From 72f97c29e963cf07c890523f4feca92d2a8e7fae Mon Sep 17 00:00:00 2001 From: Deimer Morales <105317492+DeimerM@users.noreply.github.com> Date: Mon, 22 May 2023 20:58:19 -0500 Subject: [PATCH] fix: adding TypeError to compare scores function --- lms/djangoapps/grades/signals/handlers.py | 2 +- openedx/core/lib/grade_utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/grades/signals/handlers.py b/lms/djangoapps/grades/signals/handlers.py index 14089d74ea5..a3f605bbd16 100644 --- a/lms/djangoapps/grades/signals/handlers.py +++ b/lms/djangoapps/grades/signals/handlers.py @@ -152,7 +152,7 @@ def score_published_handler(sender, block, user, raw_earned, raw_possible, only_ if previous_score is not None: prev_raw_earned, prev_raw_possible = (previous_score.grade, previous_score.max_grade) - if not is_score_higher_or_equal(prev_raw_earned, prev_raw_possible, raw_earned, raw_possible): + if not is_score_higher_or_equal(prev_raw_earned, prev_raw_possible, raw_earned, raw_possible, True): update_score = False log.warning( "Grades: Rescore is not higher than previous: " diff --git a/openedx/core/lib/grade_utils.py b/openedx/core/lib/grade_utils.py index 2e7073e962d..48c262e85a5 100644 --- a/openedx/core/lib/grade_utils.py +++ b/openedx/core/lib/grade_utils.py @@ -17,14 +17,14 @@ def compare_scores(earned1, possible1, earned2, possible2, treat_undefined_as_ze """ try: percentage1 = float(earned1) / float(possible1) - except ZeroDivisionError: + except (ZeroDivisionError, TypeError): if not treat_undefined_as_zero: raise percentage1 = 0.0 try: percentage2 = float(earned2) / float(possible2) - except ZeroDivisionError: + except (ZeroDivisionError, TypeError): if not treat_undefined_as_zero: raise percentage2 = 0.0