Makes getting grades and other data from magister easier.
npm install magister-tools

Makes getting grades and other data from Magister easier.
Uses Magister.js Written in NodeJS.
---
I am open to any suggestions.
---
npm install magister-tools
`
Cloning github source code:
1: Clone the source code.
`
git clone https://github.com/skillzzjesse/magister-tools.git
`
2: install the dependencies.
`
npm install
`
3: Profit??Example usage
`js
var magister_tools = require('magister-tools');magister_tools.magisterLogin({
school: 'xxxx' || {url: 'xxxx'},
username: 'xxxx',
password: 'xxxx'
}, function (err, magisterlogin) {
if (err) {
// Handle error..
}
// This is the callback function.
// What to do when logged in to Magister.
// Get the current course for the logged in user.
magister_tools.fetchCurrentCourse(magisterlogin, function (err, course) {
if (err) {
// Handle error..
}
// What to do when we have the current course for the logged in user.
magister_tools.fetchGrades(course, function (err, grades) {
if (err) {
// Handle error...
}
// What to do when we've got the grades for the current course of the logged in user.
// Select the endgrades (avarage grades) from this list of grades.
var endgrades = magister_tools.selectEndGrades(grades);
/*=======================================================
**
Now do whatever you want with these endgrades.
**
=======================================================*/
})
})
}, function () {
// What to do before logging in to Magister.
// This is optional but can be useful, for example:
// log something to the console indicating you're trying to login.
});
`Or use the (new) shortcut function
`js
var magister_tools = require('magister-tools');var login = {
school: 'xxxx' || {url: 'xxxx'},
username: 'xxxx',
password: 'xxxx'
}
magister_tools.fetchEndGrades(login, function (err, endGrades) {
if (err) {
// Handle the error
}
/ Do something with the endGrades, for example log them /
console.log(endGrades);
}, function () {
// What to do before logging in to Magister.
// This is optional but can be useful, for example:
// log something to the console indicating you're trying to login.
})
`
---Documentation
Contents
* magisterLogin()
* fetchCurrentCourse()
* fetchGrades()
* selectEndGrades() Shortcut functions
* fetchEndGrades()
---
$3
This function logs into magister using MagisterJS. | Param | Type | Description |
| --- | --- | --- |
| settings | Object | An object containing the data needed to login to magister. |
| callback | function | A callback function taking two parameters. -> err, magisterlogin |
| doFirst | optional function | A function the program needs to excecute before trying to login to Magister. For instance: logging something to the console indicating we're trying to log in. This is optional|
$3
This function fetches the current course for the logged in user. | Param | Type | Description |
| --- | --- | --- |
| magisterlogin | ? | magisterlogin. (pass in magisterlogin from the callback of the magisterLogin method) |
| callback | function | A callback function taking two parameters. -> err, currentcourse |
$3
This function fetches the grades for the course of the logged in user. | Param | Type | Description |
| --- | --- | --- |
| course | Array | course: A Course (like: 4 VWO E/M 14-15) (You can get the courses from MagisterJS) |
| callback | function | A callback function taking two parameters. -> err, grades |
$3
This function selects the endgrades from a list of grades. ⇒ Object
Returns: Object - endgrades An object structured like this: `js
{ class: endGrade }
// For example (with default settings)
{EN: 7.9, WB: 6.5}
`| Param | Type | Description |
| --- | --- | --- |
| grades | Array | A list of all the grades (generated by MagisterJS) |
| settings | Object | (OPTIONAL) Settings determining the functions behavior and output. |
| settings.fullClassName | Boolean | If the function should use the full class name or the class abbreviation. (DEAFAULT: false) |
| settings.gradeToNumber | Boolean | If the function should convert the grade to a JS number or leave it a string. (DEAFAULT: true) |
---
Shortcut functions
The Goal of this module is to write less and do more! The normal way you would use this module will result in quite a lot of code still.
See the example.
Shortcut functions allow you to write even less code and still get the desired results.---
$3
This function fetches the endgrades from magister for a specified user.Note that this is a shortcut function designed to make using this
module just a little easier.
However, it has less customizability since the function will use default
settings in the selectEndGrades function.
Also tracking where an error occurred while getting the data from Magister
isn't possible.
Returns: Object - endgrades An object structured like this: (Note that it will return via the callback)
`js
{ class: endGrade }
// For example (with default settings)
{EN: 7.9, WB: 6.5}
``| Param | Type | Description |
| --- | --- | --- |
| settings | Object | An object containing the data needed to login to magister. |
| callback | function | A callback function taking two parameters -> err, endgrades. |
| doFirst | function | (OPTIONAL) A function the program needs to execute before trying to login to Magister. For instance: logging something to the console indicating we're trying to log in. |
---
The software is provided as is. It might work as expected - or not. Just don't blame me.