feat: add event handler webhook for certificate generation#684
Merged
arslanashraf7 merged 3 commits intomainfrom May 6, 2026
Merged
feat: add event handler webhook for certificate generation#684arslanashraf7 merged 3 commits intomainfrom
arslanashraf7 merged 3 commits intomainfrom
Conversation
28a4c7c to
a888144
Compare
4147f90 to
10ebbf8
Compare
2 tasks
10ebbf8 to
4dfb64e
Compare
597b018 to
1a95d49
Compare
2e81fbf to
3ceb8a4
Compare
85c6e80 to
e0d4007
Compare
Anas12091101
approved these changes
May 4, 2026
Contributor
Anas12091101
left a comment
There was a problem hiding this comment.
Tested E2E. LGTM 👍
Just a couple of small changes
Comment on lines
+7
to
+10
| * Migrated certificate webhook handling from ``ol_openedx_event_bridge``. | ||
| * Added LMS receiver for ``COURSE_GRADE_NOW_PASSED`` to trigger certificate | ||
| creation callbacks in MIT systems. | ||
| * Added backward-compatible support for legacy certificate-related env tokens. |
Contributor
There was a problem hiding this comment.
I believe that only the second point is valid here.
| """ | ||
| Determine whether certificate generation should be triggered. | ||
| """ | ||
| enrollment_mode, _ = CourseEnrollment.enrollment_mode_for_user(user, course_id) |
Contributor
There was a problem hiding this comment.
enrollment_mode_for_user also returns an is_active flag. We should include an is_active check here to ensure certificates are not created for inactive enrollments.
Suggested change
| enrollment_mode, _ = CourseEnrollment.enrollment_mode_for_user(user, course_id) | |
| enrollment_mode, is_active = CourseEnrollment.enrollment_mode_for_user(user, course_id) | |
| if not is_active: | |
| return False |
e0d4007 to
c19b825
Compare
Contributor
Author
|
@Anas12091101 FYI, I've reduced the task retry count to 2, so the tasks will run a total of 3 times now. Once at start and twice at the retry. I've done this in e6fca7b. I'll merge the PR once the CI checks are green. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for handling certificate creation webhooks when a learner passes a course in the Open edX LMS. The main changes add a new signal handler for the
COURSE_GRADE_NOW_PASSEDevent, which triggers a Celery task to notify an external system to create a certificate. Configuration options and tests for the new functionality are also included.Certificate Webhook Integration:
listen_for_passing_grade) for theCOURSE_GRADE_NOW_PASSEDevent, which checks certificate eligibility and dispatches a webhook notification when a learner passes a course. (ol_openedx_events_handler/receivers/certificate_passing_receiver.py, [1] [2] [3] [4]create_certificate_for_passing_grade) to send a POST request to the configured certificate webhook endpoint, including error handling and retry logic. (ol_openedx_events_handler/tasks/certificate_passing.py, src/ol_openedx_events_handler/ol_openedx_events_handler/tasks/certificate_passing.pyR1-R80)ol_openedx_events_handler/utils.py, src/ol_openedx_events_handler/ol_openedx_events_handler/utils.pyR37-R65)Configuration and Documentation:
CERTIFICATE_WEBHOOK_URL,CERTIFICATE_WEBHOOK_ACCESS_TOKEN) with support for environment token overrides, and documented their usage in the README. (ol_openedx_events_handler/settings/common.py, [1];ol_openedx_events_handler/settings/production.py, [2];README.rst, [3]CHANGELOG.rst, [1];pyproject.toml, [2]Testing:
tests/test_certificate_passing_receiver.py, [1];tests/test_certificate_passing_tasks.py, [2]These changes enable automated certificate creation workflows integrated with external systems upon course completion.### What are the relevant tickets?
https://github.com/mitodl/hq/issues/9693, https://github.com/mitodl/hq/issues/10267
Description (What does it do?)
Screenshots (if appropriate):
How can this be tested?
NOTE: Will be tested along with the counterpart mitodl/mitxonline#3459
CERTIFICATE_WEBHOOK_URL(This is the API URL of the API from MITx Online) andCERTIFICATE_WEBHOOK_ACCESS_TOKEN(This is the staff token from your MITx Online instance)Immediately upon passingand pass the user in the course, the certificate webhook should be called, and a certificate should be created in MITx OnlineImmediately upon passing, and the webhook should not be called.Additional Context
Will be tested along with the counterpart mitodl/mitxonline#3459