Fetching assignments

See also

nbgrader fetch
Command line options for nbgrader fetch
nbgrader list
Command line options for nbgrader list
Configuration options
Details on nbgrader_config.py

From the student’s perspective, they can list what assignments have been released, and then fetch a copy of the assignment to work on. First, we’ll create a temporary directory to represent the student’s home directory:

%%bash

# remove the fake student home directory if it exists, for demo purposes
rm -rf /tmp/student_home

# create the fake student home directory and switch to it
mkdir /tmp/student_home

If you are not using the default exchange directory (as is the case here), you will additionally need to provide your students with a configuration file that sets the appropriate directory for them:

%%file /tmp/student_home/nbgrader_config.py

c = get_config()
c.TransferApp.exchange_directory = '/tmp/exchange'
c.NbGrader.course_id = "example_course"
Writing /tmp/student_home/nbgrader_config.py

From the command line

From the student’s perspective, they can see what assignments have been released using nbgrader list, and passing the name of the class:

%%bash
export HOME=/tmp/student_home && cd $HOME

nbgrader list
[ListApp | INFO] Released assignments:
[ListApp | INFO] example_course Problem Set 1

They can then fetch an assignment for that class using nbgrader fetch and passing the name of the class and the name of the assignment:

%%bash
export HOME=/tmp/student_home && cd $HOME

nbgrader fetch "Problem Set 1"
[FetchApp | INFO] Source: /tmp/exchange/example_course/outbound/Problem Set 1
[FetchApp | INFO] Destination: /private/tmp/student_home/Problem Set 1
[FetchApp | INFO] Fetched as: example_course Problem Set 1

Note that running nbgrader fetch copies the assignment files from the exchange directory to the local directory, and therefore can be used from any directory:

%%bash

ls -l "/tmp/student_home/Problem Set 1"
total 40
-rw-r--r--  1 jhamrick  wheel  8082 Mar  3 09:05 Problem 1.ipynb
-rw-r--r--  1 jhamrick  wheel  2517 Mar  3 09:05 Problem 2.ipynb
-rw-r--r--  1 jhamrick  wheel  5733 Mar  3 09:05 jupyter.png

Additionally, the nbgrader fetch (as well as nbgrader submit) command also does not rely on having access to the nbgrader database – the database is only used by instructors.

From the notebook dashboard

Alternatively, students can fetch assignments using the assignment list notebook server extension. You must have installed the extension by following the instructions here, after which you should see an “Assignments” tab in dashboard:

The image above shows that there has been one assignment released (“ps0”) for the class “cogsci131”. To get this assignment, students can click the “Fetch” button (analagous to running nbgrader fetch ps0 --course cogsci131. Note: this assumes nbgrader is always run from the root of the notebook server, which on JupyterHub is most likely the root of the user’s home directory.

After the assignment is fetched, it will appear in the list of “Downloaded assignments”:

Students can click on the name of the assignment to expand it and see all the notebooks in the assignment:

Clicking on a particular notebook will open it in a new tab in the browser.