Skip to content

Commit

Permalink
Merge pull request #117 from dbosk/fix-grades-summarizers
Browse files Browse the repository at this point in the history
Makes grades module handle Fx
  • Loading branch information
dbosk authored Nov 13, 2023
2 parents 74ac723 + 1f3d355 commit 8cba35d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
19 changes: 13 additions & 6 deletions src/canvaslms/grades/disjunctmax.nw
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def summarize(user, assignments_list):
dates.append(grade_date)

if grades:
final_grade = grade_max(grades)
final_grade = grade_max(grades) or "F"
else:
final_grade = "F"

Expand All @@ -109,16 +109,23 @@ We also include P/F here, since we can count them as lower than A--E.
<<helper functions>>=
def grade_max(grades):
"""Takes a list of A--E/P--F grades, returns the maximum."""
num_grades = map(grade_to_int, grades)
max_grade = max(num_grades)
return int_to_grade(max_grade)
num_grades = list(map(grade_to_int,
filter(lambda x: x[0] != "F", grades)))
if not num_grades:
max_grade = max(num_grades)
return int_to_grade(max_grade)
return None

def grade_to_int(grade):
grade_map = {"F": -1, "P": 0, "E": 1, "D": 2, "C": 3, "B": 4, "A": 5}
grade_map = {"F": -2, "Fx": -1,
"P": 0,
"E": 1, "D": 2, "C": 3, "B": 4, "A": 5}
return grade_map[grade]

def int_to_grade(int_grade):
grade_map_inv = {-1: "F", 0: "P", 1: "E", 2: "D", 3: "C", 4: "B", 5: "A"}
grade_map_inv = {-2: "F", -1: "Fx",
0: "P",
1: "E", 2: "D", 3: "C", 4: "B", 5: "A"}
return grade_map_inv[int_grade]
@

4 changes: 2 additions & 2 deletions src/canvaslms/grades/maxgradesurvey.nw
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def summarize(user, assignments_list):
for assignment in assignments_list:
try:
submission = assignment.get_submission(user,
include=["submission_history"])
include=["submission_history"])
except ResourceDoesNotExist:
grades.append("F")
continue
Expand All @@ -91,7 +91,7 @@ def summarize(user, assignments_list):
if len(dates) < len(grades):
final_grade = "F"
else:
final_grade = grade_max(grades)
final_grade = grade_max(grades) or "F"

if dates:
final_date = max(dates)
Expand Down

0 comments on commit 8cba35d

Please sign in to comment.