Repository navigation
refactor: slash-and-burn Problem block built-in implementation (slash-n-burn #37819) - #38751
irfanuddinahmad wants to merge 11 commits into
Conversation
|
Thanks for the pull request, @irfanuddinahmad! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
fcc939b to
356dc98
Compare
46e90c6 to
bebc423
Compare
bebc423 to
544f32e
Compare
5d222d0 to
c0260d6
Compare
…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 <noreply@anthropic.com>
c0260d6 to
67f3d09
Compare
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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
67f3d09 to
dd17204
Compare
d334e25 to
3227f88
Compare
|
@farhan thanks, all addressed; head is now
openedx/xblocks-core#320 (the MathJax v4 spec ports) is still open and should merge first. CI is running on the new head. Generated using Claude Code |
…lem (2026-11-30) The previous image showed a scripted problem, which needs a remote codejail service that the local stack doesn't run.
|
@irfanuddinahmad Please rebase and resolve conflicts |
farhan
left a comment
There was a problem hiding this comment.
Approving, but it needs rebase and conflicts needs to be resolved.
3227f88 to
f14f669
Compare
|
@farhan thanks, rebased onto master
openedx/xblocks-core#320 (the MathJax v4 spec ports) is still open, and this PR should merge after it. Generated using Claude Code |
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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
|
@farhan the last blocker for this PR is now openedx/xblocks-core#320, which I've requested your review on (and navinkarkera's). It gives the 9 MathJax v4 specs that #33555 added to the platform Generated using Claude Code |
…ded (2026-12-02)
279ea5f to
914f3a5
Compare
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 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Same nits as reviewed on #38745: - Drop the extra blank line left in openedx/envs/common.py after the toggle removal. - Collapse the toggle-era base class + __test__ subclass back into the original test class name(s). The plugin cache reset was only needed for the removed importlib.reload. Test bodies are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
These fixtures were only loaded by the deleted xmodule/js/spec/capa/display_spec.js and imageinput_spec.js. The specs moved to xblock_problem with their own copies of the fixtures (matlabinput_problem.html is gone everywhere, since MatlabInput was removed). Also point a stale comment in sequence/display.js at the extracted block's display.js. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-ups: - remove xmodule/js/src/capa/.gitignore, which only un-ignored the deleted capa JS files, so the folder goes away - remove the unused 'capa/display' RequireJS alias from the LMS spec config - drop ProblemBlock from the builtin-webpack examples in xmodule/assets/README.rst - point the sequence/display.js comment at xblock_problem's display.js - note where test_capa_block.py lives now in the test_delay_between_attempts.py docstrings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…used - xmodule/js/spec/helper.js: stubRequests no longer fakes problem_get (it read problem_content.html, which this PR deletes), /calculate or problem_(check|reset|show|save); only the deleted capa specs made those requests. The goto_position and event branches stay. - jasmine-imagediff: its only user (toImageDiffEqual) was the deleted capa display_spec.js, so drop it from the xmodule Karma configs. The wider cleanup is tracked in #39468. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
914f3a5 to
1207bc3
Compare
Summary
xblock_problem.ProblemBlockhas been the default sinceUSE_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.
Changes
Removed
xmodule/capa_block.py(_BuiltInProblemBlockand the shim),ProblemBlockDisplay.css, theProblemBlockDisplaywebpack entry, and theUSE_EXTRACTED_PROBLEM_BLOCKtoggle.xmodule/js/src/capa/(display.js,imageinput.js,schematic.js,.gitignore), and the unused'capa/display'RequireJS alias inlms/static/lms/js/spec/main.js.problem*.html,{checkbox,codeinput,jsinput,matlabinput,radiobutton}_problem.html,imageinput.html/.underscore).problem_get,/calculateandproblem_(check|reset|show|save)stubs inxmodule/js/spec/helper.js, andjasmine-imagediffin the xmodule Karma configs.Changed
problementrypoint inpyproject.tomlpoints atxblock_problem:ProblemBlock. The name stays because existing content uses it.ProblemBlock,SHOWANSWERandgenerate_report_dataimport and patch target usesxblock_problem.xmodule/assets/README.rstexample list, a comment inxmodule/js/src/sequence/display.js, and thetest_delay_between_attempts.pydocstrings.Not in this diff: the
remote_exec.pyshim, which master already removed (#39429).Tests
xmodule/tests/test_capa_block.py(140)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; 2 renamed there with equivalent bodies, 1 not ported on purpose (below)lms/djangoapps/grades/tests/integration/test_problems.pyxblock_problem.ProblemBlockThe one JS spec not ported
updateMathML › when there is an exception › should queue up the exceptiontests theexception.restartretry. That is a MathJax v2MathJax.Callbackconcept with no v4 equivalent. feanil flagged the branch as dead in the v4 review (openedx/xblocks-core#270), and xblocks-core2d0c0ffremoved it and its test.MathJax v4 spec mapping (#33555 → openedx/xblocks-core#320)
should clear and typeset the math elementdisplay_spec.js)wraps calculator input in backticks for input.mathclears preview and skips typesetPromise on empty inputbind the formulaequationinputmakes a request on user input(formula_equation_preview_spec.js) anddoes not bind refreshMath to formula equation inputswraps calculator syntax in backticks for formulaequationinputFormulaEquationTest.test_formcalc_ajax_calculator_syntax_renders_as_latexpreserves explicit TeX delimiters \(...\)test_formcalc_ajax_inline_tex_delimiters_rejectedpreserves display math TeX delimiters \[\]test_formcalc_ajax_display_tex_delimiters_rejectedpreserves double-dollar delimiterstest_formcalc_ajax_double_dollar_delimiters_rejectedpreserves single-dollar delimiterstest_formcalc_ajax_single_dollar_delimiters_rejectedThe last 6 platform tests covered the built-in block's client-side
refreshMathrendering of formula-equation previews. That path doesn't run on master (toggleTrue) and is removed here. The extracted block renders these previews only on the server, on purpose, throughpreview_formcalcandformula_equation_preview.js(xblocks-core989ae32). So their counterparts assert what that path does for the same inputs.Changes to the kept grades tests
reset_class(), the toggle overrides and the BuiltIn twins are dropped.__test__ = Truesubclass is collapsed back intoTestMultipleProblemTypesSubsectionScores,TestVariedMetadataandTestWeightedProblems, the class names used before the toggle.Release notes: covered by the single Willow dev/op entry for all 8 blocks (Willow - Operator Dev Notes).
Epic Step 1: Post-extraction commit review
53d3d5dbdf). The 9 later commits that touched the deleted files are matched in xblocks-core 4.0.0 or later, or need nothing (details below).test_capa_block.pyexist in xblocks-core with equivalent assertions. Nothing to port.Later commits and their xblocks-core equivalents
154021763f(feat!: clean up after the local codejail removal #39429) passescan_execute_unsafe_code=lambda: Falsein the built-in block. The extracted block gets the sameFalsefrom the platform'sSandboxService.can_execute_unsafe_code, which master now hard-codes. Its removal is tracked in Dropcan_execute_unsafe_codeand theunsafelyargument xblocks-core#350.f8d6364fb4(feat!: remove the XQueue service settings, callback and the MATLAB API key #39405) removesmatlab_api_keyand theungraded_responsehandler from the built-in block. xblocks-corea30b509removes the same, and neither name remains inxblock_problem.ebe22ffce5(feat!: remove the XQueue service settings, callback and the MATLAB API key #39405) rewrites the XQueue tests intest_capa_block.py. The xblocks-core 4.0.0 copies have identical bodies (from3a99862).3ae28f70ba(feat!: remove local codejail #39382) drops@UseUnsafeCodejailfrom one test. The xblocks-core copy never used it.6f85d63c7f(feat!: replace xblocks-contrib with xblocks-core 2.0.0 #38473, the xblocks-core 2.0.0 import repoint),d1d2e7889c(removes deadFEATURES-derived assignments),49dcf8f1fc(an xblocks-contrib version bump) andcc3adbd305(jasmine-core update) need nothing ported.78b892c6e2/ feat!: upgrade to mathjax v4 #33555 (MathJax v4) changedxmodule/js/src/capa/display.js. It is already in xblocks-core through feat(mathjax): upgrade mathjax from v2 to v4 xblocks-core#270, by the same author, with the sameisMathJaxTypesetReady/isMathJaxRefreshReady/isMathJaxMathMLReadylogic. The one difference is on purpose:989ae32stopped bindingrefreshMathto formula-equation inputs.Test plan
Local Tutor nightly, because PR sandboxes aren't reachable (open-craft/pr-sandbox-automation#28). Last re-verified on 2026-12-02 on the pre-rebase head
98996f0887with the xblocks-core it pins (4.0.3); the library UI checklist last ran on 2026-11-11/12. A box is ticked only if that flow actually ran.xblock_problem.capa.safe_exec.remote_exec.send_safe_exec_request_v0; scripted and randomized problems last graded correctly on 2026-11-12 (notes below)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 buildTesting notes and edge cases
6f85d63c7f+ xblocks-core 2.0.0, through the REST APIs and a headless browser.01958417ea, after Video refactor: remove built-in Video XBlock implementation (slash-n-burn #37819) #38750 removed stubs from the samehelper.jsand deletedkarma_runner_webpack.js; both PRs' removals are kept) and the review cleanups weren't re-tested locally. CI on this head covers them.xblock_problemgets its own catalog (ar,es_419,frfully translated) and loads it at runtime; its JS strings and the codejail error messages use it too (build: extract translations per xblock for openedx-translations xblocks-core#329, Parameterize aws s3 bucket name for forum uploads #336; feat: add xblocks-core to translation extraction pipeline openedx-translations#85196).mjx-container).grades/tests/integration/test_problems.py(224 tests) passes.USE_EXTRACTED_*_BLOCK = False(built-in) and on this branch. Theproblemfiles and its unit are identical.V2 Library checklist: 10/14 pass (R1–R4 partly verified)
Content libraries have historically been the most fragile area for extracted blocks (openedx/xblocks-core#123, #132, #243, #274).
mjx-container); the library preview wasn't checked in a browserSources: the Aximprovements manual test doc (Extracted Block Tests tab), the Ulmo test sheet's library cases, and for R1–R4, the Problem testing notes on #38152. Generated using Claude Code.
Re-verification screenshots (2026-12-02, pre-rebase head `98996f0887`)
Screenshots (LMS, Studio unit, V2 Library; local Tutor, 2026-11-12)
All images: irfanuddinahmad/edx-platform@snb-smoke-screenshots/38751.
The library preview first showed a scripted problem, which rendered "Could not format HTML for problem". That isn't a regression: scripted problems need a remote codejail service on xblocks-core ≥ 3.0, which the local stack can't run (in a course or a V2 library; master behaves the same).
Settings
🤖 Generated with Claude Code