Skip to content

fix: instructor dashboard add info encoded in the request body#38885

Open
marslanabdulrauf wants to merge 2 commits into
openedx:masterfrom
mitodl:marslan/11874-rescore-if-higher
Open

fix: instructor dashboard add info encoded in the request body#38885
marslanabdulrauf wants to merge 2 commits into
openedx:masterfrom
mitodl:marslan/11874-rescore-if-higher

Conversation

@marslanabdulrauf

Copy link
Copy Markdown
Contributor

Description

This pull request improves how the only_if_higher flag is handled in the instructor API for rescoring learners. The main change is to consistently support reading the flag from both query parameters and the request body, matching how the frontend sends data. This also makes the code more robust by accepting both boolean and string values for the flag.

Improvements to request handling:

  • Added a new _get_only_if_higher helper function to extract the only_if_higher flag from either query parameters or the request body, accepting both string and boolean representations.
  • Updated the RescoreView endpoint and its documentation to clarify that only_if_higher can be provided in either the query string or request body.
  • Replaced the previous direct query param check for only_if_higher in the post method with the new helper for consistent and reliable extraction.

Supporting Information

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

Testing instructions

Steps to Reproduce

Make sure you have a course with graded sub-section with at least one problem(multi-select would do)

  1. Enroll yourself as a learner in course.
  2. Log in as the learner account.
  3. Go to the unit page
  4. Go to the first question "Multiple Choice" and choose "Correct Answer" - click submit.
  5. You will see your score is reflected as correct
  6. Log in as a staff member.
  7. Go to the problem's unit in studio
  8. Click the pencil icon to edit the that problem, "Multiple choice"
  9. Scroll to Answers
  10. Change the correct answer to be "Incorrect*"
  11. Save your changes and publish the page.
  12. Go to the grading module on the instructor dashboard
  13. Type your learner account information into "Specify Learner", click "Select"
  14. Put the location block for the problem into "Specify Problem", click "Select"
  15. The page will update with the learner's responses to the problem.
  16. Next to "Rescore submission" click "Rescore only if score improves", and confirm "rescore"
  17. Reload the page and enter the learner name and problem block again.
  18. The score should be same, 1/1
  19. Log in as your learner and reload the unit with the problem
  20. You should see that you are marked 1.0/1.0

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 14, 2026
@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description can be updated to something like "Optional: If 'true', only update scores that are higher than current. " "May be provided as a query parameter or in the request body (JSON boolean or string)."

course_key, usage_key = parsed

only_if_higher = request.query_params.get('only_if_higher', 'false').lower() == 'true'
only_if_higher = _get_only_if_higher(request)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if a unit test were added for this change

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jul 15, 2026
@mphilbrick211 mphilbrick211 added the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label Jul 15, 2026
@marslanabdulrauf
marslanabdulrauf force-pushed the marslan/11874-rescore-if-higher branch from 657ef65 to 28735a5 Compare July 15, 2026 15:11
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