edx-platform icon indicating copy to clipboard operation
edx-platform copied to clipboard

Extract Problem XBlock

Open irtazaakram opened this issue 9 months ago • 12 comments

Tasks

  • [x] (Irtaza) Extracted ProblemBlock and related files from xmodule.capa into xblocks_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 to xmodule, 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 avatar Apr 17 '25 11:04 irtazaakram

@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.

farhan avatar Aug 12 '25 11:08 farhan

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.

feanil avatar Aug 13 '25 18:08 feanil

Step 1: Clean Up in edx-platform

  • [ ] Format all Python files with black and isort
  • [ ] 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

irtazaakram avatar Oct 15 '25 11:10 irtazaakram

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 except references to those in edx-platform...
    • All except ProcessingError occurrences could be replaced with the upstream exception.
    • Some except NotFoundError occurrences are coming from modulestore/contentstore, so we can't just remove those. Instead, we'd add additional except blocks 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.

kdmccormick avatar Dec 11 '25 20:12 kdmccormick

The only reference to xmodule.graders is ShowCorrectness. I think we can move that up to xblock.

kdmccormick avatar Dec 11 '25 20:12 kdmccormick

SandboxSerivce class reference should probably be replaced with self.service(...)

Same with XQueueService

kdmccormick avatar Dec 11 '25 20:12 kdmccormick

xmodule.fields get moved into XBlock?

kdmccormick avatar Dec 11 '25 20:12 kdmccormick

Progress object should be moved into XBlock

kdmccormick avatar Dec 11 '25 20:12 kdmccormick

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.DEBUG can be removed. The is_author_mode logic is good enough.

kdmccormick avatar Dec 11 '25 20:12 kdmccormick

ProblemBlockEditor JS is deprecated and does not need to be ported (same thing for HTML and Video editor JS)

kdmccormick avatar Dec 11 '25 20:12 kdmccormick

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

kdmccormick avatar Dec 11 '25 20:12 kdmccormick

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.

kdmccormick avatar Dec 11 '25 21:12 kdmccormick