From 9482fa22c0c79ddcb920d92b8a86d8479e64f4e9 Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Thu, 28 Sep 2023 15:01:56 -0500 Subject: [PATCH] feat: create event for discussion events --- openedx_events/learning/data.py | 28 ++++++++++++++++++++++++++++ openedx_events/learning/signals.py | 13 +++++++++++++ 2 files changed, 41 insertions(+) diff --git a/openedx_events/learning/data.py b/openedx_events/learning/data.py index 7e5d2f26..4c68e283 100644 --- a/openedx_events/learning/data.py +++ b/openedx_events/learning/data.py @@ -296,3 +296,31 @@ class ProgramCertificateData: status = attr.ib(type=str) url = attr.ib(type=str) certificate_available_date = attr.ib(type=datetime, default=None) + + +@attr.s(frozen=True) +class DiscussionThreadData: + """ + Attributes defined for Open edX Discussion Thread data object. + + Arguments: + + """ + + anonymous = attr.ib(type=bool) + anonymous_to_peers = attr.ib(type=bool) + body = attr.ib(type=str) + category_id = attr.ib(type=int) + category_name = attr.ib(type=str) + commentable_id = attr.ib(type=str) + group_id = attr.ib(type=int) + id = attr.ib(type=int) + options = attr.ib(type=dict) + team_id = attr.ib(type=int) + thread_type = attr.ib(type=str) + title = attr.ib(type=str) + title_truncated = attr.ib(type=bool) + truncated = attr.ib(type=bool) + url = attr.ib(type=str) + user_course_roles = attr.ib(type=List[str]) + user_forums_roles = attr.ib(type=List[str]) diff --git a/openedx_events/learning/signals.py b/openedx_events/learning/signals.py index 5c139937..87a34775 100644 --- a/openedx_events/learning/signals.py +++ b/openedx_events/learning/signals.py @@ -13,6 +13,7 @@ CohortData, CourseDiscussionConfigurationData, CourseEnrollmentData, + DiscussionThreadData, PersistentCourseGradeData, ProgramCertificateData, UserData, @@ -196,3 +197,15 @@ "notification_data": UserNotificationData, } ) + +# .. event_type: org.openedx.learning.thread.created.v1 +# .. event_name: THREAD_CREATED +# .. event_description: Emitted when a new thread is created in a discussion +# .. event_data: DiscussionThreadData +# +THREAD_CREATED = OpenEdxPublicSignal( + event_type="org.openedx.learning.thread.created.v1", + data={ + "thread": DiscussionThreadData, + } +)