diff --git a/src/canvaslms/grades/disjunctmax.nw b/src/canvaslms/grades/disjunctmax.nw index 8e10929..4fb6e95 100644 --- a/src/canvaslms/grades/disjunctmax.nw +++ b/src/canvaslms/grades/disjunctmax.nw @@ -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" @@ -109,16 +109,23 @@ We also include P/F here, since we can count them as lower than A--E. <>= 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] @ diff --git a/src/canvaslms/grades/maxgradesurvey.nw b/src/canvaslms/grades/maxgradesurvey.nw index 029a105..692c440 100644 --- a/src/canvaslms/grades/maxgradesurvey.nw +++ b/src/canvaslms/grades/maxgradesurvey.nw @@ -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 @@ -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)