Autograde a students' solution

.. seealso:: :doc:`/command_line_tools/nbgrader-autograde` Command line options for ``nbgrader autograde`` :doc:`01_philosophy` Details about how the directory hierarchy is structured
After assignments have been submitted by students, you will want to save them into a ``submitted`` directory. As described in :doc:`01_philosophy`, you need to organize your files in a particular way. For autograding assignments, you should have the submitted versions of students' assignments organized as follows:
submitted/{student_id}/{assignment_id}/{notebook_id}.ipynb

After running nbgrader autograde, the autograded version of the notebooks will be:

autograded/{student_id}/{assignment_id}/{notebook_id}.ipynb

Example

In the following example, we have an assignment with two notebooks. There are two submissions of the assignment:

Submission 1:

Submission 2:

Before we can actually start grading, we need to actually record who the students are. We can do this using the API provided by nbgrader, which provides access to a database to store information about students and their grades:


In [ ]:
# create a connection to the db using the nbgrader API
from nbgrader.api import Gradebook
gb = Gradebook("sqlite:///gradebook.db")

# add some students to the database
gb.add_student("Bitdiddle", first_name="Ben", last_name="Bitdiddle")
gb.add_student("Hacker", first_name="Alyssa", last_name="Hacker")
gb.add_student("Reasoner", first_name="Louis", last_name="Reasoner")
Note: the assignment should also already be in the database. An example of how to add it is given in :doc:`03_generating_assignments`.

Once the database has been set up with the students, we can run the autograder:


In [ ]:
%%bash

nbgrader autograde "Problem Set 1"

When grading the submission for Bitdiddle, you'll see some warnings that look like "Checksum for grade cell correct_squares has changed!". What's happening here is that nbgrader has recorded what the original contents of the grade cell correct_squares (when nbgrader assign was run), and is checking the submitted version against this original version. It has found that the submitted version changed (perhaps this student tried to cheat by commenting out the failing tests), and has therefore overwritten the submitted version of the tests with the original version of the tests.

You may also notice that there is a note saying "Problem Set 1 for Bitdiddle is 86303.948203 seconds late". What is happening here is that nbgrader is detecting a file in Bitdiddle's submission called timestamp.txt, reading in that timestamp, and saving it into the database. From there, it can compare the timestamp to the duedate of the problem set, and compute whether the submission is at all late.

Once the autograding is complete, there will be new directories for the autograded versions of the submissions:

Autograded submission 1:

Autograded submission 2: