Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add discussion reference to comments and responses #421

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'):
Ian2012 marked this conversation as resolved.
Show resolved Hide resolved
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 = [
Ian2012 marked this conversation as resolved.
Show resolved Hide resolved
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