The Assignment
Class¶
The Assignment
class represents an assignment specification as a Python object.
It mostly contains metadata about the assignment, and the heavy-lifting of comparing the assignment to an actual directory on the filesystem is delegated to the Directory
class.
The Assignment
class is responsible for assembling the text output that is returned from the validation methods of the Directory
class, however.
- class Assignment(git_branch_to_mark: str | None = None, git_other_branches: List[str] | None = None, id: int | str | None = None, structure: Dict[str, Any] | None = None, title: str | None = None, year: int | str | None = None)¶
- property academic_year: str¶
Academic year that the assignment was/is released in.
- classmethod from_json(file: Path | None = None, json_str: str | None = None) Assignment ¶
Creates an Assignment instance by reading a json file, or a json-encoded string.
Reading from a file trumps reading a string.
- Parameters:
file – Path to a compatible json file.
json_str – String encoding a valid json file, which can be loaded with json.loads.
- Returns:
An Assignment instance with the specification found in the file.
- property git_allowable_branches: List[str]¶
- property git_branch_to_mark: str¶
- id: str¶
- property name: str¶
Assignment {number}, {academic year}: {title}
- parse_into_output(fatal: AssignmentCheckerError | None, warnings: List[str] = [], information: List[str] = []) str ¶
Parses the output from assignment validation into a human-readable string that reports the findings of the validation process.
- title: str¶
- validate_assignment(submission_dir: Path, tmp_dir: Path) str ¶
Validates that the submission directory provided matches the specifications of this instance.
The validation process creates a copy of the submission directory and the directory tree beneath it, so operations like git checkouts can be conducted without altering the user’s working directory.
The temporary directory is always manually cleaned up by the program, though the OS should handle this if an uncaught error is encountered.
- Parameters:
submission_dir – Path to the root submission directory.
- Returns:
FIXME
- year: int¶