Installing and setting up nbgrader
In what follows, we will enumerate the steps required to set up a class in nbgrader using Jupyterhub. This post assumes that JupyterHub has been set up and is running. Look at installing and configuring JupyterHub first if you haven’t done so already.
Install nbgrader:$ sudo pip3 install nbgrader
Installing plugins for nbgrader
$ jupyter nbextension install –user –py nbgrader –overwrite
$ jupyter nbextension enable –user –py nbgrader
$ jupyter serverextension enable –user –py nbgrader
Note: Replace –user with –sys-prefix for system-wide installation of all the plugins of nbgrader. Also, you may need to use sudo!
Set up a course on nbgrader$ nbgrader quickstart course_idwhere course_id is the name/ID of the course.
Setting up the exchange directory
To enable the functionalities like release and collect assignments, we need to set up the exchange directory. Within the directory of the course with course_id created above, add the following lines to the nbgrader_config.py file.
%%file nbgrader_config.py c = get_config() c.CourseDirectory.course_id = "example_course" c.Exchange.root = "/tmp/exchange" c.CourseDirectory.root = "path/to/example_course"
We specified the exchange directory as /tmp/exchange which must exist before running nbgrader again. Execute the following commands to create and configure the directory:
%%bash # remove existing directory, so we can start fresh for demo purposes rm -rf /tmp/exchange # create the exchange directory, with write permissions for everyone mkdir /tmp/exchange chmod ugo+rw /tmp/exchange
Now, we need to copy this nbgrader_config.py in a location where it is visible to the JupyterHub. To do that:$ jupyter --paths
Running this command will output the paths where jupyter will look for nbgrader_config.py file. Copy the nbgrader_config.py from course directory to any of the paths generated as output of the above command.
Following these steps should have an example (default) course and assignment set up as visible on the Formgrader extension of the user.
