Extract Problem XBlock
Tasks
- [x] (Irtaza) Extracted
ProblemBlockand related files fromxmodule.capaintoxblocks_contrib/problem. - [x] (Irtaza) Created PR in
xblocks-contrib: #63 - [x] (Irtaza) Created integration PR in
edx-platform: #37136 - [x] (Salman ) Replace edx-platform–specific services (e.g., xqueue, submissions, grading, user state) with runtime service interfaces or injectable hooks in
xblocks-contrib. - [x] ( ) Audit and refactor
student_view,studio_view, and all templates to remove LMS-specific assumptions (context variables, Django settings, static paths, etc.). - [x] (Salman) Update and ensure all unit tests in xblocks_contrib/problem/capa/ pass independently, using mock services or fixtures where needed.#69
- [x] ( Salman) Remove unused or legacy files from
xblocks_contrib.problem.capa; ensure no references remain toxmodule,modulestore, or other platform-only components. - [x] (Irtaza) Update and ensure all unit tests in
xblocks_contrib/problem/tests/pass independently, using mock services or fixtures where needed. - [x] ( ) Triage and fix all test failures caused by PR #37136; update import paths, settings, or runtime behavior as required.
- [ ] ( ) Add fallback behavior for platform-specific features (e.g., attempt tracking, scoring logic, user progress) to avoid breaking edx-platform unit tests.
- [ ] ( ) Confirm all edx-platform unit tests pass with the external Problem XBlock, and the integration PR is ready for merge.
@irtazaakram I think it would be helpful to create the sub-tasks in the xblocks-contrib repository and share their links here, as our current assessment suggests these tasks will take some time to complete. @feanil your thoughts will be appreciated.
For the replacement of the edx-platform specific services, be aware that the xqueue service is being replaced so it may be worth looking at where that work is and working with the people doing that work.
Step 1: Clean Up in edx-platform
- [ ] Format all Python files with
blackandisort - [ ] Format all CSS, JS, HTML, YAML files with the right tools (
prettier,djlint, etc.) - [ ] Fix pylint warnings and errors
- [ ] Convert all problem block mako templates to Django templates
- [ ] Convert old JavaScript to ES6+ syntax for all problem block related JS files
Step 2: Move to xblocks-contrib/problem
- [ ] Make one PR that only moves files (no logic changes, only path updates)
- [ ] Make a new PR against the first branch for a second PR for only fixes or improvements to make it work
notes from Feanil's and my dive into the problemblock code today. happy to explain them later.
- We think we need to bring some exception classes upstream, to the XBlock library, or xblocks-contrib at the very least. The ProblemBlock raises both ProcessingError and NotFoundError from edx-platform, which it cannot reference once it's extracted. With regards to existing
exceptreferences to those in edx-platform...- All
except ProcessingErroroccurrences could be replaced with the upstream exception. - Some
except NotFoundErroroccurrences are coming from modulestore/contentstore, so we can't just remove those. Instead, we'd add additionalexceptblocks for the upstream exception in the places that are needed. I only see three such places: block_render.py, preview.py, and the import system.
- All
The only reference to xmodule.graders is ShowCorrectness. I think we can move that up to xblock.
SandboxSerivce class reference should probably be replaced with self.service(...)
Same with XQueueService
xmodule.fields get moved into XBlock?
Progress object should be moved into XBlock
Flags:
- ENABLE_XBLOCK_XML_VALIDATION can be fast-track depr'd.
- ENABLE_GRADING_METHOD_IN_PROBLEMS, added by https://github.com/openedx/edx-platform/pull/33911, can be removed and its behavior can be made default.
- The reference to
settings.DEBUGcan be removed. The is_author_mode logic is good enough.
ProblemBlockEditor JS is deprecated and does not need to be ported (same thing for HTML and Video editor JS)
Test advanced features of problemblock, including:
- Custom Python-evaluated problems: https://docs.openedx.org/en/latest/educators/concepts/exercise_tools/about_custom_python_problem.html
- jsinput problems: https://docs.openedx.org/en/latest/educators/references/course_development/exercise_tools/custom_javascript.html
- Multipart problems: https://docs.openedx.org/en/latest/educators/olx/components/problem-components.html#multiple-problems-in-one-component
- python_lib.zip, e.g.: https://mitodl.github.io/mitx-grading-library/
- Externally graded problems: https://docs.openedx.org/en/latest/educators/how-tos/course_development/exercise_tools/add_external_grader.html
- Might need to set up a mock queue in order to test
Remember to continue using random2 in the places where it's currently used. The purpose of this is to keep problem answer order stable, which is important for grading.