Skip to content

Commit

Permalink
feat: add courseaccessrole events (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharis278 authored Feb 1, 2024
1 parent 0a7e448 commit 5d340fd
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Change Log
Unreleased
----------
[9.4.0] - 2024-01-29
--------------------
Added
~~~~~
* Added new ``COURSE_ACCESS_ROLE_ADDED`` and ``COURSE_ACCESS_ROLE_REMOVED`` events in learning

[9.3.0] - 2024-01-24
--------------------
Expand Down
2 changes: 1 addition & 1 deletion openedx_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
more information about the project.
"""

__version__ = "9.3.0"
__version__ = "9.4.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "CloudEvent",
"type": "record",
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "course_access_role_data",
"type": {
"name": "CourseAccessRoleData",
"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": "org_key",
"type": "string"
},
{
"name": "course_key",
"type": "string"
},
{
"name": "role",
"type": "string"
}
]
}
}
],
"namespace": "org.openedx.learning.user.course_access_role.added.v1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "CloudEvent",
"type": "record",
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "course_access_role_data",
"type": {
"name": "CourseAccessRoleData",
"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": "org_key",
"type": "string"
},
{
"name": "course_key",
"type": "string"
},
{
"name": "role",
"type": "string"
}
]
}
}
],
"namespace": "org.openedx.learning.user.course_access_role.removed.v1"
}
18 changes: 18 additions & 0 deletions openedx_events/learning/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,24 @@ class ExamAttemptData:
requesting_user = attr.ib(type=UserData, default=None)


@attr.s(frozen=True)
class CourseAccessRoleData:
"""
Attributes defined for the Open edX Course Access Role data object.
Arguments:
user (UserData): user associated with the CourseAccessRole.
course_key (CourseKey): identifer of the related course object.
org (str): identifier of the organization.
role (str): the role of the user in the course.
"""

user = attr.ib(type=UserData)
org_key = attr.ib(type=str)
course_key = attr.ib(type=CourseKey)
role = attr.ib(type=str)


@attr.s(frozen=True)
class ManageStudentsPermissionData:
"""
Expand Down
23 changes: 23 additions & 0 deletions openedx_events/learning/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from openedx_events.learning.data import (
CertificateData,
CohortData,
CourseAccessRoleData,
CourseDiscussionConfigurationData,
CourseEnrollmentData,
CourseNotificationData,
Expand Down Expand Up @@ -256,6 +257,28 @@
}
)

# .. event_type: org.openedx.learning.user.course_access_role.added.v1
# .. event_name: COURSE_ACCESS_ROLE_ADDED
# .. event_description: Emitted when a user is given a course access role.
# .. event_data: CourseAccessRoleData
COURSE_ACCESS_ROLE_ADDED = OpenEdxPublicSignal(
event_type="org.openedx.learning.user.course_access_role.added.v1",
data={
"course_access_role_data": CourseAccessRoleData,
}
)

# .. event_type: org.openedx.learning.user.course_access_role.removed.v1
# .. event_name: COURSE_ACCESS_ROLE_REMOVED
# .. event_description: Emitted when a course access role is removed from a user.
# .. event_data: CourseAccessRoleData
COURSE_ACCESS_ROLE_REMOVED = OpenEdxPublicSignal(
event_type="org.openedx.learning.user.course_access_role.removed.v1",
data={
"course_access_role_data": CourseAccessRoleData,
}
)

# .. event_type: org.openedx.learning.user.manage.students.permission.added.v1
# .. event_name: MANAGE_STUDENTS_PERMISSION_ADDED
# .. event_description: Emitted when permission to manage students within a course is given to a user.
Expand Down

0 comments on commit 5d340fd

Please sign in to comment.