-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix: prevent None entrance_exam_minimum_score_pct from breaking CourseOverview sync #37339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: prevent None entrance_exam_minimum_score_pct from breaking CourseOverview sync #37339
Conversation
…eOverview sync When entrance exams are disabled in Studio, the field `entrance_exam_minimum_score_pct` was set to `None`. This caused silent failures when saving `CourseOverview` because the database column requires a float (NOT NULL). This patch ensures that: - CourseOverview sanitizes None values by falling back to `settings.ENTRANCE_EXAM_MIN_SCORE_PCT` (default=50). - Studio avoids writing `None` and instead applies the configured default. Impact: - Prevents IntegrityErrors and silent failures when updating course settings. - Restores proper syncing between modulestore (Mongo) and CourseOverview (MySQL). - Fixes reported issues such as display name changes not persisting and course start dates not syncing. Closes: openedx#37319
Thanks for the pull request, @Abdul-Muqadim-Arbisoft! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Submit a signed contributor agreement (CLA)
If you've signed an agreement in the past, you may need to re-sign. Once you've signed the CLA, please allow 1 business day for it to be processed. 🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
if course.entrance_exam_minimum_score_pct is None: | ||
entrance_exam_minimum_score_pct = float(settings.ENTRANCE_EXAM_MIN_SCORE_PCT) | ||
if entrance_exam_minimum_score_pct.is_integer(): | ||
entrance_exam_minimum_score_pct = entrance_exam_minimum_score_pct / 100 | ||
course_overview.entrance_exam_minimum_score_pct = entrance_exam_minimum_score_pct | ||
elif isinstance(course.entrance_exam_minimum_score_pct, int): | ||
course_overview.entrance_exam_minimum_score_pct = course.entrance_exam_minimum_score_pct / 100 | ||
else: | ||
course_overview.entrance_exam_minimum_score_pct = course.entrance_exam_minimum_score_pct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although I am not sure why int
is checked twice, but this code block can be simplified to this:
if course.entrance_exam_minimum_score_pct is None:
ee_min_score_pct = float(settings.ENTRANCE_EXAM_MIN_SCORE_PCT)
else:
ee_min_score_pct = course.entrance_exam_minimum_score_pct
if isinstance(ee_min_score_pct, int) or (isinstance(ee_min_score_pct, float) and ee_min_score_pct.is_integer()):
ee_min_score_pct = ee_min_score_pct / 100
course_overview.entrance_exam_minimum_score_pct = ee_min_score_pct
Please also include an inline comment on why this conditional block is being added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@taimoor-ahmed-1 code block simplified and inline comment added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested the changes?
Hi @Abdul-Muqadim-Arbisoft! If you have not done so already, please have your manager reach out to [email protected] to have you added to our existing entity agreement. This will allow the CLA check to turn green. Thanks! |
- Consolidate logic to avoid repeated assignments - Centralize None fallback and int/float normalization - Improve readability with inline comment and consistency with Open edX style
When entrance exams are disabled in Studio, the field
entrance_exam_minimum_score_pct
was set toNone
. This caused silent failures when savingCourseOverview
because the database column requires a float (NOT NULL).This patch ensures that:
settings.ENTRANCE_EXAM_MIN_SCORE_PCT
(default=50).None
and instead applies the configured default.Impact:
Closes: #37319