API reference · grader/results.py · 334 lines
grader.results
Grading session persistence and exports (design.md §28-29).
A session is a directory on disk. Everything the UI shows can be rebuilt from it, so the app can be closed and reopened mid-review.
Summary
| Name | Kind | Description |
|---|---|---|
GradingSession | class | One grading run and everything decided in it, persisted under results/<session_id>/. |
list_sessions() | function | Every saved session under results/, in reverse directory-name order (newest first for each assignment). |
new_session_id() | function | <assignment_id>_<YYYYmmdd>_<HHMMSS>. |
Constants
| Name | Value | Notes |
|---|---|---|
RESULTS_ROOT | Path(__file__).resolve().parent.parent / 'results' | |
SESSION_FILE | 'grading_session.json' | |
GRADES_CSV | 'grades.csv' | |
SUMMARY_JSON | 'summary.json' | |
FLAGGED_CSV | 'flagged_submissions.csv' | |
FEEDBACK_DIR | 'feedback' | |
EXECUTED_DIR | 'executed_notebooks' | |
RAW_DIR | 'raw_results' |
Classes
One grading run and everything decided in it, persisted under results/<session_id>/.
Holds a SubmissionResult per student keyed by student id, plus the rubric version and settings that produced them. save writes the session JSON, the CSVs, the class report and per-student feedback; load reads it back.
Fields
| Name | Type | Default | Notes |
|---|---|---|---|
session_id | str | required | |
assignment_id | str | required | |
assignment_name | str | required | |
rubric_version | str | required | |
rubric_path | str | required | |
source | str | '' | |
execution_mode | str | 'docker' | |
created_at | str | field(default_factory=utc_now_iso) | |
updated_at | str | field(default_factory=utc_now_iso) | |
settings | dict[str, Any] | field(default_factory=dict) | |
results | dict[str, SubmissionResult] | field(default_factory=dict) | |
root | Path | None | None |
Methods
- ordered_results() -> list[SubmissionResult] #[source]
Results sorted by student id.
- upsert(result: SubmissionResult) -> None #[source]
Add or replace one student's result.
- summary() -> dict[str, Any] #[source]
The class summary (mean, median, distribution, common issues, rubric breakdown).
- queue() -> list[dict[str, Any]] #[source]
The review queue: submissions that still need a person, most urgent first.
- set_override(student_id: str, rubric_id: str, manual_score: float | None, reason: str = '', enabled: bool = True) -> bool #[source]
Override one rubric item's score. The automatic score is kept alongside it; pass
enabled=Falseto remove an override. ReturnsFalseif the student or item does not exist.
- mark_reviewed(student_id: str, reviewed: bool = True) -> bool #[source]
Mark a submission as reviewed, which removes it from the queue.
- collect_overrides() -> dict[str, dict[str, dict[str, Any]]] #[source]
Snapshot manual work so a regrade can restore it (design.md §31).
- save(root: str | Path | None = None) -> Path #[source]
Write the session and all its exports to disk; returns the session directory.
- store_executed_notebook(student_id: str, notebook_path: str | Path) -> str | None #[source]
Keep the executed notebook alongside the results (design.md §28).
- classmethod load(root: str | Path) -> 'GradingSession' #[source]
Read a session back from its directory.