Releasing an assignment

.. seealso:: :doc:`/command_line_tools/nbgrader-assign` Command line options for ``nbgrader assign`` :doc:`01_philosophy` Details about how the directory hierarchy is structured :doc:`/config_options` Details on ``nbgrader_config.py``
After an assignment has been created with the assignment toolbar, you will want to create a release version of the assignment for the students. As described in :doc:`01_philosophy`, you need to organize your files in a particular way. For releasing assignments, you should have the master copy of your files saved (by default) in the following source directory structure:
{course_directory}/source/{assignment_id}/{notebook_id}.ipynb

Note: The student_id is not included here because the source and release versions of the assignment are the same for all students.

After running nbgrader assign, the release version of the notebooks will be:

{course_directory}/release/{assignment_id}/{notebook_id}.ipynb

As a reminder, the instructor is responsible for distributing this release version to their students using their institution's existing student communication and document distribution infrastructure.

Example: Instructor workflow for generating an assignment release

This example walks an instructor through the workflow for generating an assignment and preparing it for release to students:

  1. Add problem set to the source folder
  2. Set up connection to the database and add the assignment
  3. Assign a problem set using nbgrader
  4. Inspect the release folder

1. Add problem set to the source folder

To simplify this example, two notebooks of the assignment have already been stored in the source/Problem Set 1 folder:

2. Set up connection to the database and add the assignment

Setting up the database is the first workflow step to create a release version of an assignment.

A connection to the database is set by passing Gradebook the default database url, sqlite:///gradebook.db which links to the sqlite database gradebook.db. If this database does not already exist, nbgrader will automatically create it. By default, the nbgrader commands (like nbgrader assign) will assume that this database is called gradebook.db and that it lives in the root of your course directory, though its name and path can be configured in nbgrader_config.py.

Next, the assignment is added to the database and the assignment's due date is set using add_assignment:


In [ ]:
import os

# remove an existing database
if os.path.exists("gradebook.db"):
    os.remove("gradebook.db")

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

# add the assignment to the database and specify a due date
gb.add_assignment("Problem Set 1", duedate="2015-02-01 15:00:00.000000 PST")

3. Assign a problem set using nbgrader

Now that the gradebook is set up, run nbgrader assign. When running nbgrader assign, the assignment name (which is "Problem Set 1") is passed. We also specify a header notebook (source/header.ipynb) to preprend at the beginning of each notebook in the assignment. By default, this command should be run from the root of the course directory:


In [ ]:
%%bash

nbgrader assign "Problem Set 1" --IncludeHeaderFooter.header=source/header.ipynb

4. Inspect the release folder

Upon completion of nbgrader assign in the previous step, there will be a new folder called release with the same structure as source. The release folder contains the actual release version of the assignment files: