Most of the important information that nbgrader has access to---information about students, assignments, grades, etc.---is stored in the nbgrader database. Much of this is added to the database automatically by nbgrader, with the exception of two types of information: which students are in your class, and which assignments you have.
There are two methods for adding students and assignments to the database.
In [1]:
%%bash
# remove the existing database, to start fresh
rm gradebook.db
To add assignments, we can use the nbgrader db assignment add
command, which takes the name of the assignment as well as optional arguments (such as its due date):
In [2]:
%%bash
nbgrader db assignment add ps1 --duedate="2015-02-02 17:00:00 UTC"
After we have added the assignment, we can view what assignments exist in the database with nbgrader db assignment list
:
In [3]:
%%bash
nbgrader db assignment list
An alternate way to add assignments is a batch method of importing a CSV file. The file must have a column called name
, and may optionally have columns for other assignment properties (such as the due date):
In [4]:
%%file assignments.csv
name,duedate
ps1,2015-02-02 17:00:00 UTC
ps2,2015-02-09 17:00:00 UTC
Then, to import this file, we use the nbgrader db assignment import
command:
In [5]:
%%bash
nbgrader db assignment import assignments.csv
We can also remove assignments from the database with nbgrader db assignment remove
. Be very careful using this command, as it is possible you could lose data!
In [6]:
%%bash
nbgrader db assignment remove ps1
Managing students in the database works almost exactly the same as managing assignments. To add students, we use the nbgrader db student add
command:
In [7]:
%%bash
nbgrader db student add bitdiddle --last-name=Bitdiddle --first-name=Ben
nbgrader db student add hacker --last-name=Hacker --first-name=Alyssa
And to list the students in the database, we use the nbgrader db student list
command:
In [8]:
%%bash
nbgrader db student list
Like with the assignments, we can also batch add students to the database using the nbgrader db student import
command. We first have to create a CSV file, which is required to have a column for id
, and optionally may have columns for other student information (such as their name):
In [9]:
%%file students.csv
id,last_name,first_name,email
bitdiddle,Bitdiddle,Ben,
hacker,Hacker,Alyssa,
In [10]:
%%bash
nbgrader db student import students.csv
We can also remove students from the database with nbgrader db student remove
. Be very careful using this command, as it is possible you could lose data!
In [11]:
%%bash
nbgrader db student remove bitdiddle