npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

magister-tools

v1.1.0

Published

Makes getting grades and other data from magister easier.

Downloads

13

Readme


intro

The goal of this module is to make getting grades and other data from magister easier. Getting grades from Magister using Magister.js (v1) is a mess in my opinion. For my personal use I needed a way to get the average grades of students and this module does just that.

I am open to any suggestions.

Contents


Installation

Using npm:

Install the npm package

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

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

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

Shortcut functions


magisterLogin(settings, callback[, doFirst])

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|

fetchCurrentCourse(magisterlogin, callback)

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 |

fetchGrades(course, callback)

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 |

selectEndGrades(grades[, settings])

This function selects the endgrades from a list of grades. ⇒ Object
Returns: Object - endgrades An object structured like this:

{ 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.


fetchEndGrades(settings, callback[, doFirst])

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)

{ 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. |


Suggestions

This module is in a very early state and does not have a lot of functionality yet. Any suggested features are more than welcome. If you have an awesome feature in mind please open an issue.

License & Disclaimer

This module is open-sourced under the MIT Licence (see LICENSE for the full license). So within some limits, you can do with the code whatever you want.

The software is provided as is. It might work as expected - or not. Just don't blame me.