diff --git a/lms/djangoapps/grades/signals/handlers.py b/lms/djangoapps/grades/signals/handlers.py index 58c5fb90aace..8ed408e4d39d 100644 --- a/lms/djangoapps/grades/signals/handlers.py +++ b/lms/djangoapps/grades/signals/handlers.py @@ -8,7 +8,13 @@ from django.dispatch import receiver from opaque_keys.edx.keys import LearningContextKey -from openedx_events.learning.signals import EXAM_ATTEMPT_REJECTED, EXAM_ATTEMPT_VERIFIED +from openedx_events.learning.data import UserCourseData, CourseData, UserData, UserPersonalData +from openedx_events.learning.signals import ( + EXAM_ATTEMPT_REJECTED, + EXAM_ATTEMPT_VERIFIED, + COURSE_GRADE_NOW_PASSED as COURSE_GRADE_NOW_PASSED_PUBLIC, + COURSE_GRADE_NOW_FAILED as COURSE_GRADE_NOW_FAILED_PUBLIC, +) from submissions.models import score_reset, score_set from xblock.scorable import ScorableXBlockMixin, Score @@ -281,9 +287,25 @@ def listen_for_passing_grade(sender, user, course_id, **kwargs): # pylint: disa """ Listen for a signal indicating that the user has passed a course run. - Emits an edx.course.grade.now_passed event + Emits an edx.course.grade.now_passed event. + Emits a public event org.openedx.learning.course.grade.now.passed.v1. """ events.course_grade_now_passed(user, course_id) + # .. event_implemented_name: COURSE_GRADE_NOW_PASSED + COURSE_GRADE_NOW_PASSED_PUBLIC.send_event( + user_course_data=UserCourseData( + user=UserData( + pii=UserPersonalData( + username=user.username, email=user.email, name=user.get_full_name() + ), + id=user.id, + is_active=user.is_active, + ), + course=CourseData( + course_key=course_id, + ) + ) + ) @receiver(COURSE_GRADE_NOW_FAILED) @@ -291,9 +313,25 @@ def listen_for_failing_grade(sender, user, course_id, **kwargs): # pylint: disa """ Listen for a signal indicating that the user has failed a course run. - Emits an edx.course.grade.now_failed event + Emits an edx.course.grade.now_failed event. + Emits a public event org.openedx.learning.course.grade.now.failed.v1. """ events.course_grade_now_failed(user, course_id) + # .. event_implemented_name: COURSE_GRADE_NOW_FAILED + COURSE_GRADE_NOW_FAILED_PUBLIC.send_event( + user_course_data=UserCourseData( + user=UserData( + pii=UserPersonalData( + username=user.username, email=user.email, name=user.get_full_name() + ), + id=user.id, + is_active=user.is_active, + ), + course=CourseData( + course_key=course_id, + ) + ) + ) @receiver(COURSE_GRADE_PASSED_FIRST_TIME) diff --git a/lms/envs/common.py b/lms/envs/common.py index ed8d520660c9..6aca0ab9059a 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1047,7 +1047,7 @@ # .. toggle_use_cases: opt_in # .. toggle_creation_date: 2023-10-10 # .. toggle_tickets: https://github.com/openedx/openedx-events/issues/210 - 'SEND_LEARNING_CERTIFICATE_LIFECYCLE_EVENTS_TO_BUS': False + 'SEND_LEARNING_CERTIFICATE_LIFECYCLE_EVENTS_TO_BUS': False, } # Specifies extra XBlock fields that should available when requested via the Course Blocks API @@ -5447,6 +5447,14 @@ def _should_send_certificate_events(settings): 'course-authoring-xblock-lifecycle': {'event_key_field': 'xblock_info.usage_key', 'enabled': False}, }, + 'org.openedx.learning.course.grade.now.passed.v1': { + 'learning-grade-lifecycle': + {'event_key_field': 'user_course_data.course.course_key', 'enabled': True}, + }, + 'org.openedx.learning.course.grade.now.failed.v1': { + 'learning-grade-lifecycle': + {'event_key_field': 'user_course_data.course.course_key', 'enabled': True}, + }, } derived_collection_entry('EVENT_BUS_PRODUCER_CONFIG', 'org.openedx.learning.certificate.created.v1', 'learning-certificate-lifecycle', 'enabled') diff --git a/requirements/edx/github.in b/requirements/edx/github.in index ea6d47eec8a0..56b5b1ad6220 100644 --- a/requirements/edx/github.in +++ b/requirements/edx/github.in @@ -90,3 +90,4 @@ # django42 support PR merged but new release is pending. # https://github.com/openedx/edx-platform/issues/33431 -e git+https://github.com/anupdhabarde/edx-proctoring-proctortrack.git@31c6c9923a51c903ae83760ecbbac191363aa2a2#egg=edx_proctoring_proctortrack +-e git+https://github.com/raccoongang/openedx-events.git@aci.main#egg=openedx_events