Skip to content

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)

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.

'publish': EventPublishingService(user, course_id, track_function),
'enrollments': EnrollmentsService(),
'video_config': VideoConfigService(),
'xqueue': XQueueService
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'xqueue': XQueueService
'xqueue': XQueueService,

suggestion-- add a trailing comma

question-- will the runtime automatically construct this with the correct block parameter?

Copy link
Member Author

@irtazaakram irtazaakram Feb 11, 2026

Choose a reason for hiding this comment

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

I am not sure how to test it, Still figuring it out. I was hoping that since 'i18n': XBlockI18nService, is supposed to be working and also has block as argument def __init__(self, block=None):, 'xqueue': XQueueService, should work?

Copy link
Contributor

Choose a reason for hiding this comment

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

Add print statements below the dictionaries and check if they added successfully.
Also see the logs while testing

@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

SEND_TO_SUBMISSION_COURSE_FLAG = CourseWaffleFlag("send_to_submission_course.enable", __name__)


class XQueueService:
Copy link
Contributor

Choose a reason for hiding this comment

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

As part of the ambition to remove xmodule, we should plan to move the Capa block code—that will stay reside in the platform—to a new dedicated location, either now or in a future phase.

We can create a new Django app inside core to house it.

return block


@pytest.mark.django_db
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to add these declarations now and it was not needed before?

'publish': EventPublishingService(user, course_id, track_function),
'enrollments': EnrollmentsService(),
'video_config': VideoConfigService(),
'xqueue': XQueueService
Copy link
Contributor

Choose a reason for hiding this comment

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

Add print statements below the dictionaries and check if they added successfully.
Also see the logs while testing

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants