Skip to content

Commit

Permalink
Merge pull request #29 from eddex/enhancement/charts
Browse files Browse the repository at this point in the history
A nice burndown chart to get an overview of your progress
  • Loading branch information
Lextum authored Jan 30, 2020
2 parents 6e76446 + d39a7b9 commit 48e2a93
Show file tree
Hide file tree
Showing 12 changed files with 484 additions and 199 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Marco & Brian

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ Brought to you by [@Lextum](https://github.com/Lextum) and [@eddex](https://gith

Want to add some missing modules, fix a bug or add a new, awesome feature? That's great. But please read [CONTRIBUTING.md](CONTRIBUTING.md) first!

## Features

![screenshot](screenshot.png)

The browser add-on puts the following features to the page 'Meine Anmeldungen' on 'MyCampus':
- A simple table with all your modules, credits and grades
- An overview of how many modules of each type have been done / are still needed.
- An overview of your grades including grade distribution and average.
- A burndown chart to visualize your credit progress.

## Installation

You only have to install the extension once. After this you'll get automatic updates!
Expand Down Expand Up @@ -64,7 +72,8 @@ Chrome does not support third party extensions anymore. Maybe we'll publish the
2. Add everthing from `src` to a `.zip` file:
- `data/` directory
- `icons/` directory
- `components/` directory
- `lib/` directory
- `templates/` directory
- `LICENSE` file
- `main.js` file
- `manifest.json` file
Expand Down
23 changes: 4 additions & 19 deletions src/LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
MIT License
Copyright (c) 2020 Marco & Brian

Copyright (c) 2019 Marco
Released under the MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The full source code and license can be found at
https://github.com/eddex/hslu-simple-mep-results
28 changes: 0 additions & 28 deletions src/components/credits_by_module_type_table.html

This file was deleted.

21 changes: 17 additions & 4 deletions src/components/helpers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/*
/**
* Component for helper functions.
*/
const Helpers = {

/*
/**
* Given a current value and a max value, calculate the percentage.
* The result can be used for progress bars.
*
* @param current: The current value.
* @param max: The maximum value.
* @returns: A number between 0 and 100 representing the current progress.
*/
calculateProgress: (current, max) => {
let progress = Math.round(current / max * 100);
Expand All @@ -15,19 +19,28 @@ const Helpers = {
return progress;
},

/*
/**
* Add an h2 title as the first child of the given DOM element.
*
* @param element: The HTML element that should contain the title.
* Usually a div element.
* @param text: The text for the new title element.
*/
addTitleToDocument: (element, text) => {
const title = document.createElement('h2');
title.appendChild(document.createTextNode(text));
element.insertBefore(title, element.firstChild);
},

/*
/**
* Helper method to read a file that is included in this browser extension.
* The file needs to be registered in manifest.json!
* Chome and Firefox have different APIs for this.
*
* @param filePath: The path to a file from the root of the extension (src/).
* e.g. data/file.json
*
* @returns: An URL that can be used to load the file with a web request.
*/
getExtensionInternalFileUrl: (filePath) => {

Expand Down
83 changes: 71 additions & 12 deletions src/components/module_parser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* Update the base module type list for other studies than information science.
*
* Sometimes the same module can have a different module type depending on the study (I, WI, ICS, DI etc).
Expand All @@ -11,7 +11,7 @@ const updateModuleTypeList = async (oldModuleTypeList, jsonFilePath) => {

const ModuleParser = {

/*
/**
* Gets the value ("y") of a specified key ("x") in a 'detail' element of the API response.
* detail: [
* key: "x",
Expand All @@ -28,7 +28,58 @@ const ModuleParser = {
return '';
},

/*
/**
* Check if a module was done in Autumn.
* Modules are marked with 'H' for 'Herbstsemester' (autumn)
* or 'F' for 'Frühlingssemester' (spring).
*/
isAutumnSemester: (hsluModule) => {
const includesH = hsluModule.anlassnumber.split('.')[2].includes('H');
const includesF = hsluModule.anlassnumber.split('.')[2].includes('F');
return includesH || includesF ? includesH : undefined;
},

/**
* Calculate the semester.
*/
calculateSemester: (hsluModule, firstModule) => {

const startYear = new Date(firstModule.from).getFullYear();
const isStartInAutumn = ModuleParser.isAutumnSemester(firstModule);

// the lastPart of the anlassnumber is something like 'F1901'
const lastPart = hsluModule.anlassnumber.split('.')[2];
const moduleYear = Number('20' + lastPart.substring(1, 3));
const isModuleInAutumn = ModuleParser.isAutumnSemester(hsluModule);

const yearDifference = (moduleYear - startYear)

let semester = undefined;
if (isModuleInAutumn === undefined) {
// we need this early abort because of entries like 'I.BA_PTA_b.1618'
// (which is not even a real module!)
return semester;
}

if (isStartInAutumn) {
if (isModuleInAutumn) {
semester = yearDifference * 2 + 1;
}
else {
semester = yearDifference * 2;
}
} else {
if (isModuleInAutumn) {
semester = yearDifference * 2 + 2;
}
else {
semester = yearDifference * 2 + 1;
}
}
return semester;
},

/**
* The module name includes the module id.
* But there are different formats for the module names.
*
Expand Down Expand Up @@ -67,7 +118,7 @@ const ModuleParser = {
}
},

/*
/**
* Generates an array of module objects using the API and the module type mapping json file.
*/
generateModuleObjects: async (studyAcronym) => {
Expand All @@ -92,24 +143,32 @@ const ModuleParser = {
return;
}

firstModule = anlasslistApiResponse.items
.slice()
.reverse()
.find(modul => ModuleParser.isAutumnSemester(modul) != undefined);

anlasslistApiResponse.items.forEach(item => {

let parsedModule = {};

let passed = item.prop1[0].text == 'Erfolgreich teilgenommen';
parsedModule.passed = passed;

parsedModule[MarkKey] = item.note === null ? 'n/a' : item.note;
parsedModule[GradeKey] = item.grade === null ? 'n/a' : item.grade;
parsedModule.mark = item.note === null ? 'n/a' : item.note;
parsedModule.grade = item.grade === null ? 'n/a' : item.grade;
parsedModule.name = item.anlassnumber;
parsedModule.from = item.from;
parsedModule.to = item.to;

parsedModule.semester = ModuleParser.calculateSemester(item, firstModule);

let details = item.details;
ItemDetailKeys.forEach(key => {
let value = ModuleParser.getItemDetailsValueByKey(details, key);
parsedModule[key] = value;
});
const creditsKey = 'ECTS-Punkte';
parsedModule.credits = ModuleParser.getItemDetailsValueByKey(details, creditsKey);

let moduleId = ModuleParser.getModuleIdFromModuleName(parsedModule[NameKey]);
parsedModule[ModuleTypeKey] = moduleTypeList[moduleId];
let moduleId = ModuleParser.getModuleIdFromModuleName(parsedModule.name);
parsedModule.moduleType = moduleTypeList[moduleId];

modules.push(parsedModule);
});
Expand Down
7 changes: 7 additions & 0 deletions src/lib/Chart.bundle.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 48e2a93

Please sign in to comment.