fix: cast grading policy corretly as numbers - #273
Merged
Conversation
nsprenkle
requested review from
alenkadev,
jansenk,
jristau1984,
michaelroytman and
mraman-2U
May 7, 2026 20:31
nsprenkle
enabled auto-merge (squash)
May 7, 2026 20:32
There was a problem hiding this comment.
Pull request overview
Fixes progress page breakages when course grading policies contain numeric values encoded as strings (e.g., "min_count": "2"), by casting those values to numeric types before doing math.
Changes:
- Cast
weight,drop_count, andmin_countfrom grading policy entries tofloat/intwhen building the internal policy map. - Add a unit-test scenario covering grading policies with string-typed numeric fields.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lms/djangoapps/course_home_api/progress/api.py | Cast grading-policy numeric fields to float/int to prevent type errors during placeholder/math operations. |
| lms/djangoapps/course_home_api/progress/tests/test_api.py | Add a scenario where grading policy numeric fields are strings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I don't disagree with this change but I wonder whether or not this should be made further up the chain of responsibility, like, should this be done in |
jansenk
approved these changes
May 7, 2026
nsprenkle
added a commit
that referenced
this pull request
May 12, 2026
Fixes an issue with some courses causing the progress page to crash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a typing issue in grading policies causing breakages on the progress page.
Jira - https://2u-internal.atlassian.net/browse/CR-8030
Supporting information
Some courses were running into the error below which was a result of a grading policy using strings instead of numbers for their values.
This correctly casts numeric values in grading policies to numbers, allowing those mathematical operations to succeed, rather than fail.
Testing instructions
Unit tests also updated.
Deadline
ASAP - fix for a C2 bug