Skip to content

Xq depr fc 73 add receiver#37528

Merged
ormsbee merged 1 commit intoopenedx:masterfrom
edly-io:xq-depr-fc-73-add-receiver
Dec 15, 2025
Merged

Xq depr fc 73 add receiver#37528
ormsbee merged 1 commit intoopenedx:masterfrom
edly-io:xq-depr-fc-73-add-receiver

Conversation

@UsamaSadiq
Copy link
Member

@UsamaSadiq UsamaSadiq commented Oct 23, 2025

Description

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Oct 23, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @UsamaSadiq!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

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 Oct 23, 2025
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Oct 27, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Oct 27, 2025
@UsamaSadiq UsamaSadiq force-pushed the xq-depr-fc-73-add-receiver branch 4 times, most recently from 172bd29 to cf4fdd9 Compare October 31, 2025 11:30
@rehmansheikh222 rehmansheikh222 force-pushed the xq-depr-fc-73-add-receiver branch from 754d0b1 to f3b49be Compare November 17, 2025 10:13
@UsamaSadiq UsamaSadiq force-pushed the xq-depr-fc-73-add-receiver branch from a060d23 to c09b736 Compare November 27, 2025 08:34
@UsamaSadiq UsamaSadiq marked this pull request as ready for review November 27, 2025 09:13
@kdmccormick kdmccormick removed their request for review December 3, 2025 13:42
feanil added a commit that referenced this pull request Dec 3, 2025
The latest version changes a method signature and so code here will need
to be updated before that can land. There is already a PR to pick up
that change #37528 so it
doesn't seem worth it to add the constraint so just downgrade the
package in this PR so we can land the rest of the updates.
feanil added a commit that referenced this pull request Dec 3, 2025
* chore: Upgrade Python requirements

* build: Downgrade edx-submissions for now.

The latest version changes a method signature and so code here will need
to be updated before that can land. There is already a PR to pick up
that change #37528 so it
doesn't seem worth it to add the constraint so just downgrade the
package in this PR so we can land the rest of the updates.

---------

Co-authored-by: Feanil Patel <feanil@axim.org>
@ormsbee ormsbee self-requested a review December 3, 2025 17:20
Copy link
Contributor

@ormsbee ormsbee left a comment

Choose a reason for hiding this comment

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

My apologies, this took longer than I thought it would. I ran into some things that I really didn't expect—I just wanted to check to make sure that I was reviewing the correct commits? It seems like there were some dev debug code left here (e.g. the Spanish logging, imports deep in the module, etc.

Comment on lines 383 to 389
log.info(f"---------------------> course_id: {score.course_id}")
log.info(f"---------------------> user_id: {score.user_id}")
log.info(f"---------------------> module_id: {score.module_id}")
log.info(f"---------------------> submission_id: {score.submission_id}")
log.info(f"---------------------> queue_key: {score.queue_key}")
log.info(f"---------------------> queue_name: {score.queue_name}")
log.info(f"---------------------> score reply: {grader_msg}")
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. This seems overly verbose for info-level logging.
  2. grader_msg can be arbitrarily long, right? Is it necessary to log the whole thing, as opposed to just capturing the score given?

Copy link
Contributor

Choose a reason for hiding this comment

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

This level of logging is more verbose than necessary for info and grader_msg can indeed be very large. We’ll trim this down to only the essential fields.

if isinstance(grader_msg, str):
try:
# Try to parse it as JSON if it's a string
grader_msg = json.loads(grader_msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is it if it's not a string?

Copy link
Contributor

@rehmansheikh222 rehmansheikh222 Dec 10, 2025

Choose a reason for hiding this comment

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

We kept it here as we were doing double confirmation from edx-submissions and edx-platform. Now that edx-submissions has been merged and it verifies already that grader_msg is infact a string otherwise it doesn't call this external grader event, we can safely remove this check from here.


log.info(f"---------------------> Received external grader score event: {signal}, {sender}, {score}, {kwargs}")

grader_msg = score.score_msg
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Is this a case where the event itself should be defined differently (or have an alias attribute)?

Copy link
Contributor

Choose a reason for hiding this comment

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

This event is triggered from edx-submissions and it has already been merged. For this phase, we kept the event payload aligned with the legacy XQueue structure to maintain compatibility with the existing grading flow. Once we move further in the deprecation and no longer need to mirror XQueue, we can introduce a cleaner event schema or alias fields.

'lms_key': str(score.submission_id),
'queue_name': score.queue_name
}),
'xqueue_body': json.dumps(grader_msg) if isinstance(grader_msg, dict) else grader_msg,
Copy link
Contributor

Choose a reason for hiding this comment

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

As a general thing, why do we have to guess here? If it's because of backwards compatibility, please document what grader_msg can be and why somewhere in the comments. So for instance, why would it be a string vs. a dict vs. something else.

Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we have merged edx-submissions, we know for sure we will be receiving str in grader_msg and as we would be doing json.loads before this line of code, we are safe to run json.dumps without any if else checks.

Comment on lines 37 to 38
log.exception(f"No se pudo encontrar el bloque {usage_key} en modulestore: {e}")
raise Http404(f"No se encontró el módulo {usage_key_string}") from e
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use English here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, sure

Comment on lines 56 to 57
msg = f"It {usage_key_string}"
log.error(msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Leftover debug code?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll update the error message


usage_key = UsageKey.from_string(usage_key_string)
course_key = CourseKey.from_string(course_id)
usage_key = usage_key.map_into_course(course_key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: map_into_course() shouldn't be necessary any longer, since Old Mongo courses are no longer functional for the purposes of courseware—and all SplitMongo (and later) schemes encode the course/context key into the UsageKey.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we can remove this

Comment on lines 27 to 28
usage_key = UsageKey.from_string(usage_key_string)
course_key = CourseKey.from_string(course_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to do these string -> key conversions at the boundaries where you receive the data into the system, i.e. the event parsing. Inner logic modules like this should try to have these key types as parameters.

log = logging.getLogger(__name__)


def load_xblock_for_external_grader(user_id, course_id, usage_key_string, course=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add type annotations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure

@mphilbrick211 mphilbrick211 moved this from Waiting on Author to In Eng Review in Contributions Dec 12, 2025
@ormsbee
Copy link
Contributor

ormsbee commented Dec 15, 2025

Please rebase and squash your commits, and I'll merge. Thank you.

This commit implements a comprehensive solution for test score integration in the
enhancement system along with improvements to the score rendering mechanism. Key
changes include:

- Add event handler for rendering blocks with edx-submissions scores
- Implement event-based mechanism to render XBlocks with scoring data
- Create signal handlers in handlers.py to process external grader scores
- Develop specialized XBlock loader for rendering without HTTP requests
- Add queue_key propagation across the submission pipeline
- Register submission URLs in LMS routing configuration
- Add complete docstrings to score render module for better code maintainability
- Add ADR for XBlock rendering with external grader integration
- Add openedx-events fork branch as a dependency in testing.in
- Upgrade edx submission dependency

These changes support the migration from traditional XQueue callback HTTP requests
to a more robust event-based architecture, improving performance and reliability
when processing submission scores. The included ADR documents the architectural
decision and implementation approach for this significant improvement to the
external grading workflow.
@UsamaSadiq UsamaSadiq force-pushed the xq-depr-fc-73-add-receiver branch from 8dfcbfa to 362904f Compare December 15, 2025 11:08
@ormsbee ormsbee merged commit 70ea641 into openedx:master Dec 15, 2025
65 checks passed
@github-project-automation github-project-automation bot moved this from In Eng Review to Done in Contributions Dec 15, 2025
mraman-2U pushed a commit to mraman-2U/edx-platform that referenced this pull request Dec 24, 2025
* chore: Upgrade Python requirements

* build: Downgrade edx-submissions for now.

The latest version changes a method signature and so code here will need
to be updated before that can land. There is already a PR to pick up
that change openedx#37528 so it
doesn't seem worth it to add the constraint so just downgrade the
package in this PR so we can land the rest of the updates.

---------

Co-authored-by: Feanil Patel <feanil@axim.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). 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.

6 participants