Skip to content

fix: add weight from max_weight if its missing from meta#38252

Open
marslanabdulrauf wants to merge 2 commits intoopenedx:masterfrom
mitodl:marslan/9447-problem-weight
Open

fix: add weight from max_weight if its missing from meta#38252
marslanabdulrauf wants to merge 2 commits intoopenedx:masterfrom
mitodl:marslan/9447-problem-weight

Conversation

@marslanabdulrauf
Copy link
Copy Markdown
Contributor

@marslanabdulrauf marslanabdulrauf commented Mar 31, 2026

Related Ticket

https://github.com/mitodl/hq/issues/9447 (MIT Internal)

Description

This pull request introduces a new helper function to improve how problem block metadata is handled, specifically ensuring that the correct weight value is shown for problem blocks when it has not been explicitly set. The changes also include comprehensive unit tests for this new logic.

Enhancements to problem block metadata handling:

  • Added a new helper function _get_metadata_with_problem_defaults in view_handlers.py to inject a weight value into problem block metadata when it is missing, using max_score() as the default. This prevents the frontend from defaulting to 1 when the actual point value is different.
  • Updated the get_block_info function to use _get_metadata_with_problem_defaults instead of own_metadata, ensuring the new logic is applied wherever block info is retrieved.

Testing improvements:

  • Added a new test class TestGetMetadataWithProblemDefaults in test_block.py to verify the behavior of the helper function, covering scenarios for problem blocks with and without explicit weights, as well as non-problem blocks.
  • Updated imports in test_block.py to include _get_metadata_with_problem_defaults for testing.

Testing instructions

  1. Spin up a local Studio instance.
  2. Create a course and add a Problem component (e.g. a Multiple Choice question worth 2 points).
  3. Do not manually set the "Weight" field, leave it at the default.
  4. Open the problem in Studio's unit editor and click the Edit button.
  5. In the settings panel, verify the Weight field now shows the problem's actual point value (e.g. 2.0) instead of the frontend's hardcoded default of 1.

@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @marslanabdulrauf!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Mar 31, 2026
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Mar 31, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Apr 1, 2026
@mphilbrick211 mphilbrick211 added the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs reviewer assigned PR needs to be (re-)assigned a new reviewer open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

4 participants