-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgrader.py.in
58 lines (45 loc) · 1.69 KB
/
grader.py.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""ASSIGNMENT/grader.py: Grading logic for ASSIGNMENT assignment"""
from typing import Optional
import os
import shutil
import sys
import git
from common.hw_base import HW, directory
import common.utils as u
import common.printing as pr
import common.submissions as subs
ALIASES = { "ASSIGNMENT" }
class GRADER(HW):
"""Grading rubic and tests for ASSIGNMENT assignment
Attributes:
scripts_dir: The directory containing the grading scripts
submission_dir: The submission directory
submitter: The name of the student/team
rubric: Python representation of the rubric
exit_handler: SIGINT handler
"""
def __init__(self, submitter: Optional[str]):
# Set up the minimum to at least dump grades for all students
super().__init__("ASSIGNMENT", "rubric.json")
self.submitter = submitter
if submitter:
try:
u.is_dir(self.hw_workspace)
except ValueError:
sys.exit("Please run hw_setup before grading")
os.chdir(self.hw_workspace)
if not self.setup():
sys.exit(f"Couldn't setup {submitter}'s submission!")
def exit_handler(self, _signal, _frame):
"""Handler for SIGINT"""
pr.print_cyan("\n[ Exiting ASSIGNMENT grader... ]")
self.cleanup()
sys.exit()
def setup(self) -> bool:
"""Do any necessary setup for the submission"""
# TODO set self.submission_dir to submission repo directory, e.g.:
# self.submission_dir = os.path.join(self.hw_workspace, "ASSIGNMENT")
os.chdir(self.submission_dir)
return True
def cleanup(self):
"""Post ASSIGNMENT cleanup"""