Database Models¶
In general, these database models should never be modified by hand. You should
only ever modify them using a Gradebook
object, so that
changes are properly persisted to the database, and so that the models don’t end
up in an inconsistent state. However, some methods of the Gradebook
object return database model objects, so those models and their attributes are
documented here for reference.
-
class
nbgrader.api.
Student
(**kwargs)[source]¶ Database representation of a student.
-
id
¶ Unique id of the student. This could be a student ID, a username, an email address, etc., so long as it is unique.
-
first_name
¶ (Optional) The first name of the student
-
last_name
¶ (Optional) The last name of the student
-
score
¶ The overall score of the student across all assignments, computed automatically from the
score
of each submitted assignment.
-
max_score
¶ The maximum possible score the student could achieve across all assignments, computed automatically from the
max_score
of each assignment.
-
submissions
¶ A collection of assignments submitted by the student, represented as
SubmittedAssignment
objects
-
Master version of an assignment¶
-
class
nbgrader.api.
Assignment
(**kwargs)[source]¶ Database representation of the master/source version of an assignment.
-
id
¶ Unique id of the assignment (automatically generated)
-
name
¶ Unique human-readable name for the assignment, such as “Problem Set 1”
-
duedate
¶ (Optional) Duedate for the assignment in datetime format, with UTC timezone
-
submissions
¶ A collection of submissions of this assignment, represented by
SubmittedAssignment
objects.
-
num_submissions
¶ The number of submissions of this assignment
-
max_score
¶ Maximum score achievable on this assignment, automatically calculated from the
max_score
of each notebook
-
max_code_score
¶ Maximum coding score achievable on this assignment, automatically calculated from the
max_code_score
of each notebook
-
max_written_score
¶ Maximum written score achievable on this assignment, automatically calculated from the
max_written_score
of each notebook
-
-
class
nbgrader.api.
Notebook
(**kwargs)[source]¶ Database representation of the master/source version of a notebook.
-
id
¶ Unique id of the notebook (automatically generated)
-
name
¶ Unique human-readable name for the notebook, such as “Problem 1”. Note the uniqueness is only constrained within assignments (e.g. it is ok for two different assignments to both have notebooks called “Problem 1”, but the same assignment cannot have two notebooks with the same name).
-
assignment
¶ The
Assignment
object that this notebook is a part of
-
assignment_id
¶ Unique id of
assignment
-
grade_cells
¶ A collection of grade cells contained within this notebook, represented by
GradeCell
objects
-
solution_cells
¶ A collection of solution cells contained within this notebook, represented by
SolutionCell
objects
-
source_cells
¶ A collection of source cells contained within this notebook, represented by
SourceCell
objects
-
submissions
¶ A collection of submitted versions of this notebook, represented by
SubmittedNotebook
objects
-
num_submissions
¶ The number of submissions of this notebook
-
max_score
¶ Maximum score achievable on this notebook, automatically calculated from the
max_score
of each grade cell
-
max_code_score
¶ Maximum coding score achievable on this notebook, automatically calculated from the
max_score
andcell_type
of each grade cell
-
max_written_score
¶ Maximum written score achievable on this notebook, automatically calculated from the
max_score
andcell_type
of each grade cell
-
needs_manual_grade
¶ Whether there are any submitted versions of this notebook that need to be manually graded, automatically determined from the
needs_manual_grade
attribute of each submitted notebook
-
-
class
nbgrader.api.
GradeCell
(**kwargs)[source]¶ Database representation of the master/source version of a grade cell.
-
id
¶ Unique id of the grade cell (automatically generated)
-
name
¶ Unique human-readable name of the grade cell. This need only be unique within the notebook, not across notebooks.
-
max_score
¶ Maximum score that can be assigned to this grade cell
-
cell_type
¶ The cell type, either “code” or “markdown”
-
assignment
¶ The assignment that this cell is contained within, represented by a
Assignment
object
-
-
class
nbgrader.api.
SolutionCell
(**kwargs)[source]¶ -
id
¶ Unique id of the solution cell (automatically generated)
-
name
¶ Unique human-readable name of the solution cell. This need only be unique within the notebook, not across notebooks.
-
assignment
¶ The assignment that this cell is contained within, represented by a
Assignment
object
-
-
class
nbgrader.api.
SourceCell
(**kwargs)[source]¶ -
id
¶ Unique id of the source cell (automatically generated)
-
name
¶ Unique human-readable name of the source cell. This need only be unique within the notebook, not across notebooks.
-
cell_type
¶ The cell type, either “code” or “markdown”
-
source
¶ The source code or text of the cell
-
checksum
¶ A checksum of the cell contents. This should usually be computed using
nbgrader.utils.compute_checksum()
-
assignment
¶ The assignment that this cell is contained within, represented by a
Assignment
object
-
Submitted assignments¶
-
class
nbgrader.api.
SubmittedAssignment
(**kwargs)[source]¶ Database representation of an assignment submitted by a student.
-
id
¶ Unique id of the submitted assignment (automatically generated)
-
name
¶ Name of the assignment, inherited from
Assignment
-
assignment
¶ The master version of this assignment, represented by a
Assignment
object
-
assignment_id
¶ Unique id of
assignment
-
timestamp
¶ (Optional) The date and time that the assignment was submitted, in date time format with a UTC timezone
-
extension
¶ (Optional) An extension given to the student for this assignment, in time delta format
-
duedate
¶ The duedate of this student’s assignment, which includes any extension given, if applicable, and which is just the regular assignment duedate otherwise.
-
total_seconds_late
¶ The number of seconds that this assignment was turned in past the duedate (including extensions, if any). If the assignment was turned in before the deadline, this value will just be zero.
-
notebooks
¶ A collection of notebooks contained within this submitted assignment, represented by
SubmittedNotebook
objects
-
score
¶ The score assigned to this assignment, automatically calculated from the
score
of each notebook within this submitted assignment.
-
max_score
¶ The maximum possible score of this assignment, inherited from
Assignment
-
code_score
¶ The code score assigned to this assignment, automatically calculated from the
code_score
of each notebook within this submitted assignment.
-
max_code_score
¶ The maximum possible code score of this assignment, inherited from
Assignment
-
written_score
¶ The written score assigned to this assignment, automatically calculated from the
written_score
of each notebook within this submitted assignment.
-
max_written_score
¶ The maximum possible written score of this assignment, inherited from
Assignment
-
needs_manual_grade
¶ Whether this assignment has parts that need to be manually graded, automatically determined from the
needs_manual_grade
attribute of each notebook.
-
-
class
nbgrader.api.
SubmittedNotebook
(**kwargs)[source]¶ Database representation of a notebook submitted by a student.
-
id
¶ Unique id of the submitted notebook (automatically generated)
-
assignment
¶ The submitted assignment this notebook is a part of, represented by a
SubmittedAssignment
object
-
assignment_id
¶ Unique id of
assignment
-
comments
¶ Collection of comments associated with this submitted notebook, represented by
Comment
objects
-
flagged
¶ Whether this assignment has been flagged by a human grader
-
score
¶ The score assigned to this notebook, automatically calculated from the
score
of each grade cell within this submitted notebook.
-
code_score
¶ The code score assigned to this notebook, automatically calculated from the
score
andcell_type
of each grade within this submitted notebook.
-
written_score
¶ The written score assigned to this notebook, automatically calculated from the
score
andcell_type
of each grade within this submitted notebook.
-
needs_manual_grade
¶ Whether this notebook has parts that need to be manually graded, automatically determined from the
needs_manual_grade
attribute of each grade.
-
failed_tests
¶ Whether this notebook contains autograder tests that failed to pass, automatically determined from the
failed_tests
attribute of each grade.
-
-
class
nbgrader.api.
Grade
(**kwargs)[source]¶ Database representation of a grade assigned to the submitted version of a grade cell.
-
id
¶ Unique id of the grade (automatically generated)
-
assignment
¶ The submitted assignment that this grade is contained in, represented by a
SubmittedAssignment
object
-
notebook
¶ The submitted notebook that this grade is assigned to, represented by a
SubmittedNotebook
object
-
auto_score
¶ Score assigned by the autograder
-
manual_score
¶ Score assigned by a human grader
-
score
¶ The overall score, computed automatically from the
auto_score
andmanual_score
values. If neither are set, the score is zero. If both are set, then the manual score takes precedence. If only one is set, then that value is used for the score.
-
needs_manual_grade
¶ Whether a score needs to be assigned manually. This is True by default.
-
failed_tests
¶ Whether the autograded score is a result of failed autograder tests. This is True if the autograder score is zero and the cell type is “code”, and otherwise False.
-
to_dict
()[source]¶ Convert the grade object to a JSON-friendly dictionary representation. Note that this includes keys for
notebook
andassignment
which correspond to the name of the notebook and assignment, not the actual objects. It also includes a key forstudent
which corresponds to the unique id of the student, not the actual student object.
-
-
class
nbgrader.api.
Comment
(**kwargs)[source]¶ Database representation of a comment on a cell in a submitted notebook.
-
id
¶ Unique id of the comment (automatically generated)
-
name
¶ Unique name of the solution cell, inherited from
SolutionCell
-
assignment
¶ The submitted assignment that this comment is contained in, represented by a
SubmittedAssignment
object
-
notebook
¶ The submitted notebook that this comment is assigned to, represented by a
SubmittedNotebook
object
-
cell
¶ The master version of the cell this comment is assigned to, represented by a
SolutionCell
object.
-
auto_comment
¶ A comment which is automatically assigned by the autograder
-
manual_comment
¶ A commment which is assigned manually
-
comment
¶ The overall comment, computed automatically from the
auto_comment
andmanual_comment
values. If neither are set, the comment is None. If both are set, then the manual comment takes precedence. If only one is set, then that value is used for the comment.
-
to_dict
()[source]¶ Convert the comment object to a JSON-friendly dictionary representation. Note that this includes keys for
notebook
andassignment
which correspond to the name of the notebook and assignment, not the actual objects. It also includes a key forstudent
which corresponds to the unique id of the student, not the actual student object.
-