Skip to content

Commit

Permalink
feat: create event for response and comment events
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Oct 2, 2023
1 parent b32f812 commit f53fe8a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Changed
~~~~~~~
* Re-licensed this repository from AGPL 3.0 to Apache 2.0

[8.7.0] - 2023-09-29
--------------------
Added
~~~~~
* Added new ``FORUM_THREAD_CREATED``, ``FORUM_RESPONSE_CREATED``, ``FORUM_COMMENT_CREATED`` events in learning subdomain

[8.6.0] - 2023-08-28
--------------------
Added
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__ = "8.6.0"
__version__ = "8.7.0"
9 changes: 9 additions & 0 deletions openedx_events/learning/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ class DiscussionThreadData:
title_truncated (bool): indicates whether the title is truncated.
truncated (bool): indicates whether the thread is truncated.
url (str): url of the thread.
user_id (int): identifier of the user.
course_id (CourseKey): identifier of the course.
discussion (dict): discussion data. (optional, specific to comments and responses)
user_course_roles (List[str]): user course roles.
user_forums_roles (List[str]): user forums roles.
options (dict): options for the thread.
"""

anonymous = attr.ib(type=bool)
Expand All @@ -334,6 +340,9 @@ class DiscussionThreadData:
title_truncated = attr.ib(type=bool)
truncated = attr.ib(type=bool)
url = attr.ib(type=str)
user_id = attr.ib(type=int)
course_id = attr.ib(type=CourseKey)
discussion = attr.ib(type=dict, factory=dict)
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)
26 changes: 25 additions & 1 deletion openedx_events/learning/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,34 @@
# .. event_name: FORUM_THREAD_CREATED
# .. event_description: Emitted when a new thread is created in a discussion
# .. event_data: DiscussionThreadData
# Warning: This event is currently incompatible with the event bus, list/dict cannot be serialized yet
# Warning: This event is currently incompatible with the event bus, list/dict cannot be serialized yet
FORUM_THREAD_CREATED = OpenEdxPublicSignal(
event_type="org.openedx.learning.thread.created.v1",
data={
"thread": DiscussionThreadData,
}
)

# .. event_type: org.openedx.learning.thread.created.v1
# .. event_name: FORUM_RESPONSE_CREATED
# .. event_description: Emitted when a new response is added to a thread
# .. event_data: DiscussionThreadData
# Warning: This event is currently incompatible with the event bus, list/dict cannot be serialized yet
FORUM_RESPONSE_CREATED = OpenEdxPublicSignal(
event_type="org.openedx.learning.response.created.v1",
data={
"thread": DiscussionThreadData,
}
)

# .. event_type: org.openedx.learning.thread.created.v1
# .. event_name: FORUM_RESPONSE_CREATED
# .. event_description: Emitted when a new comment is added to a thread
# .. event_data: DiscussionThreadData
# Warning: This event is currently incompatible with the event bus, list/dict cannot be serialized yet
FORUM_COMMENT_CREATED = OpenEdxPublicSignal(
event_type="org.openedx.learning.response.created.v1",
data={
"thread": DiscussionThreadData,
}
)
2 changes: 2 additions & 0 deletions openedx_events/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"org.openedx.content_authoring.course.certificate_config.deleted.v1",
"org.openedx.learning.user.notification.requested.v1",
"org.openedx.learning.thread.created.v1",
"org.openedx.learning.response.created.v1",
"org.openedx.learning.comment.created.v1",
]


Expand Down

0 comments on commit f53fe8a

Please sign in to comment.