Skip to content

Commit

Permalink
Merge pull request #747 from eduNEXT/dmh/fixing-compare-utils
Browse files Browse the repository at this point in the history
fix: adding TypeError to compare scores function
  • Loading branch information
DeimerM authored May 23, 2023
2 parents 1e1f512 + 72f97c2 commit fa6b598
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lms/djangoapps/grades/signals/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand Down
4 changes: 2 additions & 2 deletions openedx/core/lib/grade_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fa6b598

Please sign in to comment.