Skip to content

FC-73 Add EXTERNAL_GRADER_SCORE_SUBMITTED signal to broadcast scoring events (Feature: Add event emission for external grader scores) #292

Closed
leoaulasneo98 wants to merge 4 commits intoopenedx:masterfrom
aulasneo:XQU-44-add-signal-to-call-xqueue-callback
Closed

FC-73 Add EXTERNAL_GRADER_SCORE_SUBMITTED signal to broadcast scoring events (Feature: Add event emission for external grader scores) #292
leoaulasneo98 wants to merge 4 commits intoopenedx:masterfrom
aulasneo:XQU-44-add-signal-to-call-xqueue-callback

Conversation

@leoaulasneo98
Copy link
Copy Markdown
Contributor

@leoaulasneo98 leoaulasneo98 commented Mar 17, 2025

FC-73 Feature: Add event emission for external grader scores

⚠️ Important: This PR builds on the ExternalGraderDetail, SubmissionFile infrastructure, and the XQueueViewSet deployed in previous PRs (FC-73). Please ensure those changes are fully deployed before merging.

Description

This PR adds event emission to notify when an external grader submits a score result. When a grader submits a result and the score is successfully saved, the system now emits an event with all necessary information for the LMS to render the graded XBlock.

The implementation leverages the existing external grading workflow in the XQueueViewSet and adds a signaling layer through the EXTERNAL_GRADER_SCORE_SUBMITTED event. This change is essential to enable the gradual migration from HTTP-based callbacks (XQueue) to an event-driven approach.

Key changes:

  • Add queue_key field to the ExternalGraderDetail model to identify the source queue
  • Include queue_key in the create_external_grader_detail method
  • Emit the EXTERNAL_GRADER_SCORE_SUBMITTED event after successful score update
  • Add migration for the new queue_key field

Supporting information

This PR is part of the migration from the XQueue system to an event-based architecture for external grading. It builds upon changes implemented in previous PRs in the FC-73 project that have already established:

  • The ExternalGraderDetail model for storing external grading details
  • The XQueueViewSet to provide compatible endpoints for external graders

Testing instructions

  • Set up an environment with edx-submissions and external grading models
  • Verify that the EXTERNAL_GRADER_SCORE_SUBMITTED event is correctly emitted when:
    • A POST request is made to the put_result endpoint
    • The result is validated correctly
    • The score is successfully saved
  • Check that the event contains all required fields
  • Verify that log entries correctly reflect event emission

Deadline

None

Other information

This PR completes the event emission architecture for the external grading workflow. With this implementation, event consumers in the LMS can now react to scores submitted by external graders without relying on HTTP callbacks.

Dependencies

This PR directly depends on previous PRs in the FC-73 series that implemented:

  • The ExternalGraderDetail and SubmissionFile models
  • The XQueueViewSet with its endpoints for interaction with external graders

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Mar 17, 2025
@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @leoaulasneo98!

This repository is currently maintained by @openedx/committers-edx-submissions.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Mar 17, 2025
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Mar 17, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.89%. Comparing base (98be5fc) to head (4602624).
⚠️ Report is 22 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #292      +/-   ##
==========================================
+ Coverage   94.79%   95.89%   +1.09%     
==========================================
  Files          18       21       +3     
  Lines        2423     2828     +405     
  Branches       99      117      +18     
==========================================
+ Hits         2297     2712     +415     
+ Misses        115      106       -9     
+ Partials       11       10       -1     
Flag Coverage Δ
unittests 95.89% <100.00%> (+1.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leoaulasneo98 leoaulasneo98 force-pushed the XQU-44-add-signal-to-call-xqueue-callback branch 3 times, most recently from e9eb42d to c2d51fb Compare March 17, 2025 18:17
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Mar 19, 2025
@leoaulasneo98 leoaulasneo98 force-pushed the XQU-44-add-signal-to-call-xqueue-callback branch 4 times, most recently from bb76448 to 92126be Compare March 27, 2025 15:06
@gabrielC1409 gabrielC1409 force-pushed the XQU-44-add-signal-to-call-xqueue-callback branch 2 times, most recently from 92126be to 9d61a74 Compare May 12, 2025 17:24
@angonz
Copy link
Copy Markdown

angonz commented May 19, 2025

@ormsbee if you don't disagree we would be merging this PR into #287, as it's quite smaller. This would simplify code review and make two PRs into one.

@ormsbee
Copy link
Copy Markdown
Contributor

ormsbee commented May 19, 2025

If you feel that they're too intertwined to review separately, then I'm okay with it. But I would prefer to review separately. At a glance, their functionality is different enough, and even the smaller one is about a thousand lines of code--which is plenty large enough for a pull request.

leoaulasneo98 and others added 3 commits May 20, 2025 09:21
  - Add XqueueViewSet with complete xqueue-watcher service compatibility
  - Implement get_submission service for retrieving pending submissions
  - Add put_result service with row-level locking (select_for_update(nowait=True)) to prevent race conditions
  - Ensure concurrent xqueue-watcher instances process each submission exactly once, even under high load
  - Implement standardized response format for backward compatibility
  - Add session management and authentication handling for XWatcher clients
  - Add comprehensive test coverage for core interactions
…nd add timeout mechanism (Get Submission)

- Implemented locking to ensure submissions are processed by a single xqueue watcher.
- Added timeout mechanism for submissions stuck in 'pulled' state.
- Updated tests to cover new error scenarios and timeout handling.
- Renamed variables from 'submission_record' to 'external_grader' throughout the
  codebase for better consistency with model naming
- Added new 'retry' status to integrate with submission processing retry services
- Removed unused 'is_processable' method that wasn't providing any value
- Enhanced test coverage
- Add new status external grader detail migration
@leoaulasneo98 leoaulasneo98 force-pushed the XQU-44-add-signal-to-call-xqueue-callback branch from 709aba0 to 07dc74f Compare May 21, 2025 19:01
This commit adds the EXTERNAL_GRADER_SCORE_SUBMITTED event emission to the
put_result endpoint in the XQueueViewSet. When a grader submits a result and
the score is successfully saved, the system now emits an event with all the
necessary information for the LMS to render the graded XBlock.

Key changes:
- Add queue_key field to ExternalGraderDetail model
- Include queue_key in create_external_grader_detail method
- Emit EXTERNAL_GRADER_SCORE_SUBMITTED event after successful score update
- Implement robust false to propagate error and put submission in pending queue again
- Add migration for the new queue_key field
- Add openedx-events dependency

This enables the event-driven approach for updating XBlocks with scoring data
from the edx-submissions service, supporting the gradual migration away from
HTTP-based XQueue callbacks.
@UsamaSadiq
Copy link
Copy Markdown
Member

This PR can be closed now as the superseeding PR has been merged with these changes in the repository.

@UsamaSadiq UsamaSadiq closed this Nov 27, 2025
@github-project-automation github-project-automation bot moved this from Waiting on Author to Done in Contributions Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants