Skip to content

refactor: slash-and-burn Problem block built-in implementation (slash-n-burn #37819) - #38751

Open
irfanuddinahmad wants to merge 7 commits into
masterfrom
irfanuddinahmad/slash-and-burn-problem-block
Open

irfanuddinahmad wants to merge 7 commits into
masterfrom
irfanuddinahmad/slash-and-burn-problem-block

Conversation

@irfanuddinahmad

@irfanuddinahmad irfanuddinahmad commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Removes the built-in Problem (capa) XBlock. xblock_problem.ProblemBlock has been the default since USE_EXTRACTED_PROBLEM_BLOCK = True, so the built-in code no longer runs.

Part of the Slash-n-Burn Built-In XBlocks epic. Closes openedx/public-engineering#540

Merge status: ✅ ready for review. The xblocks-core counterparts of the 9 MathJax v4 JS specs deleted here are in openedx/xblocks-core#320, which should merge first.
Not verified: the codejail service path (CODE_JAIL_REST_SERVICE_REMOTE_EXEC). It needs an AppArmor 4 Linux host. Scripted problems were run with local unsandboxed execution instead and grade correctly.
Translations hold: merge only after openedx/xblocks-core#329 and openedx/openedx-translations#85196 are live and the xblock_* catalogs are confirmed. Until then the extracted block is translated only through the built-in xmodule msgids that this PR deletes. Its JS strings also need i18n_js_namespace (review on #329).

Changes

Deleted: xmodule/capa_block.py (2481 LOC: _BuiltInProblemBlock + shim), xmodule/capa/ (deprecated safe_exec shim), xmodule/js/src/capa/ (display.js, imageinput.js, schematic.js), ProblemBlockDisplay.css, the ProblemBlockDisplay webpack entry, the built-in problem entrypoint, and the USE_EXTRACTED_PROBLEM_BLOCK toggle.

Modified:

  • CODE_JAIL_REST_SERVICE_REMOTE_EXEC points directly to xblock_problem.capa.safe_exec.remote_exec.
  • Every ProblemBlock, SHOWANSWER and generate_report_data import and patch target now uses xblock_problem.

Tests:

Removed from the platform Counterpart in xblocks-core
xmodule/tests/test_capa_block.py (141 tests, imported _BuiltInProblemBlock) src/xblock_problem/tests/test_capa_block.py: same names, near-identical bodies (compared one by one)
xmodule/js/spec/capa/display_spec.js, imageinput_spec.js + fixtures, pre-MathJax-v4 specs src/xblock_problem/assets/spec/: same names, except 2 renamed by xblocks-core's own MathJax v4 port (c5fb2e4) because the v2 API they tested is gone
The 9 specs added by #33555 (MathJax v4) openedx/xblocks-core#320 (mapping below)

Kept in the platform: lms/djangoapps/grades/tests/integration/test_problems.py runs against xblock_problem.ProblemBlock; only reset_class(), the toggle overrides and BuiltIn twins were dropped. It tests the platform's grades pipeline, so it stays here (supersedes openedx/xblocks-core#266).

MathJax v4 spec mapping (#33555 → xblocks-core#320)
Platform test (#33555) Counterpart in xblocks-core#320
should clear and typeset the math element moved unchanged (display_spec.js)
wraps calculator input in backticks for input.math moved unchanged
clears preview and skips typesetPromise on empty input moved unchanged
bind the formulaequationinput existing: makes a request on user input (formula_equation_preview_spec.js) and does not bind refreshMath to formula equation inputs
wraps calculator syntax in backticks for formulaequationinput FormulaEquationTest.test_formcalc_ajax_calculator_syntax_renders_as_latex
preserves explicit TeX delimiters \(...\) test_formcalc_ajax_inline_tex_delimiters_rejected
preserves display math TeX delimiters \[\] test_formcalc_ajax_display_tex_delimiters_rejected
preserves double-dollar delimiters test_formcalc_ajax_double_dollar_delimiters_rejected
preserves single-dollar delimiters test_formcalc_ajax_single_dollar_delimiters_rejected

The last 6 platform tests covered the built-in block's client-side refreshMath rendering of formula-equation previews. That path doesn't run on master (toggle True) and is removed here. The extracted block deliberately renders these previews only on the server, through preview_formcalc and formula_equation_preview.js (xblocks-core 989ae32), so their counterparts assert what that path does for the same inputs.

Epic Step 1: Post-extraction commit review

Toggle flipped 2026-04-24 (53d3d5dbdf). No later commits to capa_block.py. One later functional change, #33555 (MathJax v4) to xmodule/js/src/capa/display.js, is already in xblocks-core via openedx/xblocks-core#270 by the same author (same isMathJaxTypesetReady/isMathJaxRefreshReady/isMathJaxMathMLReady logic). The one difference is intentional: 989ae32 stopped binding refreshMath to formula-equation inputs. Nothing to port.

Test plan

Tested on a local Tutor nightly (master 6f85d63c7f + xblocks-core 2.0.0) through the REST APIs and a headless browser, because PR sandboxes aren't deploying (open-craft/pr-sandbox-automation#28). A box is ticked only if that flow actually ran.

  • LMS student view
  • CMS course unit
  • CMS V2 Library
  • Python-evaluated problem through codejail: the codejail service wasn't exercised (needs an AppArmor 4 Linux host). The setting resolves to xblock_problem.capa.safe_exec.remote_exec.send_safe_exec_request_v0. With local unsandboxed execution (test courses only), scripted and randomized problems grade correctly, on the course block and on the library-reused copy
  • CI: grades/tests/integration/test_problems.py, test_tasks_helper.py, test_contentstore.py, test_block_render.py, test_library_content.py, test_item_bank.py, test_delay_between_attempts.py, show_answer/tests/, test_crud.py (all passed locally), npm run build
V2 Library checklist: 9/14 pass (R1–R4 partly verified, details inside; L10 export diff not done)

Content Libraries V2: smoke tests (historically the most fragile area for extracted blocks: openedx/xblocks-core#123, openedx/xblocks-core#132, openedx/xblocks-core#243, openedx/xblocks-core#274)

  • L1. Create the block in a V2 library; the preview renders with no 500 or console errors
  • L2. Edit → save → reload the page → reopen the editor: every field kept its value
  • L3. Publish the component; its status changes to Published
  • L4. Copy to clipboard from the library, then paste into the library and into a course unit
  • L5. In a library unit: add the block as new content, then add it as existing library content (watch for "There was an error linking the content to this container", [Test failure] TC-00338: Libraries: Unable to add existing component to a unit wg-build-test-release#556)
  • L6. Reuse in a course: add it through "Library content" in a unit, and reuse a library unit containing it from the course outline. Both render in Studio and in the LMS student view
  • L7. Sync: edit and publish in the library, then accept the update in the course and also ignore one
  • L8. Override the title on the reused copy in the course
  • L9. Library search: filtering by content type finds the block
  • L10. OLX: import as a pointer tag and inline, export as a pointer tag, and diff the export against master (which still has the built-in block) — not ticked: inline and pointer-tag import and pointer-tag export pass; the export diff against the built-in block wasn't done

Problem-specific (from the Problem testing notes on #38152):

  • R1. In a library, author a problem with each editor (simple, advanced OLX, markdown); each saves, reopens in the same editor and previews correctly — not ticked: markdown and OLX content save, reopen and preview (API); the editor-picker UI wasn't exercised
  • R2. Math (MathJax v4) renders in the library preview and on the reused copy — not ticked: MathJax renders on the reused copy in the LMS (1 mjx-container); the library preview wasn't checked in a browser
  • R3. On the reused copy in the LMS: answering, grading, hints, show answer, reset and max attempts work — not ticked: answering, grading, choice hints, demand hint, show answer and reset pass; max-attempts lockout wasn't tested
  • R4. A Python-scripted / randomized problem reused from the library runs through codejail and re-randomizes — not ticked: not through codejail. With local unsandboxed execution, a scripted randomized problem reused from the library grades correctly in the LMS and re-randomizes after reset (7 → 16)

Library checklist compiled from the Aximprovements manual test doc (Extracted Block Tests tab) and the Ulmo test sheet's library cases. Generated using Claude Code.

Screenshots

6 screenshots (LMS, Studio unit, V2 Library)

Local Tutor nightly, 2026-11-12

Captured automatically during the local smoke tests (the sandbox isn't reachable yet, see open-craft/pr-sandbox-automation#28). All images: irfanuddinahmad/edx-platform@snb-smoke-screenshots/38751.

LMS student view (imported block) Studio course unit (authoring MFE)
lms_inline studio_unit
V2 library home V2 library component preview
library_home lib_preview
LMS: copy reused from the library (after sync + title override) LMS: library-reused problem with MathJax
lms_reused problem_mathjax_lms

🤖 Generated with Claude Code

Settings

# Workaround for open-craft/pr-sandbox-automation#28: the openedx-permissions image name gets mangled.
DOCKER_IMAGE_PERMISSIONS: docker.io/overhangio/openedx-permissions:23.0.0-main

@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 Jun 11, 2026
@openedx-webhooks

openedx-webhooks commented Jun 11, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @irfanuddinahmad!

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

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.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jun 11, 2026
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/slash-and-burn-problem-block branch from fcc939b to 356dc98 Compare June 11, 2026 12:53
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jun 11, 2026
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/slash-and-burn-problem-block branch 2 times, most recently from 46e90c6 to bebc423 Compare June 12, 2026 16:55
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/slash-and-burn-problem-block branch from bebc423 to 544f32e Compare June 22, 2026 11:17
@irfanuddinahmad irfanuddinahmad changed the title feat: slash-and-burn Problem block built-in implementation refactor: slash-and-burn Problem block built-in implementation (slash-n-burn #37819) Jun 22, 2026
@mphilbrick211 mphilbrick211 moved this from Ready for Review to Waiting on Author in Contributions Aug 20, 2026
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/slash-and-burn-problem-block branch from 5d222d0 to c0260d6 Compare November 4, 2026 11:24
@mphilbrick211 mphilbrick211 moved this from Waiting on Author to Ready for Review in Contributions Nov 4, 2026
@irfanuddinahmad irfanuddinahmad added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Nov 5, 2026
irfanuddinahmad added a commit to irfanuddinahmad/xblocks-core that referenced this pull request Nov 6, 2026
…pecs

openedx/openedx-platform#33555 added six specs for the built-in block's
client-side refreshMath formula-equation preview, which
openedx/openedx-platform#38751 removes. The extracted block renders these
previews only via the server (preview_formcalc, 989ae32), so add tests
asserting that path's behavior for the same inputs:

- calculator syntax R_1*R_2/R_3 renders as LaTeX
- \(..\), \[..\], $$..$$ and $..$ inputs are rejected with a parse error

The binding spec maps to existing coverage (formula_equation_preview_spec
'makes a request on user input' and display_spec 'does not bind
refreshMath to formula equation inputs').

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/slash-and-burn-problem-block branch from c0260d6 to 67f3d09 Compare November 6, 2026 10:10
irfanuddinahmad added a commit to irfanuddinahmad/xblocks-core that referenced this pull request Nov 10, 2026
Ports three tests that openedx/openedx-platform#33555 (MathJax v4
upgrade) added to xmodule/js/spec/capa/display_spec.js, which
openedx/openedx-platform#38751 removes along with the built-in Problem
block:

- should clear and typeset the math element
- wraps calculator input in backticks for input.math
- clears preview and skips typesetPromise on empty input

Names, bodies and assertions are unchanged except for the extracted
block's Problem(runtime, element) constructor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
irfanuddinahmad added a commit to irfanuddinahmad/xblocks-core that referenced this pull request Nov 10, 2026
…pecs

openedx/openedx-platform#33555 added six specs for the built-in block's
client-side refreshMath formula-equation preview, which
openedx/openedx-platform#38751 removes. The extracted block renders these
previews only via the server (preview_formcalc, 989ae32), so add tests
asserting that path's behavior for the same inputs:

- calculator syntax R_1*R_2/R_3 renders as LaTeX
- \(..\), \[..\], $$..$$ and $..$ inputs are rejected with a parse error

The binding spec maps to existing coverage (formula_equation_preview_spec
'makes a request on user input' and display_spec 'does not bind
refreshMath to formula equation inputs').

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Irfan Ahmad and others added 2 commits November 10, 2026 15:22
Removes the built-in ProblemBlock shim and all associated assets now that
the extracted xblocks_contrib.problem.ProblemBlock is the production implementation.

- Delete xmodule/capa_block.py (_BuiltInProblemBlock + shim)
- Delete xmodule/capa/ (deprecated safe_exec shim pointing to xblocks_contrib)
- Delete xmodule/js/src/capa/ JS files (display, imageinput, schematic)
- Delete xmodule/static/css-builtin-blocks/ProblemBlockDisplay.css
- Delete xmodule/tests/test_capa_block.py (tested _BuiltInProblemBlock directly)
- Delete lms/djangoapps/grades/tests/integration/test_problems.py (used reset_class shim)
- Remove USE_EXTRACTED_PROBLEM_BLOCK toggle from openedx/envs/common.py
- Update CODE_JAIL_REST_SERVICE_REMOTE_EXEC to xblocks_contrib path
- Remove problem entrypoint from pyproject.toml
- Remove ProblemBlockDisplay webpack entry
- Update all ProblemBlock/SHOWANSWER imports to xblocks_contrib.problem

Part of epic #37819

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Irfan Ahmad and others added 5 commits November 10, 2026 15:22
…nfig.js

ProblemBlockDisplay (the only webpack entry including capa/display.js,
capa/imageinput.js, and capa/schematic.js) and those JS files are deleted
in this PR. Remove the now-dead imports-loader rules for consistency with
how Poll, WordCloud, and LTI PRs handle their own cleanup.
Also removes the stale capa/display.js example from the comment above the
imports-loader block since that example is no longer in the codebase.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…blemBlock

These grades-pipeline integration tests already ran against the extracted
ProblemBlock (USE_EXTRACTED_PROBLEM_BLOCK=True). The grades pipeline lives
in openedx-platform, so the coverage belongs here rather than in
xblocks-core (supersedes the port tracked in openedx/xblocks-core#266).

Only the reset_class() calls, toggle overrides and BuiltIn variants are
removed; test names and logic are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
xblocks-core 2.0.0 (#38473) removed the xblocks_contrib package. Point the
platform entrypoint, imports and mock.patch targets at the new per-block
packages (e.g. xblocks_contrib.video.video -> xblock_video.block).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/slash-and-burn-problem-block branch from 67f3d09 to dd17204 Compare November 10, 2026 10:26

This branch has not been deployed

No deployments
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). create-sandbox open-craft-grove should create a sandbox environment from this PR 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.

[Refactor] Slash-n-Burn Problem BuiltIn XBlock

2 participants