Skip to content

TU-Wien-dataLAB/grader-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

banner

General

Documentation Status BSD-3-Clause GitHub commit activity

Grader Service

PyPI PyPI - Python Version

Grader Labextension

PyPI PyPI - Python Version npm

Disclaimer: Grader Service is still in the early development stages. You may encounter issues while using the service.

Grader Service offers lecturers and students a well integrated teaching environment for data science, machine learning and programming classes.

Try out GraderService: .. TODO: update binder

binder

Read the official documentation.

./docs/source/_static/assets/gifs/labextension_update.gif

Requirements

JupyterHub, JupyterLab, Python >= 3.8, pip, Node.js>=12, npm

Installation

This repository contains the packages for the jupyter extensions and the grader service itself.

The grader service has only been tested on Unix/macOS operating systems.

This repository contains all the necessary packages for a full installation of the grader service.

  • grader-service: Manages students and instructors, files, grading and multiple lectures. It can be run as a standalone containerized service and can utilize a kubernetes cluster for grading assignments. This package also contains grader-convert, a tool for converting notebooks to different formats (e.g. removing solution code, executing, etc.). It can be used as a command line tool but will mainly be called by the service. The conversion logic is based on nbgrader.
pip install grader-service
  • grader-labextension: The JupyterLab plugin for interacting with the service. Provides the UI for instructors and students and manages the local git repositories for the assignments and so on. The package is located in its own repo.
pip install grader-labextension

Development Environment

Alternatively you can run the installation scripts in examples/dev_environment. Follow the documentation there. The directory also contains the config files for a local installation.

Installation from Source

To install this package from source, clone into the repository or download the zip file.

Local installation

In the grader directory run:

pip install -r ./grader_labextension/requirements.txt
pip install ./grader_labextension

pip install -r ./grader_service/requirements.txt
pip install ./grader_service

Then, navigate to the grader_labextension-directory and follow the instructions in the README file.

Development Environment

Alternatively you can run the installation scripts in examples/dev_environment. Follow the documentation there. The directory also contains the config files for a local installation.

Configuration

Check out the examples/dev_environment directory which contains configuration details or the (Administrator Guide)[https://grader-service.readthedocs.io/en/latest/admin/administrator.html].

In order to use the grader service with an LMS like Moodle, the groups first have to be added to the JupyterHub so the grader service gets the necessary information from the hub.

For this purpose, the LTI 1.3 Authenticator can be used so that users from the LMS can be added to the JupyterHub.

To automatically add the groups for the grader service from the LTI authenticator, the following post auth hook can be used.

from jupyterhub import orm
import sqlalchemy

def post_auth_hook(authenticator, handler, authentication):
    db: sqlalchemy.orm.session.Session = authenticator.db
    log = authenticator.log

    course_id = authentication["auth_state"]["course_id"].replace(" ","")
    user_role = authentication["auth_state"]["user_role"]
    user_name = authentication["name"]

    # there are only Learner and Instructors
    if user_role == "Learner":
        user_role = "student"
    elif user_role == "Instructor":
        user_role = "instructor"
    user_model: orm.User = orm.User.find(db, user_name)
    if user_model is None:
        user_model = orm.User()
        user_model.name = user_name
        db.add(user_model)
        db.commit()

    group_name = f"{course_id}:{user_role}"
    group = orm.Group.find(db, group_name)
    if group is None:
        log.info(f"Creating group: '{group_name}'")
        group = orm.Group()
        group.name = group_name
        db.add(group)
        db.commit()

    extra_grader_groups = [g for g in user_model.groups if g.name.startswith(f"{course_id}:") and g.name != group_name]
    for g in extra_grader_groups:
        log.info(f"Removing user from group: {g.name}")
        g.users.remove(user_model)
        db.commit()

    if user_model not in group.users:
        log.info(f"Adding user to group: {group.name}")
        group.users.append(user_model)
        db.commit()

    return authentication

Make sure that the course_id does not contain any spaces or special characters!

Optional Configuration of JupyterLab >=3.4

The grader labextension also uses the embedded cell toolbar of JupyterLab for further cell manipulation. These optional features include:

  • Run Cell: This command simply run the current cell without advancing.
  • Revert Cell: In the conversion process new metadata is set to allow students to revert every answer cell to their original state.
  • Show Hint: Students can access a hint to a task if one is specified.

To access these commands buttons have to be added to the JupyterLab cell toolbar by editing the overrides.json file. We also recommend that all other built in cell toolbar buttons should be disabled in the config because they might enable unwanted cell manipulation by students.

A sample overrides.json file could look like this:

{
    "@jupyterlab/cell-toolbar-extension:plugin": {
        "toolbar": [
            {
                "args": {},
                "command": "notebookplugin:run-cell",
                "disabled": false,
                "rank": 501,
                "name": "run-cell"
            },
            {
                "args": {},
                "command": "notebookplugin:revert-cell",
                "disabled": false,
                "rank": 502,
                "name": "revert-cell"
            },
            {
                "args": {},
                "command": "notebookplugin:show-hint",
                "disabled": false,
                "rank": 503,
                "name": "show-hint"
            }
        ]
    }
}

About

Grader Service offers lecturers and students a well integrated teaching environment for data science, machine learning and programming classes.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 11