Skip to content

fix: restore Problem template behavior lost in the Mako to Django conversion - #368

Open
irfanuddinahmad wants to merge 1 commit into
openedx:mainfrom
irfanuddinahmad:irfanuddinahmad/problem-template-fixes
Open

irfanuddinahmad wants to merge 1 commit into
openedx:mainfrom
irfanuddinahmad:irfanuddinahmad/problem-template-fixes

Conversation

@irfanuddinahmad

Copy link
Copy Markdown
Contributor

Summary

Changes

Issue Fix
#305: "Shift due dates" under a past-due problem does nothing problem.html passes the event data to emit_event() unquoted, as the Mako template did (the fix suggested in #305)
#367.1: choice 10+ also marks choice 1 ChoiceGroup.selected_choice_ids() restores the Mako template's rule: a radio's string value is wrapped in a list, so choice_id in selected_choice_ids is an exact match. choicegroup.html uses it for submitted, checked and the correctness mark. This also makes a <radiogroup> with a list value checked again.
#367.2: choicetext number boxes come back blank ChoiceTextGroup puts each text input's saved answer in its content node's value; choicetext.html reads content_node.value

Test plan

  • 5 new tests fail on main and pass here:

    • test_submit_disabled_cta_event_data
    • test_radio_label_marked_only_for_selected_choice
    • test_radiogroup_selected_choice_checked
    • test_text_input_value
    • test_saved_text_input_values, which renders end to end through the real template.

    ChoiceGroupTemplateTest.render_to_xml and ChoiceGroupTest.check_group now include the new selected_choice_ids context key.

  • pytest src/xblock_problem: 710 passed. ruff check, ruff format --check and pylint are clean.

  • Live in a local Tutor (platform master, xblocks-core 4.0.0 with this PR's four capa files on top; they're unchanged between 4.0.0 and main), as a learner:

    Stock This PR
    12 choices, submit choice_10 (correct) choice_1 and choice_10 marked correct Only choice_10
    Choicetext: enter 5, submit, reload Box empty Box shows 5
  • "Shift due dates": covered by the unit test only. A live check needs a self-paced course with personalized schedules and the learning MFE (see "Shift due dates" CTA under a past-due problem does nothing — onclick is invalid JavaScript #305).

Stock This PR
stock this PR

Closes #305. Closes #367. Part of the Slash-n-Burn Built-In XBlocks epic.

🤖 Generated with Claude Code

…version

Three regressions from openedx/openedx-platform#37570, which converted the
capa templates from Mako to Django:

- problem.html: the "Shift due dates" button wrapped the CTA's event data
  in quotes, so its onclick was a JS syntax error. Pass it to emit_event()
  unquoted, as the Mako template did.
- choicetext.html: `value.my_id` looked up the literal key "my_id", so the
  numeric inputs of a choicetext problem came back blank. ChoiceTextGroup
  now puts each text input's saved answer in its content node's `value`.
- choicegroup.html: the correctness mark used `choice_id in value`, a
  substring test for a radio choicegroup, so selecting choice_10 also
  marked choice_1; and a <radiogroup>'s list value never checked its
  radio. ChoiceGroup.selected_choice_ids() restores the Mako template's
  is_radio_input() rule for the checked, submitted and correctness marks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Dec 4, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @irfanuddinahmad!

This repository is currently maintained by @openedx/axim-engineering.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

2 participants