Skip to content

Conversation

@irtazaakram
Copy link
Member

@irtazaakram irtazaakram commented Oct 13, 2025

This PR applies consistent formatting across all Problem XBlock–related files to align with the formatting conventions used in the xblocks-contrib extraction. The goal is to minimize noise during the extraction review and ensure that only functional differences remain when moving the Problem XBlock out of edx-platform.

We are in the process of extracting the Problem XBlock into xblocks-contrib/problem, where all code and templates are already formatted consistently. To make the migration diff easier for reviewers—and to avoid unnecessary churn caused by formatting—we are pre-formatting the corresponding files inside edx-platform using the same tools and configuration.

Related PR: openedx/xblocks-contrib#63

Python Files

isort --profile black --line-length 120
black --line-length 120

Targeted files include:

openedx/core/djangolib/markup.py
openedx/core/djangolib/tests/test_markup.py
openedx/core/lib/safe_lxml/xmlparser.py
xmodule/capa_block.py
xmodule/capa/
xmodule/contentstore/django.py
xmodule/fields.py
xmodule/progress.py
xmodule/raw_block.py
xmodule/stringify.py
xmodule/tests/test_capa_block.py
xmodule/tests/test_fields.py
xmodule/tests/test_progress.py
xmodule/tests/test_stringify.py
xmodule/tests/test_xml_block.py
xmodule/util/sandboxing.py
xmodule/x_module.py
xmodule/xml_block.py
  • No logic changes — formatting only
  • Consistent style across Problem XBlock files

Testing:

  • Created a Multiple Choice problem in the Visual Editor, submitted the correct option, and confirmed the Green Check appeared.
  • Submitted an incorrect option in the same Multiple Choice problem and confirmed the Red X appeared.
  • Configured a Checkbox problem with partial_credit="EDC", selected a mix of right/wrong answers, and confirmed a partial score (e.g., 50%) was awarded.
  • Configured a Checkbox problem with partial_credit="halves", selected one wrong option, and confirmed the score was cut exactly in half.
  • Configured a Dropdown problem with inline="1" and confirmed the dropdown rendered inside the text flow, not on a new line.
  • Configured a Text Input with type="ci" (Case Insensitive), submitted "paris" for answer "Paris", and verified it was accepted.
  • Configured a Text Input with type="cs" (Case Sensitive), submitted "paris" for answer "Paris", and verified it was rejected.
  • Configured a Numerical Input with a tolerance of 0.5, submitted a value on the boundary (e.g., 10.5 for 10), and confirmed it was marked Correct.
  • Configured a Numerical Input with an answer range (e.g., [1, 2]), submitted a value inside the range, and confirmed it was marked Correct.
  • Entered text into a problem, clicked Save, performed a hard refresh, and confirmed the text remained saved.
  • Modified max_attempts to 1, submitted an answer, and confirmed the Submit button disabled immediately.
  • Modified max_attempts to 3, submitted incorrect answers, and confirmed the button remained enabled until the 3rd submission.
  • Modified max_attempts to 0 (unlimited) and confirmed the problem never locks regardless of submissions.
  • Enabled show_reset_button="true", clicked Reset on an un-submitted input, and confirmed the field cleared.
  • Enabled show_reset_button="false" and confirmed the Reset button was hidden in the LMS.
  • Set showanswer="always" and confirmed the Show Answer button was visible immediately upon page load.
  • Set showanswer="answered" and confirmed the button appeared only after a correct submission.
  • Set showanswer="attempted" and confirmed the button appeared after the first incorrect submission.
  • Set showanswer="past_due", manipulated the due date to the past, and confirmed the button appeared immediately.
  • Enabled rerandomize="on_reset" (on a problem with a Python script), clicked Reset, and confirmed the random values changed.
  • Enabled rerandomize="never", clicked Reset, and confirmed that only inputs cleared while the random values remained static.
  • Enabled shuffle="true" on a Multiple Choice problem, reloaded the page 3 times, and confirmed the order of answers changed.
  • Switched a problem to the Advanced Editor to add custom XML (e.g., <choicehint>), then attempted to switch back to the Visual Editor to confirm the system prevented the action.
  • Configured a Math Expression problem, submitted a symbolically equivalent answer (e.g., 1 + x^2 for x^2 + 1), and confirmed the parser accepted it.
  • Configured a Drag and Drop problem in Standard Mode, dragged an incorrect item, and confirmed it immediately snapped back with feedback.
  • Configured a Drag and Drop problem in Assessment Mode, dragged items, clicked Submit, and confirmed no feedback occurred until submission.

During testing on the sandbox, the following problems were observed to be non-functional, but this is not caused by the changes in this PR

  • Custom JavaScript Display & Grading
  • Custom Python-evaluated input

Relevant issue: #36538

@irtazaakram irtazaakram marked this pull request as draft October 13, 2025 09:40
@irtazaakram irtazaakram force-pushed the autoformat-problemblock branch 2 times, most recently from c2f0f65 to e3f3005 Compare October 13, 2025 10:28
@irtazaakram irtazaakram changed the title Autoformat Problem XBlock Templates and Related Source Files for Consistency Autoformat Problem XBlock Source Files for Consistency Oct 13, 2025
@irtazaakram irtazaakram force-pushed the autoformat-problemblock branch 4 times, most recently from 7920e3e to 8a5ec40 Compare October 15, 2025 06:35
@irtazaakram irtazaakram changed the title Autoformat Problem XBlock Source Files for Consistency Autoformat Problem XBlock Source Files for Consistency (1/2) Oct 15, 2025
we'll combine the system's per-student seed with the problem id in picking the bin.
"""
r_hash = hashlib.sha1()
r_hash = hashlib.sha256()
Copy link
Member Author

Choose a reason for hiding this comment

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

@irtazaakram irtazaakram added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Oct 15, 2025
@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@irtazaakram irtazaakram added create-sandbox open-craft-grove should create a sandbox environment from this PR and removed create-sandbox open-craft-grove should create a sandbox environment from this PR labels Oct 20, 2025
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Configuration information unavailable

@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@irtazaakram irtazaakram added create-sandbox open-craft-grove should create a sandbox environment from this PR and removed create-sandbox open-craft-grove should create a sandbox environment from this PR labels Nov 11, 2025
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@irtazaakram irtazaakram force-pushed the autoformat-problemblock branch from d5a4e6e to 072eceb Compare December 1, 2025 14:35
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@irtazaakram irtazaakram marked this pull request as ready for review December 3, 2025 11:03
Copy link
Contributor

@salman2013 salman2013 left a comment

Choose a reason for hiding this comment

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

LGTM

@irtazaakram irtazaakram merged commit 1945b12 into master Dec 5, 2025
53 checks passed
@irtazaakram irtazaakram deleted the autoformat-problemblock branch December 5, 2025 13:31
@irtazaakram irtazaakram changed the title Autoformat Problem XBlock Source Files for Consistency (1/2) Autoformat Problem XBlock Source Files for Consistency (1/3) Dec 15, 2025
mraman-2U pushed a commit to mraman-2U/edx-platform that referenced this pull request Dec 24, 2025
…#37476)

* fix: run formatter black and isort

* fix: linting, pydocstyle, xsslint and security issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-sandbox open-craft-grove should create a sandbox environment from this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants