diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 68cb1238..69409012 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 diff --git a/openedx_events/__init__.py b/openedx_events/__init__.py index 977cc1ca..55536ae4 100644 --- a/openedx_events/__init__.py +++ b/openedx_events/__init__.py @@ -5,4 +5,4 @@ more information about the project. """ -__version__ = "9.0.0" +__version__ = "9.1.0" diff --git a/openedx_events/learning/data.py b/openedx_events/learning/data.py index 00c1d643..b939bfc4 100644 --- a/openedx_events/learning/data.py +++ b/openedx_events/learning/data.py @@ -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]) @@ -425,3 +425,27 @@ 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. + content_url (str): url of the content the notification will redirect to. + context_context (dict): additional information related to the content of the notification. + audience_filters (dict): additional information related to the audience of the notification. + We can have different filters on course level, such as roles, enrollments, cohorts etc. + + """ + + course_key = attr.ib(type=CourseKey) + app_name = attr.ib(type=str) + notification_type = attr.ib(type=str) + content_url = attr.ib(type=str) + content_context = attr.ib(type=dict, factory=dict) + audience_filters =attr.ib(type=dict, factory=dict) diff --git a/openedx_events/learning/signals.py b/openedx_events/learning/signals.py index 87f1885a..9ec57e0b 100644 --- a/openedx_events/learning/signals.py +++ b/openedx_events/learning/signals.py @@ -13,6 +13,7 @@ CohortData, CourseDiscussionConfigurationData, CourseEnrollmentData, + CourseNotificationData, DiscussionThreadData, ExamAttemptData, ManageStudentsPermissionData, @@ -188,7 +189,7 @@ ) # .. event_type: org.openedx.learning.user.notification.requested.v1 -# .. event_name: USER_NOTIFICATION +# .. event_name: USER_NOTIFICATION_REQUESTED # .. event_description: Can be fired from apps to send user notifications. # .. event_data: UserNotificationSendListData # Warning: This event is currently incompatible with the event bus, list/dict cannot be serialized yet @@ -312,3 +313,17 @@ "thread": DiscussionThreadData, } ) + + +# .. event_type: org.openedx.learning.course.notification.requested.v1 +# .. event_name: COURSE_NOTIFICATION_REQUESTED +# .. 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 +# +COURSE_NOTIFICATION_REQUESTED = OpenEdxPublicSignal( + event_type="org.openedx.learning.course.notification.requested.v1", + data={ + "course_notification_data": CourseNotificationData, + } +) diff --git a/openedx_events/tooling.py b/openedx_events/tooling.py index 1547428a..1171ec33 100644 --- a/openedx_events/tooling.py +++ b/openedx_events/tooling.py @@ -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" ] diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b