Skip to content

Use runtime-provided XQueueService instead of constructing it in ProblemBlock#37998

Open
irtazaakram wants to merge 3 commits intomasterfrom
XQueueService
Open

Use runtime-provided XQueueService instead of constructing it in ProblemBlock#37998
irtazaakram wants to merge 3 commits intomasterfrom
XQueueService

Conversation

@irtazaakram
Copy link
Member

@irtazaakram irtazaakram commented Feb 10, 2026

This PR updates ProblemBlock to request XQueueService via the XBlock runtime (self.runtime.service(self, "xqueue")) instead of directly constructing it inside the block and moves XQueueService from xmodule/capa/xqueue_interface.py to xmodule/services.py

This aligns with the standard service pattern and allows the Problem XBlock to live in xblocks-contrib/problem without copying the XQueueService implementation into that repo.

TESTING

OLX for sample question:

<problem>
  <coderesponse queuename="openedx">
    <label>Type "Hello World" in the box below.</label>
    <textbox rows="3" cols="80" mode="text" tabsize="4"/>
    <codeparam>
      <initial_display>Hello ...</initial_display>
      <grader_payload>{"check": "hello_match"}</grader_payload>
    </codeparam>
  </coderesponse>
  <solution>
    <div class="detailed-solution"><p>Type exactly: Hello World</p></div>
  </solution>
</problem>

Mock Grader Script:

mock_grader.py

How to run this:

STEP 1: GET CREDENTIALS

Run this in your terminal:
tutor config printvalue XQUEUE_AUTH_PASSWORD

STEP 2: PREPARE SCRIPT

IN mock_grader.py. Update the XQUEUE_PASS variable with the password from Step 1.

FOR TUTOR DEV SETUP:

STEP 3: COPY SCRIPT TO CONTAINER & EXECUTE SCRIPT

Run this command (replace tutor_main_dev-lms-1 with your actual LMS container name if different):
docker cp mock_grader.py tutor_main_dev-lms-1:/tmp/mock_grader.py

Run this command to start the interactive grader:
tutor dev exec lms python /tmp/mock_grader.py

FOR TUTOR LOCAL SETUP:

STEP 3: EXECUTE SCRIPT

Run this command:
python mock_grader.py

STEP 5: TEST

  1. Go to the LMS browser.
  2. Submit an answer to the problem.
  3. Look at your terminal. The script will show the student's answer.
  4. Enter a score (e.g., 1.0 for correct, 0.0 for incorrect).
  5. Enter feedback message.
  6. Check LMS to see the grade appear.
Screen.Recording.2026-02-11.at.3.41.12.PM.mov

Related to #36538
Reference openedx/xblocks-contrib#151 (comment)
Testing Instructions for both xqueue and edx-submission: https://gist.github.com/irtazaakram/37299e341876d4798c93f8e5ab8ab1f2

Copy link
Member

@kdmccormick kdmccormick left a comment

Choose a reason for hiding this comment

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

the code looks good to me 👍🏻 please have another team member look at it too.

could you manually test this? To be honest, I'm not sure exactly how to set up testing for external grading, but I'll ask around.

@kdmccormick
Copy link
Member

kdmccormick commented Feb 10, 2026

Dave O tells me that @UsamaSadiq would probably be the most knowledgable person for how to manually test this. Usama, do you mind giving Irtaza pointers on how he could manually changes to the XQueueService class?

I know that we're in the middle of migrating from the XQueue microservice to the in-process edx-submissions backend, and that both are currently supported. My understanding is that the XQueueService class delegates to either one, based on the waffle flag. So we should only need to test one of the backends (xqueue or edx-submissions) in order to validate this PR--whichever backend is easier to set up.

@irtazaakram
Copy link
Member Author

I added some instructions to the PR description on how to test the XQueue Service locally using tutor dev and tutor local. I’ll follow up with @UsamaSadiq to discuss the testing details further.

Copy link
Contributor

@farhan farhan left a comment

Choose a reason for hiding this comment

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

All seems good,
As per discussion please create a .rst document, how to test it and add its link in the class docs of XQueueService

@irtazaakram irtazaakram moved this to 👀 In review in Aximprovements Team Feb 12, 2026
@irtazaakram irtazaakram self-assigned this Feb 12, 2026
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Aximprovements Team Feb 12, 2026
@irtazaakram irtazaakram reopened this Feb 12, 2026
@irtazaakram irtazaakram moved this from ✅ Done to 👀 In review in Aximprovements Team Feb 12, 2026
@irtazaakram
Copy link
Member Author

@kdmccormick Tested locally with help from @UsamaSadiq and @rehmansheikh222.
Testing notes for XQueue + submissions: https://gist.github.com/irtazaakram/37299e341876d4798c93f8e5ab8ab1f2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

3 participants