From 2a6e95abeeaca87ed372cc5f60d17aacaad76e34 Mon Sep 17 00:00:00 2001 From: nsprenkle Date: Thu, 7 May 2026 16:25:37 -0400 Subject: [PATCH 1/2] fix: cast grading policy corretly as numbers --- lms/djangoapps/course_home_api/progress/api.py | 6 +++--- .../course_home_api/progress/tests/test_api.py | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/course_home_api/progress/api.py b/lms/djangoapps/course_home_api/progress/api.py index f89ecd3d2596..e53f8e54e0d4 100644 --- a/lms/djangoapps/course_home_api/progress/api.py +++ b/lms/djangoapps/course_home_api/progress/api.py @@ -129,10 +129,10 @@ def _build_policy_map(self) -> dict: policy_map = {} for policy in self.grading_policy.get('GRADER', []): policy_map[policy.get('type')] = { - 'weight': policy.get('weight', 0.0), + 'weight': float(policy.get('weight', 0.0) or 0.0), 'short_label': policy.get('short_label', ''), - 'num_droppable': policy.get('drop_count', 0), - 'num_total': policy.get('min_count', 0), + 'num_droppable': int(policy.get('drop_count', 0) or 0), + 'num_total': int(policy.get('min_count', 0) or 0), } return policy_map diff --git a/lms/djangoapps/course_home_api/progress/tests/test_api.py b/lms/djangoapps/course_home_api/progress/tests/test_api.py index 51e7dd68286e..ee536979faa1 100644 --- a/lms/djangoapps/course_home_api/progress/tests/test_api.py +++ b/lms/djangoapps/course_home_api/progress/tests/test_api.py @@ -79,6 +79,15 @@ def _make_subsection(fmt, earned, possible, show_corr, *, due_delta_days=None): ], {'avg': 1.0, 'weighted': 1.0, 'hidden': 'none', 'final': 1.0}, ), + ( + 'string_typed_policy_counts', + {'type': 'Homework', 'weight': '1.0', 'drop_count': '1', 'min_count': '2', 'short_label': 'HW'}, + [ + _make_subsection('Homework', 1, 1, ShowCorrectness.ALWAYS), + _make_subsection('Homework', 0, 1, ShowCorrectness.ALWAYS), + ], + {'avg': 1.0, 'weighted': 1.0, 'hidden': 'none', 'final': 1.0}, + ), ] From c0c4a7e5293f713306f8cb2f2d7e3f03713d6514 Mon Sep 17 00:00:00 2001 From: nsprenkle Date: Thu, 7 May 2026 16:34:02 -0400 Subject: [PATCH 2/2] fix: correct issue in tests --- lms/djangoapps/course_home_api/progress/tests/test_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/course_home_api/progress/tests/test_api.py b/lms/djangoapps/course_home_api/progress/tests/test_api.py index ee536979faa1..935cf803c8f4 100644 --- a/lms/djangoapps/course_home_api/progress/tests/test_api.py +++ b/lms/djangoapps/course_home_api/progress/tests/test_api.py @@ -188,4 +188,4 @@ def test_aggregate_assignment_type_grade_summary_scenarios(self): assert row['average_grade'] == expected['avg'] assert row['weighted_grade'] == expected['weighted'] assert row['has_hidden_contribution'] == expected['hidden'] - assert row['num_droppable'] == policy['drop_count'] + assert row['num_droppable'] == int(policy['drop_count'])