diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+course+grade+now+failed+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+course+grade+now+failed+v1_schema.avsc new file mode 100644 index 00000000..ade981c8 --- /dev/null +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+course+grade+now+failed+v1_schema.avsc @@ -0,0 +1,88 @@ +{ + "name": "CloudEvent", + "type": "record", + "doc": "Avro Event Format for CloudEvents created with openedx_events/schema", + "fields": [ + { + "name": "user_course_data", + "type": { + "name": "UserCourseData", + "type": "record", + "fields": [ + { + "name": "user", + "type": { + "name": "UserData", + "type": "record", + "fields": [ + { + "name": "id", + "type": "long" + }, + { + "name": "is_active", + "type": "boolean" + }, + { + "name": "pii", + "type": { + "name": "UserPersonalData", + "type": "record", + "fields": [ + { + "name": "username", + "type": "string" + }, + { + "name": "email", + "type": "string" + }, + { + "name": "name", + "type": "string" + } + ] + } + } + ] + } + }, + { + "name": "course", + "type": { + "name": "CourseData", + "type": "record", + "fields": [ + { + "name": "course_key", + "type": "string" + }, + { + "name": "display_name", + "type": "string" + }, + { + "name": "start", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "end", + "type": [ + "null", + "string" + ], + "default": null + } + ] + } + } + ] + } + } + ], + "namespace": "org.openedx.learning.course.grade.now.failed.v1" +} \ No newline at end of file diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+course+grade+now+passed+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+course+grade+now+passed+v1_schema.avsc new file mode 100644 index 00000000..19534cab --- /dev/null +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+course+grade+now+passed+v1_schema.avsc @@ -0,0 +1,88 @@ +{ + "name": "CloudEvent", + "type": "record", + "doc": "Avro Event Format for CloudEvents created with openedx_events/schema", + "fields": [ + { + "name": "user_course_data", + "type": { + "name": "UserCourseData", + "type": "record", + "fields": [ + { + "name": "user", + "type": { + "name": "UserData", + "type": "record", + "fields": [ + { + "name": "id", + "type": "long" + }, + { + "name": "is_active", + "type": "boolean" + }, + { + "name": "pii", + "type": { + "name": "UserPersonalData", + "type": "record", + "fields": [ + { + "name": "username", + "type": "string" + }, + { + "name": "email", + "type": "string" + }, + { + "name": "name", + "type": "string" + } + ] + } + } + ] + } + }, + { + "name": "course", + "type": { + "name": "CourseData", + "type": "record", + "fields": [ + { + "name": "course_key", + "type": "string" + }, + { + "name": "display_name", + "type": "string" + }, + { + "name": "start", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "end", + "type": [ + "null", + "string" + ], + "default": null + } + ] + } + } + ] + } + } + ], + "namespace": "org.openedx.learning.course.grade.now.passed.v1" +} \ No newline at end of file diff --git a/openedx_events/learning/data.py b/openedx_events/learning/data.py index 39bfb24f..0e713650 100644 --- a/openedx_events/learning/data.py +++ b/openedx_events/learning/data.py @@ -469,3 +469,17 @@ class CourseNotificationData: content_url = attr.ib(type=str) content_context = attr.ib(type=dict, factory=dict) audience_filters = attr.ib(type=dict, factory=dict) + + +@attr.s(frozen=True) +class UserCourseData: + """ + Attributes defined for Open edX user course data object. + + Arguments: + user (UserData): user associated with the Course Enrollment. + course (CourseData): course where the user is enrolled in. + """ + + user = attr.ib(type=UserData) + course = attr.ib(type=CourseData) diff --git a/openedx_events/learning/signals.py b/openedx_events/learning/signals.py index 9ec57e0b..41c4ba68 100644 --- a/openedx_events/learning/signals.py +++ b/openedx_events/learning/signals.py @@ -22,6 +22,7 @@ UserData, UserNotificationData, XBlockSkillVerificationData, + UserCourseData, ) from openedx_events.tooling import OpenEdxPublicSignal @@ -327,3 +328,25 @@ "course_notification_data": CourseNotificationData, } ) + +# .. event_type: org.openedx.learning.course.grade.now.passed.v1 +# .. event_name: COURSE_GRADE_NOW_PASSED +# .. event_description: Emmited when course grade is passed. +# .. event_data: UserCourseData +COURSE_GRADE_NOW_PASSED = OpenEdxPublicSignal( + event_type="org.openedx.learning.course.grade.now.passed.v1", + data={ + "user_course_data": UserCourseData, + } +) + +# .. event_type: org.openedx.learning.course.grade.now.failed.v1 +# .. event_name: COURSE_GRADE_NOW_FAILED +# .. event_description: Emmited when course grade is failed. +# .. event_data: UserCourseData +COURSE_GRADE_NOW_FAILED = OpenEdxPublicSignal( + event_type="org.openedx.learning.course.grade.now.failed.v1", + data={ + "user_course_data": UserCourseData, + } +)