MUSA Graderv0.1.0

API reference · grader/rubric.py · 164 lines

grader.rubric

YAML rubric loading (design.md section 20).

A rubric file declares the assignment, its point breakdown, and per-item config blocks. Expected values (Center City ZIPs, tolerances, the final answer) live here rather than in code so a TA can correct them against the official solution without touching Python.

Summary

NameKindDescription
RubricItemclassOne graded line of a rubric, as declared in the YAML rubric: list.
RubricclassA parsed rubric file. Every top-level YAML block is kept as-is, so assignment graders can read their own configuration from settings, probe, discovery and data.
RubricErrorclassRaised when a rubric file is missing or structurally invalid.
load_rubric()functionParse and validate a rubric YAML file.
available_rubrics()functionMap assignment id -> rubric path for every parsable rubric on disk.

Constants

NameValueNotes
RUBRIC_DIRPath(__file__).resolve().parent.parent / 'rubrics'
VALID_TYPES{'execution', 'structural', 'deterministic', 'hidden_test', 'qualitative'}

Classes

class RubricItem #[source]

dataclass

One graded line of a rubric, as declared in the YAML rubric: list.

Fields

NameTypeDefaultNotes
idstrrequired
namestrrequired
pointsfloatrequired
typestr'deterministic'
descriptionstr''
configdict[str, Any]field(default_factory=dict)

Properties

property is_qualitative: bool #[source]

No description.

class Rubric #[source]

dataclass

A parsed rubric file. Every top-level YAML block is kept as-is, so assignment graders can read their own configuration from settings, probe, discovery and data.

Fields

NameTypeDefaultNotes
idstrrequired
namestrrequired
versionstrrequired
total_pointsfloatrequired
itemslist[RubricItem]required
settingsdict[str, Any]field(default_factory=dict)
probedict[str, Any]field(default_factory=dict)
discoverydict[str, Any]field(default_factory=dict)
datadict[str, Any]field(default_factory=dict)Data the instructor supplies for every submission (design.md §16-17).
source_pathstr | NoneNone

Properties

property requires_data: bool #[source]

No description.

property offers_data: bool #[source]

Whether the sidebar should let a TA supply data for this assignment.

Assignment 3 does not require its zip — it is graded from the outputs each student saved — but supplying it lets the grader re-run every notebook and confirm them, so the option has to be there.

property declared_points: float #[source]

No description.

Methods

item(rubric_id: str) -> RubricItem | None #[source]

No description.

label() -> str #[source]

No description.

class RubricError(ValueError) #[source]

Raised when a rubric file is missing or structurally invalid.

Functions

load_rubric(path: str | Path) -> Rubric #[source]

Parse and validate a rubric YAML file.

Raises RubricError when the file is missing or unparsable, assignment.id is absent, the rubric is empty, an item id is missing or duplicated, an item type is unknown, or the item points do not add up to total_points.

available_rubrics(directory: str | Path = RUBRIC_DIR) -> dict[str, Path] #[source]

Map assignment id -> rubric path for every parsable rubric on disk.