Skip to content

Commit

Permalink
Merge pull request #421 from openedx/cag/forum-events
Browse files Browse the repository at this point in the history
feat: add discussion reference to comments and responses
  • Loading branch information
Ian2012 authored May 22, 2024
2 parents 8328a10 + 12c5c99 commit 46b2e54
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ Change Log
Unreleased
~~~~~~~~~~

[9.2.0]

* Add discussion reference to comments and responses xAPI events

[9.1.0]

* Add python 3.11 and 3.12 support

[9.0.1]

* Fix an issue with the event routing backend async task to not find the event-tracking backend.
Expand Down
2 changes: 1 addition & 1 deletion event_routing_backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Various backends for receiving edX LMS events..
"""

__version__ = '9.1.0'
__version__ = '9.2.0'
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def get_object(self):
object_id = self.get_data('data.id', True)
object_path = self.get_data('context.path', True).rstrip('/').replace(object_id, '').rstrip('/')

kwargs = {}

if self.get_data('data.title'):
kwargs['name'] = LanguageMap({constants.EN: self.get_data('data.title')})

return Activity(
id='{lms_root_url}{object_path}/{object_id}'.format(
lms_root_url=settings.LMS_ROOT_URL,
Expand All @@ -35,9 +40,31 @@ def get_object(self):
),
definition=ActivityDefinition(
type=constants.XAPI_ACTIVITY_DISCUSSION,
**kwargs
)
)

def get_context_activities(self):
context_activities = super().get_context_activities()

discussion = self.get_data('data.discussion.id')
if not discussion:
return context_activities

context_activities.grouping = [
Activity(
id='{lms_root_url}/api/discussion/v1/threads/{discussion_id}'.format(
lms_root_url=settings.LMS_ROOT_URL,
discussion_id=discussion
),
definition=ActivityDefinition(
type=constants.XAPI_ACTIVITY_DISCUSSION,
)
)
]

return context_activities


@XApiTransformersRegistry.register('edx.forum.thread.created')
class ThreadCreatedTransformer(BaseForumThreadTransformer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"type": "http://adlnet.gov/expapi/activities/course"
}
}
],
"grouping": [
{
"id": "http://localhost:18000/api/discussion/v1/threads/64d1df0887e82a002b35a6f7",
"objectType": "Activity",
"definition": {
"type": "http://id.tincanapi.com/activitytype/discussion"
}
}
]
},
"extensions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"type": "http://adlnet.gov/expapi/activities/course"
}
}
],
"grouping": [
{
"id": "http://localhost:18000/api/discussion/v1/threads/64b7b2bee68f35003369092d",
"objectType": "Activity",
"definition": {
"type": "http://id.tincanapi.com/activitytype/discussion"
}
}
]
},
"extensions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"object": {
"definition": {
"name": {"en": "Another thread in test topic"},
"type": "http://id.tincanapi.com/activitytype/discussion"
},
"id": "http://localhost:18000/api/discussion/v1/threads/64abcdfee68f35002fd013c6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"object": {
"definition": {
"name": {"en": "Another thread in test topic"},
"type": "http://id.tincanapi.com/activitytype/discussion"
},
"id": "http://localhost:18000/api/discussion/v1/threads/64abcdfee68f35002fd013c6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"object": {
"definition": {
"name": {"en": "title of post"},
"type": "http://id.tincanapi.com/activitytype/discussion"
},
"id": "http://localhost:18000/api/discussion/v1/threads/64b7b2bee68f35003369092d",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"object": {
"definition": {
"name": {"en": "title of post"},
"type": "http://id.tincanapi.com/activitytype/discussion"
},
"id": "http://localhost:18000/api/discussion/v1/threads/64b7b2bee68f35003369092d",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"object": {
"definition": {
"name": {"en": "This is first post"},
"type": "http://id.tincanapi.com/activitytype/discussion"
},
"id": "http://localhost:18000/api/discussion/v1/comments/64a817fce68f35002fd013c3",
Expand Down

0 comments on commit 46b2e54

Please sign in to comment.