Gradebook#

Submodules#

Gradebook#

class Gradebook(dest_json: str, log: Optional[logging.Logger] = None)[source]#

The gradebook object to interface with the JSON output file of a conversion. Should only be used as a context manager when changing the data.

add_comment(solution_cell: str, notebook: str, comment: grader_convert.gradebook.models.Comment) grader_convert.gradebook.models.Comment[source]#

Add a comment to a notebook. :param solution_cell: the name of a solution or task cell :param notebook: the name of a notebook :param comment: the comment to add :return: comment

add_grade(grade_cell: str, notebook: str, grade: grader_convert.gradebook.models.Grade) grader_convert.gradebook.models.Grade[source]#

Add a grade to a notebook. :param grade_cell: the name of a grade or task cell :param notebook: the name of a notebook :param grade: the grade to add :return: grade

add_grade_cell(name: str, notebook: str, **kwargs: dict) grader_convert.gradebook.models.GradeCell[source]#

Add a new grade cell to an existing notebook. :param name: the name of the new grade cell :param notebook: the name of an existing notebook :param kwargs: additional keyword arguments for GradeCell :return: grade_cell

add_notebook(name: str, **kwargs: dict) grader_convert.gradebook.models.Notebook[source]#

Add a new notebook to the GradeBookModel. Parameters :param name: the name of the new notebook :param kwargs: additional keyword arguments for the Notebook object :return: notebook : Notebook

add_solution_cell(name: str, notebook: str, **kwargs: dict) grader_convert.gradebook.models.SolutionCell[source]#

Add a new solution cell to an existing notebook. :param name: the name of the new solution cell :param notebook: the name of an existing notebook :param kwargs: additional keyword arguments for SolutionCell :return: solution_cell : SolutionCell

add_source_cell(name: str, notebook: str, **kwargs: dict) grader_convert.gradebook.models.SourceCell[source]#

Add a new source cell to an existing notebook. :param name: the name of the new source cell :param notebook: the name of an existing notebook :param kwargs: additional keyword arguments for SourceCell :return: source_cell : SourceCell

add_task_cell(name: str, notebook: str, **kwargs: dict) grader_convert.gradebook.models.TaskCell[source]#

Add a new task cell to an existing notebook. :param name: the name of the new task cell :param notebook: the name of an existing notebook :param kwargs: additional keyword arguments for TaskCell :return: task_cell

find_comment(solution_cell: str, notebook: str) grader_convert.gradebook.models.Comment[source]#

Find a particular comment in a notebook. :param solution_cell: the name of a solution or task cell :param notebook: the name of a notebook :return: comment

find_grade(grade_cell: str, notebook: str) grader_convert.gradebook.models.Grade[source]#

Find a particular grade in a notebook. If the grade does not exists an empty grade object is returned. :param grade_cell: the name of a grade or task cell :param notebook: the name of a notebook :return: grade

find_grade_cell(name: str, notebook: str) grader_convert.gradebook.models.GradeCell[source]#

Find a grade cell in a particular notebook. :param name: the name of the grade cell :param notebook: the name of the notebook :return: grade_cell

find_graded_cell(name: str, notebook: str) Union[grader_convert.gradebook.models.GradeCell, grader_convert.gradebook.models.TaskCell][source]#

Find a graded cell in a particular notebook. This can be either a GradeCell or a TaskCell. :param name: the name of the grade cell :param notebook: the name of the notebook :return: grade_cell

find_notebook(name: str) grader_convert.gradebook.models.Notebook[source]#

Find a particular notebook. :param name: the name of the notebook :return: notebook : Notebook

find_solution_cell(name: str, notebook: str) grader_convert.gradebook.models.SolutionCell[source]#

Find a solution cell in a particular notebook. :param name: the name of the solution cell :param notebook: the name of the notebook :return: solution_cell : SolutionCell

find_source_cell(name: str, notebook: str) grader_convert.gradebook.models.SourceCell[source]#

Find a source cell in a particular notebook. :param name: the name of the source cell :param notebook: the name of the notebook :return: source_cell : SourceCell

find_task_cell(name: str, notebook: str) grader_convert.gradebook.models.TaskCell[source]#

Find a task cell in a particular notebook. :param name: the name of the task cell :param notebook: the name of the notebook :return: task_cell : TaskCell

property is_in_context: bool#
remove_notebook(name: str)[source]#

Deletes an existing notebook from the gradebook. :param name: the name of the notebook to delete :return: None

update_or_create_grade_cell(name: str, notebook: str, **kwargs: dict) grader_convert.gradebook.models.GradeCell[source]#

Update an existing grade cell in a notebook, or create the grade cell if it does not exist. :param name: the name of the grade cell :param notebook: the name of the notebook :param kwargs: additional keyword arguments for GradeCell :return: grade_cell

update_or_create_notebook(name: str, **kwargs)[source]#

Update an existing notebook, or create it if it doesn’t exist. :param name: the name of the notebook :param kwargs: additional keyword arguments for the Notebook object :return: notebook : nNotebook

update_or_create_solution_cell(name: str, notebook: str, **kwargs: dict) grader_convert.gradebook.models.SolutionCell[source]#

Update an existing solution cell in a notebook, or create the solution cell if it does not exist. :param name: the name of the solution cell :param notebook: the name of the notebook :param kwargs: additional keyword arguments for SolutionCell :return: solution_cell

update_or_create_source_cell(name: str, notebook: str, **kwargs: dict) grader_convert.gradebook.models.SourceCell[source]#

Update an existing source cell in a notebook of an assignment, or create the source cell if it does not exist. :param name: the name of the source cell :param notebook: the name of the notebook :param kwargs: additional keyword arguments for SourceCell :return: source_cell

update_or_create_task_cell(name: str, notebook: str, **kwargs) grader_convert.gradebook.models.TaskCell[source]#

Update an existing task cell in a notebook, or create the task cell if it does not exist. :param name: the name of the task cell :param notebook: the name of the notebook :param kwargs: additional keyword arguments for TaskCell :return: task_cell : TaskCell

write_access()[source]#
write_model()[source]#

Writes JSON string to a JSON file

exception InvalidEntry[source]#
exception MissingEntry[source]#

Models#

class BaseCell(notebook_id: str, name: str, id: str, grade_id: str, comment_id: str)[source]#
comment_id: str#
classmethod from_dict(d: dict) Type[grader_convert.gradebook.models.BaseCell][source]#
grade_id: str#
class BaseModel[source]#
classmethod empty_dict() dict[source]#
classmethod from_dict(d: dict) Type[grader_convert.gradebook.models.BaseModel][source]#
to_dict() dict[source]#
class CellRelashionship(cell_id: str)[source]#
cell_id: str#
class CellType(value)[source]#

code

class Comment(cell_id: str, notebook_id: str, id: str, auto_comment: str, manual_comment: str)[source]#
auto_comment: str#
property comment: Optional[str]#
manual_comment: str#
class Grade(cell_id: str, notebook_id: str, id: str, auto_score: float, manual_score: float, extra_credit: float, needs_manual_grade: bool, max_score_gradecell: float, max_score_taskcell: float, failed_tests: bool)[source]#

Representation of a grade assigned to the submitted version of a grade cell.

auto_score: float#
extra_credit: float#
failed_tests: bool#

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.

classmethod from_dict(d: dict) Type[grader_convert.gradebook.models.Grade][source]#
manual_score: float#
property max_score#
max_score_gradecell: float#

The maximum possible score that can be assigned, inherited from GradeCell

max_score_taskcell: float#
needs_manual_grade: bool#
property score: float#

The overall score, computed automatically from the auto_score and manual_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

to_dict() dict[source]#
class GradeBookModel(notebooks: Dict[str, grader_convert.gradebook.models.Notebook])[source]#
classmethod from_dict(d: dict) grader_convert.gradebook.models.GradeBookModel[source]#
property notebook_id_set: Set[grader_convert.gradebook.models.Notebook]#
notebooks: Dict[str, grader_convert.gradebook.models.Notebook]#
property score: float#
to_dict() dict[source]#
class GradeCell(max_score: float, cell_type: grader_convert.gradebook.models.CellType, notebook_id: str, name: str, id: str, grade_id: str, comment_id: str)[source]#
comment_id: str#
classmethod from_dict(d: dict) grader_convert.gradebook.models.GradeCell[source]#
grade_id: str#
id: str#
name: str#
notebook_id: str#
class GradedMixin(max_score: float, cell_type: grader_convert.gradebook.models.CellType)[source]#
cell_type: grader_convert.gradebook.models.CellType#
max_score: float#
class IDMixin(id: str)[source]#
id: str#
class NameMixin(name: str)[source]#
name: str#
class Notebook(name: str, id: str, kernelspec: str, grade_cells_dict: Dict[str, Type[grader_convert.gradebook.models.GradeCell]], solution_cells_dict: Dict[str, Type[grader_convert.gradebook.models.SolutionCell]], task_cells_dict: Dict[str, Type[grader_convert.gradebook.models.TaskCell]], source_cells_dict: Dict[str, Type[grader_convert.gradebook.models.SourceCell]], grades_dict: Dict[str, Type[grader_convert.gradebook.models.Grade]], comments_dict: Dict[str, Type[grader_convert.gradebook.models.Comment]], flagged: bool)[source]#
property code_score: float#
property comments: List[Type[grader_convert.gradebook.models.Comment]]#
comments_dict: Dict[str, Type[grader_convert.gradebook.models.Comment]]#
property failed_tests: bool#
flagged: bool#

Whether this assignment has been flagged by a human grader

classmethod from_dict(d: dict) grader_convert.gradebook.models.Notebook[source]#
property grade_cells: List[grader_convert.gradebook.models.GradeCell]#
grade_cells_dict: Dict[str, Type[grader_convert.gradebook.models.GradeCell]]#
property graded_cells: List[Union[grader_convert.gradebook.models.GradeCell, grader_convert.gradebook.models.TaskCell]]#
property grades: List[Type[grader_convert.gradebook.models.Grade]]#
grades_dict: Dict[str, Type[grader_convert.gradebook.models.Grade]]#
kernelspec: str#
property max_code_score: float#
property max_score: float#
property max_written_score: float#
property score: float#
property solution_cells: List[grader_convert.gradebook.models.SolutionCell]#
solution_cells_dict: Dict[str, Type[grader_convert.gradebook.models.SolutionCell]]#
property source_cells: List[grader_convert.gradebook.models.SourceCell]#
source_cells_dict: Dict[str, Type[grader_convert.gradebook.models.SourceCell]]#
property task_cells: List[grader_convert.gradebook.models.TaskCell]#
task_cells_dict: Dict[str, Type[grader_convert.gradebook.models.TaskCell]]#
to_dict() dict[source]#
property written_score: float#
class NotebookRelashionship(notebook_id: str)[source]#
notebook_id: str#
class SolutionCell(notebook_id: str, name: str, id: str, grade_id: str, comment_id: str)[source]#
comment_id: str#
classmethod from_dict(d: dict) grader_convert.gradebook.models.SolutionCell[source]#
grade_id: str#
id: str#
name: str#
notebook_id: str#
class SourceCell(notebook_id: str, name: str, id: str, cell_type: grader_convert.gradebook.models.CellType, locked: bool, source: str, checksum: str)[source]#
cell_type: grader_convert.gradebook.models.CellType#
checksum: str#

A checksum of the cell contents. This should usually be computed using utils.compute_checksum()

classmethod from_dict(d: dict) Type[grader_convert.gradebook.models.BaseModel][source]#
locked: bool#

Whether the cell is locked (e.g. the source saved in the database should be used to overwrite the source of students’ cells)

source: str#

The source code or text of the cell

class TaskCell(max_score: float, cell_type: grader_convert.gradebook.models.CellType, notebook_id: str, name: str, id: str, grade_id: str, comment_id: str)[source]#
comment_id: str#
classmethod from_dict(d: dict) grader_convert.gradebook.models.TaskCell[source]#
grade_id: str#
id: str#
name: str#
notebook_id: str#