Skip to content

Commit

Permalink
feat: [ACI-75] new public events
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrylo-kh committed Jan 12, 2024
1 parent 1a5f9ca commit cd8bdd8
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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"
}
14 changes: 14 additions & 0 deletions openedx_events/learning/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
23 changes: 23 additions & 0 deletions openedx_events/learning/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
UserData,
UserNotificationData,
XBlockSkillVerificationData,
UserCourseData,
)
from openedx_events.tooling import OpenEdxPublicSignal

Expand Down Expand Up @@ -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,
}
)

0 comments on commit cd8bdd8

Please sign in to comment.