Skip to content

Commit

Permalink
feat: [ACI-510, ACI-511, ACI-512] new events and dataclass for ccx co…
Browse files Browse the repository at this point in the history
…urse (#5)

* feat: [ACI-512] describe ccx course payload dataclass

* feat: [ACI-510] define ccx-course-grade-passed signal

* feat: [ACI-511] define ccx-course-grade-failed signal

* feat: [ACI-510, ACI-511, ACI-512] new events and dataclass for ccx course

* style: [ACI-512] fix line-too-long and trailing-whitespace

---------

Co-authored-by: Andrii <[email protected]>
  • Loading branch information
2 people authored and wowkalucky committed Mar 26, 2024
1 parent 52f06da commit ca46345
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"name": "CloudEvent",
"type": "record",
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "ccx_course",
"type": {
"name": "CcxCourseData",
"type": "record",
"fields": [
{
"name": "course_key",
"type": "string"
},
{
"name": "master_course_key",
"type": "string"
},
{
"name": "max_students_allowed",
"type": "long"
},
{
"name": "coach",
"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": "display_name",
"type": "string"
},
{
"name": "start",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "end",
"type": [
"null",
"string"
],
"default": null
}
]
}
}
],
"namespace": "org.openedx.learning.ccx.course.grade.now.failed.v1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"name": "CloudEvent",
"type": "record",
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "ccx_course",
"type": {
"name": "CcxCourseData",
"type": "record",
"fields": [
{
"name": "course_key",
"type": "string"
},
{
"name": "master_course_key",
"type": "string"
},
{
"name": "max_students_allowed",
"type": "long"
},
{
"name": "coach",
"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": "display_name",
"type": "string"
},
{
"name": "start",
"type": [
"null",
"string"
],
"default": null
},
{
"name": "end",
"type": [
"null",
"string"
],
"default": null
}
]
}
}
],
"namespace": "org.openedx.learning.ccx.course.grade.now.passed.v1"
}
21 changes: 21 additions & 0 deletions openedx_events/learning/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,24 @@ class BadgeData:
uuid = attr.ib(type=str)
user = attr.ib(type=UserData)
template = attr.ib(type=BadgeTemplateData)


@attr.s(frozen=True)
class CcxCourseData(CourseData):
"""
Attributes defined fir the Open edX custom course data object.
Arguments:
master_course_key (str): identifier of the master Course object.
max_students_allowed (int): maximum number of students allowed on the custom course
coach (UserData): coach associated with the custom course
"""

master_course_key = attr.ib(type=CourseKey)
max_students_allowed = attr.ib(type=int)
coach = attr.ib(type=UserData)

# copypasted from CourseData to avoid ValueError
display_name = attr.ib(type=str, factory=str)
start = attr.ib(type=datetime, default=None)
end = attr.ib(type=datetime, default=None)
25 changes: 25 additions & 0 deletions openedx_events/learning/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from openedx_events.learning.data import (
BadgeData,
CcxCourseData,
CertificateData,
CohortData,
CourseAccessRoleData,
Expand Down Expand Up @@ -383,3 +384,27 @@
"badge": BadgeData,
}
)


# .. event_type: org.openedx.learning.ccx.course.grade.now.passed.v1
# .. event_name: CCX_COURSE_GRADE_NOW_PASSED
# .. event_description: Emit when a ccx course grade is passed
# .. event_data: CcxCourseData
CCX_COURSE_GRADE_NOW_PASSED = OpenEdxPublicSignal(
event_type="org.openedx.learning.ccx.course.grade.now.passed.v1",
data={
"ccx_course": CcxCourseData,
}
)


# .. event_type: org.openedx.learning.ccx.course.grade.now.failed.v1
# .. event_name: CCX_COURSE_GRADE_NOW_FAILED
# .. event_description: Emit when a ccx course grade is failed
# .. event_data: CcxCourseData
CCX_COURSE_GRADE_NOW_FAILED = OpenEdxPublicSignal(
event_type="org.openedx.learning.ccx.course.grade.now.failed.v1",
data={
"ccx_course": CcxCourseData,
}
)

0 comments on commit ca46345

Please sign in to comment.