Assign and release an assignment¶
See also
- nbgrader assign
- Command line options for
nbgrader assign - How to structure course files
- Details about how the directory hierarchy is structured
- Configuration 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 How to structure course files, 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.
Workflow example: Instructor generating an assignment release¶
This example walks an instructor through the workflow for generating an assignment and preparing it for release to students:
- Add problem set to the source folder
- Set up connection to the database and add the assignment
- Assign a problem set using nbgrader
- 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. Configure assignments in the config file¶
Creating a nbgrader_config.py file and configuring the list of your
assignments is the first workflow step to create a release version of an
assignment. These assignments will be automatically added 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.
%%file nbgrader_config.py
c = get_config()
c.NbGrader.db_assignments = [dict(name="Problem Set 1")]
Writing nbgrader_config.py
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:
%%bash
nbgrader assign "Problem Set 1" --IncludeHeaderFooter.header=source/header.ipynb
[AssignApp | INFO] Copying /Users/jhamrick/project/tools/nbgrader/docs/source/user_guide/source/./Problem Set 1/jupyter.png -> /Users/jhamrick/project/tools/nbgrader/docs/source/user_guide/release/./Problem Set 1/jupyter.png
[AssignApp | INFO] Updating/creating assignment 'Problem Set 1': {}
[AssignApp | INFO] Converting notebook /Users/jhamrick/project/tools/nbgrader/docs/source/user_guide/source/./Problem Set 1/Problem 1.ipynb to notebook
[AssignApp | INFO] Writing 8082 bytes to /Users/jhamrick/project/tools/nbgrader/docs/source/user_guide/release/./Problem Set 1/Problem 1.ipynb
[AssignApp | INFO] Converting notebook /Users/jhamrick/project/tools/nbgrader/docs/source/user_guide/source/./Problem Set 1/Problem 2.ipynb to notebook
[AssignApp | INFO] Writing 2517 bytes to /Users/jhamrick/project/tools/nbgrader/docs/source/user_guide/release/./Problem Set 1/Problem 2.ipynb
[AssignApp | INFO] Setting destination file permissions to 644
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: