Skip to content

Commit

Permalink
feat: add event for course wide notification request
Browse files Browse the repository at this point in the history
  • Loading branch information
SaadYousaf authored and SaadYousaf committed Oct 30, 2023
1 parent 6e7dbd2 commit 79c78f9
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Change Log
Unreleased
----------

[9.1.0] - 2023-10-04
--------------------
Added
~~~~~~~
* Added new ``COURSE_NOTIFICATION_REQUESTED`` event in learning

[9.0.0] - 2023-10-04
--------------------
Changed
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.0.0"
__version__ = "9.1.0"
26 changes: 23 additions & 3 deletions openedx_events/learning/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ class UserNotificationData:
Attributes defined for Open edX User Notification data object.
Arguments:
user_ids (List(int)): identifier of the user to which the notification belongs.
user_ids (List(int)): identifier of the users to which the notification belongs.
notification_type (str): type of the notification.
context (dict): additional structured information about the context in
which this topic is used, such as the section, subsection etc.
content_url (str): url of the content.
app_name (str): name of the app.
course_key (str): identifier of the Course object.
context (dict): additional structured information about the context of the notification.
"""

user_ids = attr.ib(type=List[int])
Expand Down Expand Up @@ -425,3 +425,23 @@ class DiscussionThreadData:
user_course_roles = attr.ib(type=List[str], factory=list)
user_forums_roles = attr.ib(type=List[str], factory=list)
options = attr.ib(type=dict, factory=dict)


@attr.s(frozen=True)
class CourseNotificationData:
"""
Attributes defined for Open edX Course Notification data object.
Arguments:
course_key (str): identifier of the Course object.
app_name (str): name of the app requesting the course notification.
notification_type (str): type of the notification.
context (dict): additional structured information context of the course notification.
content_url (str): url of the content the notification will redirect to.
"""

course_key = attr.ib(type=CourseKey)
app_name = attr.ib(type=str)
notification_type = attr.ib(type=str)
content_url = attr.ib(type=str)
context = attr.ib(type=dict, factory=dict)
15 changes: 15 additions & 0 deletions openedx_events/learning/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
CohortData,
CourseDiscussionConfigurationData,
CourseEnrollmentData,
CourseNotificationData,
DiscussionThreadData,
ExamAttemptData,
ManageStudentsPermissionData,
Expand Down Expand Up @@ -312,3 +313,17 @@
"thread": DiscussionThreadData,
}
)


# .. event_type: org.openedx.learning.course.notification.requested.v1
# .. event_name: USER_NOTIFICATION
# .. event_description: Emitted when a notification is requested for a course
# .. event_data: CourseNotificationData
# Warning: This event is currently incompatible with the event bus, list/dict cannot be serialized yet
#
USER_NOTIFICATION_REQUESTED = OpenEdxPublicSignal(
event_type="org.openedx.learning.course.notification.requested.v1",
data={
"course_notification_data": CourseNotificationData,
}
)
1 change: 1 addition & 0 deletions openedx_events/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"org.openedx.learning.thread.created.v1",
"org.openedx.learning.response.created.v1",
"org.openedx.learning.comment.created.v1",
"org.openedx.learning.course.notification.requested.v1"
]


Expand Down
Empty file added tests/__init__.py
Empty file.

0 comments on commit 79c78f9

Please sign in to comment.