Skip to content

Commit

Permalink
Merge pull request #152 from dbosk/bugfix-grade-max
Browse files Browse the repository at this point in the history
Bugfix: `disjunctmax.grade_max` had `not` in the wrong place
  • Loading branch information
dbosk authored Mar 26, 2024
2 parents ed5e811 + 1aa35f4 commit 935125f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/canvaslms/grades/disjunctmax.nw
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,17 @@ def summarize(user, assignments_list):
\subsection{Computing the maximum}

To compute the maximum for the A--E grades; we will convert the grades into
integers, compute the maximum, round the value to an integer and convert back.
integers, compute the maximum, and convert back.
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 = list(map(grade_to_int,
filter(lambda x: x[0] != "F", grades)))
if not num_grades:
num_grades = list(map(grade_to_int, grades))

if num_grades:
max_grade = max(num_grades)
return int_to_grade(max_grade)

return None

def grade_to_int(grade):
Expand All @@ -127,5 +128,4 @@ def int_to_grade(int_grade):
0: "P",
1: "E", 2: "D", 3: "C", 4: "B", 5: "A"}
return grade_map_inv[int_grade]
@

0 comments on commit 935125f

Please sign in to comment.