nbgrader

repository·main·Indexed 20 days ago

https://github.com/jupyter/nbgrader

A system for assigning and grading Jupyter notebooks, providing tools for instructors and students to manage the assignment lifecycle. It includes a toolbar extension, a 'formgrader' extension for instructors, an assignment list extension for students, and command line tools. The system supports autograding, manual grading, and database management via the Gradebook class for tracking students, assignments, and submissions.

Tokens
44.4K
Snippets
96
Records
259
Agent score
80%

What's inside nbgrader

  1. Overview of nbgrader command line tools

    main

    nbgrader provides a suite of command line tools categorized by user role and purpose.

    • Basic commands: Core utilities for running nbgrader and managing configuration.
    • Instructor commands: Tools for creating assignments, validating them, autograding, and managing solutions/feedback.
    • Database commands: Utilities to manage the nbgrader database, including adding, importing, removing, and listing students and assignments.
    • Shared server commands (Instructor): Commands for releasing assignments/feedback and collecting submissions in a shared environment (e.g., JupyterHub).
    • Shared server commands (Student): Commands for students to list, fetch, validate, and submit assignments in a shared environment.
  2. Overview of nbgrader functionality

    main

    nbgrader is a tool designed for creating and grading assignments using Jupyter Notebooks. It streamlines the workflow for instructors by providing the following capabilities:

    • Assignment Creation: Instructors create a single master copy of an assignment containing instructions, tests, and canonical solutions. nbgrader can then generate student versions by automatically removing the solutions.
    • Automated Grading: The tool executes student notebooks and stores test results in a database to provide automatic grading for code-based exercises.
    • Manual Grading: Using the formgrader Jupyter Notebook extension, instructors can manually grade free-response answers and assign partial credit.
    • Feedback: Instructors can provide personalized feedback, including comments and detailed error information, for each student submission.
    • JupyterHub Integration: When used with JupyterHub, nbgrader manages the full lifecycle of an assignment: instructors can distribute assignments, students can fetch and submit them via the Jupyter interface, and instructors can collect all submissions with a single command.
  3. Overview of nbgrader features

    main

    nbgrader is a system designed for assigning and grading Jupyter notebooks. It provides several interfaces for different user roles:

    • Instructors: Can use a toolbar extension within Jupyter notebooks to guide assignment and grading tasks, or the 'formgrader' extension to manage the full lifecycle of an assignment (generating student versions, releasing, collecting, autograding, and manual grading).
    • Students: Can use the assignment list extension to view, fetch, submit, and validate their assignments.
    • Automated/Power Users: Can use command line tools to efficiently generate, assign, release, collect, and grade notebooks.
  4. Overview of nbgrader interfaces

    main

    nbgrader provides three primary interfaces for different user roles:

    1. Student Assignment List Extension: A Jupyter extension for students to view, fetch, submit, and validate assignments, as well as review feedback.
    2. Instructor Toolbar Extension: A Jupyter extension that guides instructors through assignment and grading tasks directly within the notebook interface.
    3. Instructor Formgrader Extension: A Jupyter extension that provides access to core nbgrader functionality (generating, releasing, collecting, autograding, and manual grading) via a form-based interface.
  5. How autograding works in nbgrader

    main

    Autograding in nbgrader functions by executing the notebook, similar to the "Restart and run all cells" command.

    Mechanism:

    1. The notebook is run from top to bottom.
    2. nbgrader looks for cells marked as autograder tests that produced an error output.
    3. An error is detected if there is any text on the standard error stream (stderr) for that cell.
    4. If an error is found, the point value associated with that specific test cell is subtracted from the total.

    Important Notes:

    • Kernel Support: The Jupyter kernel must write error messages to the stderr stream for autograding to function. Some language kernels may not support this.
    • Partial Credit: While not natively implemented as a complex system, you can simulate partial credit by dividing a single task into multiple autograded test cells.
  6. Understand the nbgrader JSON metadata structure

    main

    nbgrader stores its configuration and state within the Jupyter notebook source itself. All nbgrader-specific information is stored at the cell level within the cell's metadata field, under a dictionary keyed as nbgrader. This structure allows nbgrader to track grading requirements, solutions, and integrity via commands like nbgrader generate_assignment, nbgrader validate, and nbgrader autograde.

    {
        "cells": [
            {
                "cell_type": "markdown",
                "metadata": {
                    "nbgrader": {
                        "...
                    }
                },
                "source": ["an example cell\n"]
            }
        ]
    }
  7. Understand the nbgrader CourseDirectory structure

    main

    The CourseDirectory object defines the directory structure used by nbgrader to organize assignments and student work. When implementing or interacting with an Exchange, you must respect these directory roles.

    Default directory names:

    • source_directory: Where new assignments created by instructors are stored (default: source).
    • release_directory: Where assignments processed for release are copied (default: release).
    • submitted_directory: Where student submissions are copied when an instructor collects them (default: submitted).
    • autograded_directory: Where student submissions are copied after being autograded (default: autograded).
    • feedback_directory: Where feedback is copied when instructors generate it (default: feedback).
    • solution_directory: Where solutions are copied when instructors generate them (default: solution).

    Standard File Path Pattern: By default, nbgrader expects the following hierarchy: {nbgrader_step}/{student_id}/{assignment_id}/{notebook_id}.ipynb

  8. Customize nbgrader behavior with plugins

    main

    nbgrader allows for limited customization of its behavior through predefined plugin methods or by implementing your own custom plugins.

    Supported plugin types include:

    • late-plugin: For logic that needs to run late in the process.
    • export-plugin: For customizing how notebooks are exported.
    • zipcollect-plugin: For customizing how files are collected into zip archives.

    If the existing plugin interfaces do not meet your requirements, you should open an issue on GitHub to request new functionality.

  9. Configure the nbgrader gradebook database

    main

    nbgrader uses a database to store assignment information.

    • SQLite (Default): nbgrader will automatically create a SQLite database at {course_directory}/gradebook.db. You do not need to create this manually.
    • MySQL or PostgreSQL: Since nbgrader uses SQLAlchemy, you can use these backends. However, unlike SQLite, you must create the database ahead of time before running nbgrader commands.
  10. How validation works for students

    main

    The validate extension provides a student-facing interface within the Jupyter notebook view.

    Functionality:

    • It executes the student's notebook from top to bottom.
    • It reports any errors encountered during execution.
    • It is functionally equivalent to "Restart and run all", but it does not stop execution when an error is encountered.
    • Limitation: Validation only has access to the actual notebook file the student possesses; it cannot access or execute hidden tests. If an instructor wants a test to be visible to students, it must be part of the notebook file.
  11. How to call nbgrader exchange functions

    main

    nbgrader exchange functions can be invoked through three primary interfaces:

    1. Command Line Interface (CLI): Direct execution of commands, for example: nbgrader release_assignment assignment1.
    2. formgrader server extension: This extension generally invokes methods defined in the nbgrader/apps/{foo}app.py modules.
    3. assignment_list server extension: This extension generally calls the exchange methods directly.
    nbgrader release_assignment assignment1