ygrader 2.1.0__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ygrader-2.1.0/ygrader.egg-info → ygrader-2.2.0}/PKG-INFO +1 -1
- {ygrader-2.1.0 → ygrader-2.2.0}/setup.py +1 -1
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/deductions.py +21 -21
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/feedback.py +104 -11
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/grader.py +0 -48
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/grading_item.py +12 -49
- {ygrader-2.1.0 → ygrader-2.2.0/ygrader.egg-info}/PKG-INFO +1 -1
- {ygrader-2.1.0 → ygrader-2.2.0}/LICENSE +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/setup.cfg +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/test/test_interactive.py +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/test/test_unittest.py +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/__init__.py +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/grades_csv.py +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/grading_item_config.py +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/score_input.py +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/send_ctrl_backtick.ahk +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/student_repos.py +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/upstream_merger.py +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader/utils.py +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader.egg-info/SOURCES.txt +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader.egg-info/dependency_links.txt +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader.egg-info/requires.txt +0 -0
- {ygrader-2.1.0 → ygrader-2.2.0}/ygrader.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ setup(
|
|
|
4
4
|
name="ygrader",
|
|
5
5
|
packages=["ygrader"],
|
|
6
6
|
package_data={"ygrader": ["*.ahk"]},
|
|
7
|
-
version="2.
|
|
7
|
+
version="2.2.0",
|
|
8
8
|
description="Grading scripts used in BYU's Electrical and Computer Engineering Department",
|
|
9
9
|
author="Jeff Goeders",
|
|
10
10
|
author_email="jeff.goeders@gmail.com",
|
|
@@ -44,7 +44,7 @@ class StudentDeductions:
|
|
|
44
44
|
|
|
45
45
|
def __init__(self, yaml_path: Optional[pathlib.Path] = None):
|
|
46
46
|
self.deductions_by_students = {}
|
|
47
|
-
self.
|
|
47
|
+
self.submit_time_by_students = {} # ISO format timestamp strings
|
|
48
48
|
self.deduction_types = {}
|
|
49
49
|
self.yaml_path = yaml_path
|
|
50
50
|
|
|
@@ -102,9 +102,9 @@ class StudentDeductions:
|
|
|
102
102
|
|
|
103
103
|
self.deductions_by_students[student_key] = deduction_items
|
|
104
104
|
|
|
105
|
-
# Load
|
|
106
|
-
if "
|
|
107
|
-
self.
|
|
105
|
+
# Load submit_time if present
|
|
106
|
+
if "submit_time" in entry:
|
|
107
|
+
self.submit_time_by_students[student_key] = entry["submit_time"]
|
|
108
108
|
|
|
109
109
|
def _write_yaml(self):
|
|
110
110
|
"""Write deduction types and student deductions to the YAML file.
|
|
@@ -134,9 +134,9 @@ class StudentDeductions:
|
|
|
134
134
|
)
|
|
135
135
|
data["deduction_types"] = deduction_list
|
|
136
136
|
|
|
137
|
-
# Write student deductions (include students with deductions OR
|
|
137
|
+
# Write student deductions (include students with deductions OR submit_time)
|
|
138
138
|
all_student_keys = set(self.deductions_by_students.keys()) | set(
|
|
139
|
-
self.
|
|
139
|
+
self.submit_time_by_students.keys()
|
|
140
140
|
)
|
|
141
141
|
# Sort student keys for consistent output ordering
|
|
142
142
|
sorted_student_keys = sorted(all_student_keys)
|
|
@@ -158,8 +158,8 @@ class StudentDeductions:
|
|
|
158
158
|
"net_ids": FlowList(student_key),
|
|
159
159
|
"deductions": FlowList(deduction_ids),
|
|
160
160
|
**(
|
|
161
|
-
{"
|
|
162
|
-
if student_key in self.
|
|
161
|
+
{"submit_time": self.submit_time_by_students[student_key]}
|
|
162
|
+
if student_key in self.submit_time_by_students
|
|
163
163
|
else {}
|
|
164
164
|
),
|
|
165
165
|
}
|
|
@@ -375,8 +375,8 @@ class StudentDeductions:
|
|
|
375
375
|
student_key = tuple(net_ids) if not isinstance(net_ids, tuple) else net_ids
|
|
376
376
|
if student_key in self.deductions_by_students:
|
|
377
377
|
del self.deductions_by_students[student_key]
|
|
378
|
-
if student_key in self.
|
|
379
|
-
del self.
|
|
378
|
+
if student_key in self.submit_time_by_students:
|
|
379
|
+
del self.submit_time_by_students[student_key]
|
|
380
380
|
self._save()
|
|
381
381
|
|
|
382
382
|
def ensure_student_in_file(self, net_ids: tuple):
|
|
@@ -405,31 +405,31 @@ class StudentDeductions:
|
|
|
405
405
|
student_key = tuple(net_ids) if not isinstance(net_ids, tuple) else net_ids
|
|
406
406
|
return student_key in self.deductions_by_students
|
|
407
407
|
|
|
408
|
-
def
|
|
409
|
-
"""Set the
|
|
408
|
+
def set_submit_time(self, net_ids: tuple, submit_time: Optional[str]):
|
|
409
|
+
"""Set the submission time for a student.
|
|
410
410
|
|
|
411
411
|
Args:
|
|
412
412
|
net_ids: Tuple of net_ids for the student.
|
|
413
|
-
|
|
413
|
+
submit_time: ISO format timestamp string, or None to remove.
|
|
414
414
|
"""
|
|
415
415
|
student_key = tuple(net_ids) if not isinstance(net_ids, tuple) else net_ids
|
|
416
|
-
if
|
|
417
|
-
self.
|
|
418
|
-
elif student_key in self.
|
|
419
|
-
del self.
|
|
416
|
+
if submit_time:
|
|
417
|
+
self.submit_time_by_students[student_key] = submit_time
|
|
418
|
+
elif student_key in self.submit_time_by_students:
|
|
419
|
+
del self.submit_time_by_students[student_key]
|
|
420
420
|
self._save()
|
|
421
421
|
|
|
422
|
-
def
|
|
423
|
-
"""Get the
|
|
422
|
+
def get_submit_time(self, net_ids: tuple) -> Optional[str]:
|
|
423
|
+
"""Get the submission time for a student.
|
|
424
424
|
|
|
425
425
|
Args:
|
|
426
426
|
net_ids: Tuple of net_ids for the student.
|
|
427
427
|
|
|
428
428
|
Returns:
|
|
429
|
-
|
|
429
|
+
ISO format timestamp string, or None if not set.
|
|
430
430
|
"""
|
|
431
431
|
student_key = tuple(net_ids) if not isinstance(net_ids, tuple) else net_ids
|
|
432
|
-
return self.
|
|
432
|
+
return self.submit_time_by_students.get(student_key)
|
|
433
433
|
|
|
434
434
|
def total_deductions(self, net_ids: Optional[tuple] = None) -> float:
|
|
435
435
|
"""Calculate the total deductions for a student or all students.
|
|
@@ -1,29 +1,65 @@
|
|
|
1
1
|
"""Module for generating student feedback files and grades CSV."""
|
|
2
2
|
|
|
3
|
+
import datetime
|
|
3
4
|
import pathlib
|
|
4
5
|
import zipfile
|
|
5
6
|
from typing import Callable, Dict, Optional, Tuple
|
|
6
7
|
|
|
8
|
+
import numpy as np
|
|
7
9
|
import pandas
|
|
8
10
|
|
|
9
11
|
from .deductions import StudentDeductions
|
|
10
12
|
from .grading_item_config import LearningSuiteColumn
|
|
11
|
-
from .utils import warning
|
|
13
|
+
from .utils import warning, print_color, TermColors
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
# Type alias for late penalty callback: (late_days, max_score, actual_score) -> new_score
|
|
15
17
|
LatePenaltyCallback = Callable[[int, float, float], float]
|
|
16
18
|
|
|
17
19
|
|
|
20
|
+
def _calculate_late_days(
|
|
21
|
+
submit_time_str: Optional[str],
|
|
22
|
+
due_date: datetime.datetime,
|
|
23
|
+
) -> int:
|
|
24
|
+
"""Calculate the number of business days late from a submit time.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
submit_time_str: ISO format timestamp string of submission.
|
|
28
|
+
due_date: The effective due date for the student.
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
Number of business days late (0 if on time or no submit time).
|
|
32
|
+
"""
|
|
33
|
+
if not submit_time_str:
|
|
34
|
+
return 0
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
submit_time = datetime.datetime.fromisoformat(submit_time_str)
|
|
38
|
+
except ValueError:
|
|
39
|
+
return 0
|
|
40
|
+
|
|
41
|
+
if submit_time <= due_date:
|
|
42
|
+
return 0
|
|
43
|
+
|
|
44
|
+
days_late = np.busday_count(due_date.date(), submit_time.date())
|
|
45
|
+
if days_late == 0:
|
|
46
|
+
days_late = 1 # Same day but after deadline
|
|
47
|
+
return int(days_late)
|
|
48
|
+
|
|
49
|
+
|
|
18
50
|
def _get_student_key_and_max_late_days(
|
|
19
51
|
net_id: str,
|
|
20
52
|
item_deductions: Dict[str, StudentDeductions],
|
|
53
|
+
due_date: Optional[datetime.datetime] = None,
|
|
54
|
+
due_date_exceptions: Optional[Dict[str, datetime.datetime]] = None,
|
|
21
55
|
) -> tuple:
|
|
22
56
|
"""Find the student key and maximum late days across all items.
|
|
23
57
|
|
|
24
58
|
Args:
|
|
25
59
|
net_id: The student's net ID.
|
|
26
60
|
item_deductions: Mapping from item name to StudentDeductions.
|
|
61
|
+
due_date: The default due date for the assignment.
|
|
62
|
+
due_date_exceptions: Mapping from net_id to exception due date.
|
|
27
63
|
|
|
28
64
|
Returns:
|
|
29
65
|
Tuple of (student_key or None, max_late_days).
|
|
@@ -31,6 +67,9 @@ def _get_student_key_and_max_late_days(
|
|
|
31
67
|
max_late_days = 0
|
|
32
68
|
found_student_key = None
|
|
33
69
|
|
|
70
|
+
if due_date_exceptions is None:
|
|
71
|
+
due_date_exceptions = {}
|
|
72
|
+
|
|
34
73
|
for deductions_obj in item_deductions.values():
|
|
35
74
|
if not deductions_obj:
|
|
36
75
|
continue
|
|
@@ -39,12 +78,12 @@ def _get_student_key_and_max_late_days(
|
|
|
39
78
|
student_key = None
|
|
40
79
|
if (net_id,) in deductions_obj.deductions_by_students:
|
|
41
80
|
student_key = (net_id,)
|
|
42
|
-
elif (net_id,) in deductions_obj.
|
|
81
|
+
elif (net_id,) in deductions_obj.submit_time_by_students:
|
|
43
82
|
student_key = (net_id,)
|
|
44
83
|
else:
|
|
45
84
|
# Check for multi-student keys containing this net_id
|
|
46
85
|
for key in set(deductions_obj.deductions_by_students.keys()) | set(
|
|
47
|
-
deductions_obj.
|
|
86
|
+
deductions_obj.submit_time_by_students.keys()
|
|
48
87
|
):
|
|
49
88
|
if net_id in key:
|
|
50
89
|
student_key = key
|
|
@@ -52,8 +91,25 @@ def _get_student_key_and_max_late_days(
|
|
|
52
91
|
|
|
53
92
|
if student_key:
|
|
54
93
|
found_student_key = student_key
|
|
55
|
-
|
|
56
|
-
|
|
94
|
+
|
|
95
|
+
# Calculate late days from submit_time if we have a due date
|
|
96
|
+
if due_date is not None:
|
|
97
|
+
submit_time_str = deductions_obj.submit_time_by_students.get(
|
|
98
|
+
student_key
|
|
99
|
+
)
|
|
100
|
+
if submit_time_str:
|
|
101
|
+
# Calculate effective due date (using most generous exception for group)
|
|
102
|
+
effective_due_date = due_date
|
|
103
|
+
for member_net_id in student_key:
|
|
104
|
+
if member_net_id in due_date_exceptions:
|
|
105
|
+
effective_due_date = max(
|
|
106
|
+
effective_due_date, due_date_exceptions[member_net_id]
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
days_late = _calculate_late_days(
|
|
110
|
+
submit_time_str, effective_due_date
|
|
111
|
+
)
|
|
112
|
+
max_late_days = max(max_late_days, days_late)
|
|
57
113
|
|
|
58
114
|
return found_student_key, max_late_days
|
|
59
115
|
|
|
@@ -62,8 +118,11 @@ def _calculate_student_score(
|
|
|
62
118
|
net_id: str,
|
|
63
119
|
ls_column: LearningSuiteColumn,
|
|
64
120
|
item_deductions: Dict[str, StudentDeductions],
|
|
121
|
+
*,
|
|
65
122
|
late_penalty_callback: Optional[LatePenaltyCallback] = None,
|
|
66
123
|
warn_on_missing_callback: bool = True,
|
|
124
|
+
due_date: Optional[datetime.datetime] = None,
|
|
125
|
+
due_date_exceptions: Optional[Dict[str, datetime.datetime]] = None,
|
|
67
126
|
) -> Tuple[float, float, int]:
|
|
68
127
|
"""Calculate a student's final score.
|
|
69
128
|
|
|
@@ -73,6 +132,8 @@ def _calculate_student_score(
|
|
|
73
132
|
item_deductions: Mapping from item name to StudentDeductions.
|
|
74
133
|
late_penalty_callback: Optional callback for late penalty.
|
|
75
134
|
warn_on_missing_callback: Whether to warn if late days found but no callback.
|
|
135
|
+
due_date: The default due date for the assignment.
|
|
136
|
+
due_date_exceptions: Mapping from net_id to exception due date.
|
|
76
137
|
|
|
77
138
|
Returns:
|
|
78
139
|
Tuple of (final_score, total_possible, max_late_days).
|
|
@@ -102,7 +163,9 @@ def _calculate_student_score(
|
|
|
102
163
|
score = max(0, total_possible - total_deductions)
|
|
103
164
|
|
|
104
165
|
# Get max late days
|
|
105
|
-
_, max_late_days = _get_student_key_and_max_late_days(
|
|
166
|
+
_, max_late_days = _get_student_key_and_max_late_days(
|
|
167
|
+
net_id, item_deductions, due_date, due_date_exceptions
|
|
168
|
+
)
|
|
106
169
|
|
|
107
170
|
# Apply late penalty if applicable
|
|
108
171
|
if max_late_days > 0:
|
|
@@ -124,6 +187,8 @@ def assemble_grades(
|
|
|
124
187
|
output_zip_path: Optional[pathlib.Path] = None,
|
|
125
188
|
output_csv_path: Optional[pathlib.Path] = None,
|
|
126
189
|
late_penalty_callback: Optional[LatePenaltyCallback] = None,
|
|
190
|
+
due_date: Optional[datetime.datetime] = None,
|
|
191
|
+
due_date_exceptions: Optional[Dict[str, datetime.datetime]] = None,
|
|
127
192
|
) -> Tuple[Optional[pathlib.Path], Optional[pathlib.Path]]:
|
|
128
193
|
"""Generate feedback zip and/or grades CSV from deductions.
|
|
129
194
|
|
|
@@ -135,6 +200,8 @@ def assemble_grades(
|
|
|
135
200
|
output_csv_path: Path for the output CSV file. If None, no CSV is generated.
|
|
136
201
|
late_penalty_callback: Optional callback function that takes
|
|
137
202
|
(late_days, max_score, actual_score) and returns the adjusted score.
|
|
203
|
+
due_date: The default due date for the assignment. Required for late penalty.
|
|
204
|
+
due_date_exceptions: Mapping from net_id to exception due date.
|
|
138
205
|
|
|
139
206
|
Returns:
|
|
140
207
|
Tuple of (feedback_zip_path or None, grades_csv_path or None).
|
|
@@ -170,15 +237,32 @@ def assemble_grades(
|
|
|
170
237
|
last_name = str(student_row["Last Name"]).strip()
|
|
171
238
|
net_id = str(student_row["Net ID"]).strip()
|
|
172
239
|
|
|
173
|
-
# Calculate
|
|
174
|
-
|
|
240
|
+
# Calculate score before late penalty
|
|
241
|
+
score_before_late, total_possible, max_late_days = _calculate_student_score(
|
|
175
242
|
net_id=net_id,
|
|
176
243
|
ls_column=ls_column,
|
|
177
244
|
item_deductions=subitem_deductions,
|
|
178
|
-
late_penalty_callback=
|
|
179
|
-
warn_on_missing_callback=
|
|
245
|
+
late_penalty_callback=None, # Don't apply late penalty yet
|
|
246
|
+
warn_on_missing_callback=False,
|
|
247
|
+
due_date=due_date,
|
|
248
|
+
due_date_exceptions=due_date_exceptions,
|
|
180
249
|
)
|
|
181
250
|
|
|
251
|
+
# Apply late penalty if applicable
|
|
252
|
+
final_score = score_before_late
|
|
253
|
+
if max_late_days > 0 and late_penalty_callback:
|
|
254
|
+
final_score = max(
|
|
255
|
+
0,
|
|
256
|
+
late_penalty_callback(
|
|
257
|
+
max_late_days, total_possible, score_before_late
|
|
258
|
+
),
|
|
259
|
+
)
|
|
260
|
+
print_color(
|
|
261
|
+
TermColors.YELLOW,
|
|
262
|
+
f"Late: {net_id} ({max_late_days} day{'s' if max_late_days != 1 else ''}): "
|
|
263
|
+
f"{score_before_late:.1f} -> {final_score:.1f}",
|
|
264
|
+
)
|
|
265
|
+
|
|
182
266
|
# Add to grades data
|
|
183
267
|
if output_csv_path:
|
|
184
268
|
grades_data.append(
|
|
@@ -192,6 +276,8 @@ def assemble_grades(
|
|
|
192
276
|
ls_column=ls_column,
|
|
193
277
|
subitem_deductions=subitem_deductions,
|
|
194
278
|
late_penalty_callback=late_penalty_callback,
|
|
279
|
+
due_date=due_date,
|
|
280
|
+
due_date_exceptions=due_date_exceptions,
|
|
195
281
|
)
|
|
196
282
|
|
|
197
283
|
filename = (
|
|
@@ -226,7 +312,10 @@ def _generate_student_feedback(
|
|
|
226
312
|
student_row: pandas.Series,
|
|
227
313
|
ls_column: LearningSuiteColumn,
|
|
228
314
|
subitem_deductions: Dict[str, StudentDeductions],
|
|
315
|
+
*,
|
|
229
316
|
late_penalty_callback: Optional[LatePenaltyCallback] = None,
|
|
317
|
+
due_date: Optional[datetime.datetime] = None,
|
|
318
|
+
due_date_exceptions: Optional[Dict[str, datetime.datetime]] = None,
|
|
230
319
|
) -> str:
|
|
231
320
|
"""Generate the feedback text content for a single student.
|
|
232
321
|
|
|
@@ -235,6 +324,8 @@ def _generate_student_feedback(
|
|
|
235
324
|
ls_column: The LearningSuiteColumn object.
|
|
236
325
|
subitem_deductions: Mapping from subitem name to StudentDeductions.
|
|
237
326
|
late_penalty_callback: Optional callback for calculating late penalty.
|
|
327
|
+
due_date: The default due date for the assignment.
|
|
328
|
+
due_date_exceptions: Mapping from net_id to exception due date.
|
|
238
329
|
|
|
239
330
|
Returns:
|
|
240
331
|
The formatted feedback text.
|
|
@@ -317,7 +408,9 @@ def _generate_student_feedback(
|
|
|
317
408
|
score_before_late = max(0, total_points_possible - total_points_deducted)
|
|
318
409
|
|
|
319
410
|
# Get max late days for this student
|
|
320
|
-
_, max_late_days = _get_student_key_and_max_late_days(
|
|
411
|
+
_, max_late_days = _get_student_key_and_max_late_days(
|
|
412
|
+
net_id, subitem_deductions, due_date, due_date_exceptions
|
|
413
|
+
)
|
|
321
414
|
|
|
322
415
|
# Late penalty section
|
|
323
416
|
lines.append("")
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"""Main ygrader module"""
|
|
2
2
|
|
|
3
|
-
import datetime as dt
|
|
4
3
|
import enum
|
|
5
4
|
import inspect
|
|
6
5
|
import os
|
|
@@ -13,7 +12,6 @@ from collections import defaultdict
|
|
|
13
12
|
from typing import Callable
|
|
14
13
|
|
|
15
14
|
import pandas
|
|
16
|
-
import yaml
|
|
17
15
|
|
|
18
16
|
from . import grades_csv, student_repos, utils
|
|
19
17
|
from .grading_item import GradeItem
|
|
@@ -101,7 +99,6 @@ class Grader:
|
|
|
101
99
|
self.github_https = None
|
|
102
100
|
self.groups_csv_path = None
|
|
103
101
|
self.groups_csv_col_name = None
|
|
104
|
-
self.due_date_exceptions = {}
|
|
105
102
|
self.set_other_options()
|
|
106
103
|
|
|
107
104
|
def add_item_to_grade(
|
|
@@ -335,8 +332,6 @@ class Grader:
|
|
|
335
332
|
dry_run_first=False,
|
|
336
333
|
dry_run_all=False,
|
|
337
334
|
workflow_hash=None,
|
|
338
|
-
due_date=None,
|
|
339
|
-
due_date_exceptions_path=None,
|
|
340
335
|
):
|
|
341
336
|
"""
|
|
342
337
|
This can be used to set other options for the grader.
|
|
@@ -376,15 +371,6 @@ class Grader:
|
|
|
376
371
|
(Optional) Expected hash of the GitHub workflow file. If provided, the workflow file will be verified
|
|
377
372
|
before grading each student. If the hash doesn't match, a warning will be displayed indicating
|
|
378
373
|
the student may have modified the workflow system.
|
|
379
|
-
due_date: datetime.datetime
|
|
380
|
-
(Optional) Due date for the assignment. If provided, the submission date will be compared to this
|
|
381
|
-
and late days will be calculated and displayed.
|
|
382
|
-
due_date_exceptions_path: str
|
|
383
|
-
(Optional) Path to a YAML file containing per-student due date exceptions. The file should be
|
|
384
|
-
a simple dictionary mapping net_ids to deadline strings in "YYYY-MM-DD HH:MM:SS" format.
|
|
385
|
-
Example:
|
|
386
|
-
"student1": "2025-01-15 23:59:59"
|
|
387
|
-
"student2": "2025-01-17 23:59:59"
|
|
388
374
|
"""
|
|
389
375
|
self.format_code = format_code
|
|
390
376
|
self.build_only = build_only
|
|
@@ -392,9 +378,6 @@ class Grader:
|
|
|
392
378
|
self.allow_rebuild = allow_rebuild
|
|
393
379
|
self.allow_rerun = allow_rerun
|
|
394
380
|
self.workflow_hash = workflow_hash
|
|
395
|
-
self.due_date = due_date
|
|
396
|
-
self.due_date_exceptions = {}
|
|
397
|
-
self.due_date_exceptions_path = due_date_exceptions_path
|
|
398
381
|
if prep_fcn and not isinstance(prep_fcn, Callable):
|
|
399
382
|
error("The 'prep_fcn' argument must provide a callable function pointer")
|
|
400
383
|
self.prep_fcn = prep_fcn
|
|
@@ -424,36 +407,6 @@ class Grader:
|
|
|
424
407
|
+ "set_submission_system_learning_suite() or set_submission_system_github()."
|
|
425
408
|
)
|
|
426
409
|
|
|
427
|
-
def _load_due_date_exceptions(self):
|
|
428
|
-
"""Load due date exceptions from YAML file (simple net_id: deadline format)"""
|
|
429
|
-
|
|
430
|
-
self.due_date_exceptions = {}
|
|
431
|
-
if not self.due_date_exceptions_path:
|
|
432
|
-
return
|
|
433
|
-
|
|
434
|
-
try:
|
|
435
|
-
with open(self.due_date_exceptions_path, "r", encoding="utf-8") as f:
|
|
436
|
-
exceptions_raw = yaml.safe_load(f)
|
|
437
|
-
except (IOError, yaml.YAMLError) as e:
|
|
438
|
-
print_color(
|
|
439
|
-
TermColors.YELLOW, f"Warning: Could not load exceptions file: {e}"
|
|
440
|
-
)
|
|
441
|
-
return
|
|
442
|
-
|
|
443
|
-
if not exceptions_raw or not isinstance(exceptions_raw, dict):
|
|
444
|
-
return
|
|
445
|
-
|
|
446
|
-
for net_id, deadline_str in exceptions_raw.items():
|
|
447
|
-
try:
|
|
448
|
-
self.due_date_exceptions[net_id] = dt.datetime.strptime(
|
|
449
|
-
deadline_str, "%Y-%m-%d %H:%M:%S"
|
|
450
|
-
)
|
|
451
|
-
except ValueError as e:
|
|
452
|
-
print_color(
|
|
453
|
-
TermColors.YELLOW,
|
|
454
|
-
f"Warning: Could not parse deadline for {net_id}: {e}",
|
|
455
|
-
)
|
|
456
|
-
|
|
457
410
|
def _get_all_csv_cols_to_grade(self):
|
|
458
411
|
"""Collect all columns that will be graded into a single list.
|
|
459
412
|
|
|
@@ -465,7 +418,6 @@ class Grader:
|
|
|
465
418
|
"""Call this to start (or resume) the grading process"""
|
|
466
419
|
|
|
467
420
|
self._validate_config()
|
|
468
|
-
self._load_due_date_exceptions()
|
|
469
421
|
|
|
470
422
|
# Print starting message
|
|
471
423
|
print_color(TermColors.BLUE, "Running grader for", self.lab_name)
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
import datetime
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
|
-
import numpy as np
|
|
7
|
-
|
|
8
6
|
from .utils import (
|
|
9
7
|
CallbackFailed,
|
|
10
8
|
TermColors,
|
|
@@ -149,10 +147,10 @@ class GradeItem:
|
|
|
149
147
|
print_color(TermColors.RED, "=" * 70)
|
|
150
148
|
print("")
|
|
151
149
|
|
|
152
|
-
# Display submission date if available
|
|
150
|
+
# Display submission date if available and store for later late calculation
|
|
153
151
|
student_code_path = callback_args.get("student_code_path")
|
|
154
|
-
#
|
|
155
|
-
|
|
152
|
+
# Store submission time but don't save yet - will be saved only after successful grading
|
|
153
|
+
pending_submit_time = None
|
|
156
154
|
if student_code_path:
|
|
157
155
|
submission_date_path = student_code_path / ".commitdate"
|
|
158
156
|
if submission_date_path.is_file():
|
|
@@ -166,43 +164,8 @@ class GradeItem:
|
|
|
166
164
|
TermColors.BLUE,
|
|
167
165
|
f"Submitted: {submission_time.strftime('%Y-%m-%d %H:%M:%S')}",
|
|
168
166
|
)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if self.grader.due_date is not None:
|
|
172
|
-
# Check for student-specific due date exception
|
|
173
|
-
# Use the latest (most generous) exception if multiple group members have them
|
|
174
|
-
effective_due_date = self.grader.due_date
|
|
175
|
-
for net_id in net_ids:
|
|
176
|
-
if net_id in self.grader.due_date_exceptions:
|
|
177
|
-
exception_date = self.grader.due_date_exceptions[
|
|
178
|
-
net_id
|
|
179
|
-
]
|
|
180
|
-
effective_due_date = max(
|
|
181
|
-
effective_due_date, exception_date
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
has_exception = effective_due_date != self.grader.due_date
|
|
185
|
-
if has_exception:
|
|
186
|
-
print_color(
|
|
187
|
-
TermColors.YELLOW,
|
|
188
|
-
f"Exception due date: {effective_due_date.strftime('%Y-%m-%d %H:%M:%S')}",
|
|
189
|
-
)
|
|
190
|
-
|
|
191
|
-
if submission_time <= effective_due_date:
|
|
192
|
-
print_color(TermColors.GREEN, "Status: ON TIME")
|
|
193
|
-
pending_days_late = 0
|
|
194
|
-
else:
|
|
195
|
-
days_late = np.busday_count(
|
|
196
|
-
effective_due_date.date(),
|
|
197
|
-
submission_time.date(),
|
|
198
|
-
)
|
|
199
|
-
if days_late == 0:
|
|
200
|
-
days_late = 1 # Same day but after deadline
|
|
201
|
-
print_color(
|
|
202
|
-
TermColors.RED,
|
|
203
|
-
f"Status: LATE ({days_late} business day(s))",
|
|
204
|
-
)
|
|
205
|
-
pending_days_late = int(days_late)
|
|
167
|
+
# Store as ISO format for later late calculation
|
|
168
|
+
pending_submit_time = submission_time.isoformat()
|
|
206
169
|
except (ValueError, IOError) as e:
|
|
207
170
|
print_color(
|
|
208
171
|
TermColors.YELLOW,
|
|
@@ -230,10 +193,10 @@ class GradeItem:
|
|
|
230
193
|
TermColors.BLUE,
|
|
231
194
|
f"Applied deduction: {deduction_desc} (-{deduction_points})",
|
|
232
195
|
)
|
|
233
|
-
# Save
|
|
234
|
-
if
|
|
235
|
-
self.student_deductions.
|
|
236
|
-
tuple(net_ids),
|
|
196
|
+
# Save submit_time now that grading succeeded
|
|
197
|
+
if pending_submit_time is not None:
|
|
198
|
+
self.student_deductions.set_submit_time(
|
|
199
|
+
tuple(net_ids), pending_submit_time
|
|
237
200
|
)
|
|
238
201
|
# Ensure student is in the deductions file
|
|
239
202
|
self.student_deductions.ensure_student_in_file(tuple(net_ids))
|
|
@@ -270,10 +233,10 @@ class GradeItem:
|
|
|
270
233
|
build = False
|
|
271
234
|
continue
|
|
272
235
|
|
|
273
|
-
# Record score - save
|
|
236
|
+
# Record score - save submit_time and ensure the student is in the deductions file
|
|
274
237
|
# (even if they have no deductions, to indicate they were graded)
|
|
275
|
-
if
|
|
276
|
-
self.student_deductions.
|
|
238
|
+
if pending_submit_time is not None:
|
|
239
|
+
self.student_deductions.set_submit_time(tuple(net_ids), pending_submit_time)
|
|
277
240
|
self.student_deductions.ensure_student_in_file(tuple(net_ids))
|
|
278
241
|
break
|
|
279
242
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|