Skip to content

Commit 20688f1

Browse files
Merge pull request #45 from eduNEXT/JDB/event-extraction-discussions_update
feat: Discussion event extraction, in openedx-event library
2 parents be71031 + f93fb2b commit 20688f1

3 files changed

Lines changed: 68 additions & 2 deletions

File tree

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Changed
2323
~~~~~~~~~~~~~~~~~~~~
2424
Added
2525
-----
26+
* Added COURSE_DISCUSSIONS_CHANGED for discussion event
2627
* Added data definition for enterprise/LicenseLifecycle
2728
* Added LicenseCreated signal definition
2829

openedx_events/learning/data.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
pattern.
66
"""
77
from datetime import datetime
8+
from typing import List
89

910
import attr
10-
from opaque_keys.edx.keys import CourseKey
11+
from opaque_keys.edx.keys import CourseKey, UsageKey
1112

1213

1314
@attr.s(frozen=True)
@@ -135,3 +136,49 @@ class CohortData:
135136
user = attr.ib(type=UserData)
136137
course = attr.ib(type=CourseData)
137138
name = attr.ib(type=str)
139+
140+
141+
@attr.s(frozen=True)
142+
class DiscussionTopicContext:
143+
"""
144+
Attributes defined for Open edX Discussion Topic Context object.
145+
146+
Context for linking the external id for a discussion topic to its associated usage key.
147+
148+
Arguments:
149+
title (str): is cached to improve the performance.
150+
usage_key (str): usage key.
151+
group_id(int): can be used for providers that don't internally support cohorting.
152+
external_id(str): store the commentable id.
153+
"""
154+
155+
title = attr.ib(type=str)
156+
usage_key = attr.ib(type=UsageKey, default=None)
157+
group_id = attr.ib(type=int, default=None)
158+
external_id = attr.ib(type=str, default=None)
159+
160+
161+
@attr.s(frozen=True)
162+
class CourseDiscussionConfigurationData:
163+
"""
164+
Attributes defined for Open edX Course Discussion Configuration Data object.
165+
166+
Contains all the metadata needed to configure discussions for a course.
167+
168+
Arguments:
169+
course_key(str): information about the course
170+
provider_type(str): provider type
171+
enable_in_context(bool): enable in context
172+
enable_graded_units(bool): enable grade units
173+
plugin_configuration(dict): plugin configuration
174+
contexts(List): field contains all the contexts for which discussion
175+
is to be enabled.
176+
"""
177+
178+
course_key = attr.ib(type=CourseKey)
179+
provider_type = attr.ib(type=str)
180+
enable_in_context = attr.ib(type=bool, default=True)
181+
enable_graded_units = attr.ib(type=bool, default=False)
182+
unit_level_visibility = attr.ib(type=bool, default=False)
183+
plugin_configuration = attr.ib(type=dict, default={})
184+
contexts = attr.ib(type=List[DiscussionTopicContext], factory=list)

openedx_events/learning/signals.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
docs/decisions/0003-events-payload.rst
99
"""
1010

11-
from openedx_events.learning.data import CertificateData, CohortData, CourseEnrollmentData, UserData
11+
from openedx_events.learning.data import (
12+
CertificateData,
13+
CohortData,
14+
CourseDiscussionConfigurationData,
15+
CourseEnrollmentData,
16+
UserData,
17+
)
1218
from openedx_events.tooling import OpenEdxPublicSignal
1319

1420
# .. event_type: org.openedx.learning.student.registration.completed.v1
@@ -117,3 +123,15 @@
117123
"cohort": CohortData,
118124
}
119125
)
126+
127+
128+
# .. event_type: org.openedx.learning.discussions.configuration.changed.v1
129+
# .. event_name: COURSE_DISCUSSIONS_CHANGED
130+
# .. event_description: emitted when the configuration for a course's discussions changes in the course
131+
# .. event_data: CourseDiscussionConfigurationData
132+
COURSE_DISCUSSIONS_CHANGED = OpenEdxPublicSignal(
133+
event_type="org.openedx.learning.discussions.configuration.changed.v1",
134+
data={
135+
"configuration": CourseDiscussionConfigurationData
136+
}
137+
)

0 commit comments

Comments
 (0)