From f0ac42fabc98562bbe4f95305914916150cc5c58 Mon Sep 17 00:00:00 2001 From: Zia Fazal Date: Wed, 19 Jul 2023 11:11:50 +0500 Subject: [PATCH] feat: Added forum thread interaction events (#318) feat: forum thread interaction events --- docs/event-mapping/Supported_events.rst | 14 +++ docs/event-mapping/xAPI_mapping.rst | 97 ++++++++++++++ .../current/edx.forum.thread.created.json | 40 ++++++ .../current/edx.forum.thread.deleted.json | 34 +++++ .../current/edx.forum.thread.edited.json | 32 +++++ .../current/edx.forum.thread.viewed.json | 32 +++++ .../current/edx.forum.thread.voted.json | 31 +++++ .../processors/xapi/constants.py | 11 ++ .../xapi/event_transformers/__init__.py | 7 ++ .../xapi/event_transformers/forum_events.py | 118 ++++++++++++++++++ .../expected/edx.forum.thread.created.json | 43 +++++++ .../expected/edx.forum.thread.deleted.json | 42 +++++++ .../expected/edx.forum.thread.edited.json | 42 +++++++ .../expected/edx.forum.thread.viewed.json | 42 +++++++ .../expected/edx.forum.thread.voted.json | 43 +++++++ event_routing_backends/settings/common.py | 5 + 16 files changed, 633 insertions(+) create mode 100644 event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.created.json create mode 100644 event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.deleted.json create mode 100644 event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.edited.json create mode 100644 event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.viewed.json create mode 100644 event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.voted.json create mode 100644 event_routing_backends/processors/xapi/event_transformers/forum_events.py create mode 100644 event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.created.json create mode 100644 event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.deleted.json create mode 100644 event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.edited.json create mode 100644 event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.viewed.json create mode 100644 event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.voted.json diff --git a/docs/event-mapping/Supported_events.rst b/docs/event-mapping/Supported_events.rst index 49db27f5..42939555 100644 --- a/docs/event-mapping/Supported_events.rst +++ b/docs/event-mapping/Supported_events.rst @@ -48,6 +48,15 @@ Course navigation events * `edx.ui.lms.sequence.tab_selected`_ | edX `sample <../../event_routing_backends/processors/tests/fixtures/current/edx.ui.lms.sequence.tab_selected.json>`__ | xAPI `map <./xAPI_mapping.rst#edx-ui-lms-sequence-tab-selected>`__ , `sample <../../event_routing_backends/processors/xapi/tests/fixtures/expected/edx.ui.lms.sequence.tab_selected.json>`__ | Caliper `map <./Caliper_mapping.rst#edx-ui-lms-sequence-tab-selected>`__ , `sample <../../event_routing_backends/processors/caliper/tests/fixtures/expected/edx.ui.lms.sequence.tab_selected.json>`__ * `edx.ui.lms.link_clicked`_ | edX `sample <../../event_routing_backends/processors/tests/fixtures/current/edx.ui.lms.link_clicked.json>`__ | xAPI `map <./xAPI_mapping.rst#edx-ui-lms-link-clicked>`__ , `sample <../../event_routing_backends/processors/xapi/tests/fixtures/expected/edx.ui.lms.link_clicked.json>`__ | Caliper `map <./Caliper_mapping.rst#edx-ui-lms-link-clicked>`__ , `sample <../../event_routing_backends/processors/caliper/tests/fixtures/expected/edx.ui.lms.link_clicked.json>`__ +Forum events +----------------- + +* `edx.forum.thread.created`_ | edX `sample <../../event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.created.json>`__ | xAPI `map <./xAPI_mapping.rst#edx-forum-thread-created>`__ , `sample <../../event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.created.json>`__ +* `edx.forum.thread.edited`_ | edX `sample <../../event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.edited.json>`__ | xAPI `map <./xAPI_mapping.rst#edx-forum-thread-edited>`__ , `sample <../../event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.edited.json>`__ +* `edx.forum.thread.viewed`_ | edX `sample <../../event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.viewed.json>`__ | xAPI `map <./xAPI_mapping.rst#edx-forum-thread-viewed>`__ , `sample <../../event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.viewed.json>`__ +* `edx.forum.thread.deleted`_ | edX `sample <../../event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.deleted.json>`__ | xAPI `map <./xAPI_mapping.rst#edx-forum-thread-deleted>`__ , `sample <../../event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.deleted.json>`__ +* `edx.forum.thread.voted`_ | edX `sample <../../event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.voted.json>`__ | xAPI `map <./xAPI_mapping.rst#edx-forum-thread-voted>`__ , `sample <../../event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.voted.json>`__ + .. _edx.course.enrollment.activated: http://edx.readthedocs.io/projects/devdata/en/latest/internal_data_formats/tracking_logs/student_event_types.html#edx-course-enrollment-activated-and-edx-course-enrollment-deactivated .. _edx.course.enrollment.deactivated: http://edx.readthedocs.io/projects/devdata/en/latest/internal_data_formats/tracking_logs/student_event_types.html#edx-course-enrollment-activated-and-edx-course-enrollment-deactivated @@ -71,3 +80,8 @@ Course navigation events .. _edx.video.transcript.shown: https://docs.openedx.org/en/latest/developers/references/internal_data_formats/tracking_logs/student_event_types.html#show-transcript-edx-video-transcript-shown .. _edx.video.transcript.hidden: https://docs.openedx.org/en/latest/developers/references/internal_data_formats/tracking_logs/student_event_types.html#hide-transcript-edx-video-transcript-hidden .. _speed_change_video: https://docs.openedx.org/en/latest/developers/references/internal_data_formats/tracking_logs/student_event_types.html#speed-change-video +.. _edx.forum.thread.created: https://docs.openedx.org/en/latest/developers/references/internal_data_formats/tracking_logs/student_event_types.html#edx-forum-thread-created +.. _edx.forum.thread.edited: https://docs.openedx.org/en/latest/developers/references/internal_data_formats/tracking_logs/student_event_types.html#edx-forum-thread-edited +.. _edx.forum.thread.viewed: https://docs.openedx.org/en/latest/developers/references/internal_data_formats/tracking_logs/student_event_types.html#edx-forum-thread-viewed +.. _edx.forum.thread.deleted: https://docs.openedx.org/en/latest/developers/references/internal_data_formats/tracking_logs/student_event_types.html#edx-forum-thread-deleted +.. _edx.forum.thread.voted: https://docs.openedx.org/en/latest/developers/references/internal_data_formats/tracking_logs/student_event_types.html#edx-forum-thread-voted diff --git a/docs/event-mapping/xAPI_mapping.rst b/docs/event-mapping/xAPI_mapping.rst index caa6b130..2ee778c0 100644 --- a/docs/event-mapping/xAPI_mapping.rst +++ b/docs/event-mapping/xAPI_mapping.rst @@ -635,3 +635,100 @@ contextActivities [ parent [ id ] ] /cou contextActivities [ parent [ definition [ type ] ] ] http://adlnet.gov/expapi/activities/course contextActivities [ parent [ definition [ name ][ en-US ] ] ] ============================================================= ============================================= + +edx.forum.thread.created +======================== + +=========================================================================== ====================================================== +xAPI Key Value +=========================================================================== ====================================================== +``Actor`` +objectType Agent +account [ homePage ] +account [ name ] +``Verb`` +id https://w3id.org/xapi/acrossx/verbs/posted +display [ en-US ] posted +``Object`` +id /api/discussion/v1/threads/ +objectType Activity +definition [ type ] http://id.tincanapi.com/activitytype/discussion +definition [ extensions [ https://w3id.org/xapi/acrossx/extensions/type ] ] +=========================================================================== ====================================================== + +edx.forum.thread.edited +======================= + +=========================================================================== ====================================================== +xAPI Key Value +=========================================================================== ====================================================== +``Actor`` +objectType Agent +account [ homePage ] +account [ name ] +``Verb`` +id https://w3id.org/xapi/acrossx/verbs/edited +display [ en-US ] edited +``Object`` +id /api/discussion/v1/threads/ +objectType Activity +definition [ type ] http://id.tincanapi.com/activitytype/discussion +=========================================================================== ====================================================== + +edx.forum.thread.deleted +======================== + +=========================================================================== ====================================================== +xAPI Key Value +=========================================================================== ====================================================== +``Actor`` +objectType Agent +account [ homePage ] +account [ name ] +``Verb`` +id https://w3id.org/xapi/dod-isd/verbs/deleted +display [ en-US ] deleted +``Object`` +id /api/discussion/v1/threads/ +objectType Activity +definition [ type ] http://id.tincanapi.com/activitytype/discussion +=========================================================================== ====================================================== + +edx.forum.thread.viewed +======================= + +=========================================================================== ======================================================= +xAPI Key Value +=========================================================================== ======================================================= +``Actor`` +objectType Agent +account [ homePage ] +account [ name ] +``Verb`` +id http://id.tincanapi.com/verb/viewed +display [ en-US ] viewed +``Object`` +id /api/discussion/v1/comments/ +objectType Activity +definition [ type ] http://id.tincanapi.com/activitytype/discussion +=========================================================================== ======================================================= + +edx.forum.thread.created +======================== + +=========================================================================== ====================================================== +xAPI Key Value +=========================================================================== ====================================================== +``Actor`` +objectType Agent +account [ homePage ] +account [ name ] +``Verb`` +id https://w3id.org/xapi/openedx/verb/voted +display [ en-US ] voted +``Object`` +id /api/discussion/v1/threads/ +objectType Activity +definition [ type ] http://id.tincanapi.com/activitytype/discussion +definition [ extensions [ https://w3id.org/xapi/acrossx/extensions/type ] ] +=========================================================================== ====================================================== diff --git a/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.created.json b/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.created.json new file mode 100644 index 00000000..35588e43 --- /dev/null +++ b/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.created.json @@ -0,0 +1,40 @@ +{ + "name": "edx.forum.thread.created", + "timestamp": "2023-07-10T09:23:10.354202+00:00", + "data": { + "commentable_id": "856d38cd-a139-4346-bef9-4147a2e4b7bf", + "group_id": null, + "thread_type": "discussion", + "anonymous": false, + "anonymous_to_peers": false, + "options": { + "followed": true + }, + "from_mfe_sidebar": false, + "title_truncated": false, + "title": "Another thread in test topic", + "truncated": false, + "body": "

Description of another thread in test topic

", + "id": "64abcdfee68f35002fd013c6", + "url": "http://apps.local.overhang.io:2002/", + "user_forums_roles": [ + "Student" + ], + "user_course_roles": [] + }, + "context": { + "session": "054c9ddcb76d2096f862e66bda3bc308", + "user_id": 16, + "username": "xiajul10", + "ip": "172.18.0.1", + "host": "local.overhang.io:8000", + "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0", + "path": "/api/discussion/v1/threads/", + "referer": "http://apps.local.overhang.io:2002/", + "accept_language": "en-US,en;q=0.5", + "client_id": null, + "course_id": "course-v1:testX+XAPI101+2019_T2", + "org_id": "testX", + "enterprise_uuid": "" + } +} diff --git a/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.deleted.json b/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.deleted.json new file mode 100644 index 00000000..64859bca --- /dev/null +++ b/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.deleted.json @@ -0,0 +1,34 @@ +{ + "name": "edx.forum.thread.deleted", + "timestamp": "2023-07-10T09:23:10.354202+00:00", + "data": { + "body": "

Description of another thread in test topic

", + "content_type": "Post", + "own_content": true, + "commentable_id": "856d38cd-a139-4346-bef9-4147a2e4b7bf", + "target_username": "xiajul10", + "title_truncated": false, + "title": "Another thread in test topic", + "id": "64abcdfee68f35002fd013c6", + "url": "http://apps.local.overhang.io:2002/", + "user_forums_roles": [ + "Student" + ], + "user_course_roles": [] + }, + "context": { + "session": "054c9ddcb76d2096f862e66bda3bc308", + "user_id": 16, + "username": "xiajul10", + "ip": "172.18.0.1", + "host": "local.overhang.io:8000", + "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0", + "path": "/api/discussion/v1/threads/64abcdfee68f35002fd013c6/", + "referer": "http://apps.local.overhang.io:2002/", + "accept_language": "en-US,en;q=0.5", + "client_id": null, + "course_id": "course-v1:testX+XAPI101+2019_T2", + "org_id": "testX", + "enterprise_uuid": "" + } +} diff --git a/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.edited.json b/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.edited.json new file mode 100644 index 00000000..2c1ce410 --- /dev/null +++ b/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.edited.json @@ -0,0 +1,32 @@ +{ + "name": "edx.forum.thread.edited", + "timestamp": "2023-07-10T09:23:10.354202+00:00", + "data": { + "target_username": "xiajul7", + "content_type": "Post", + "own_content": true, + "edit_reason": null, + "commentable_id": "856d38cd-a139-4346-bef9-4147a2e4b7bf", + "id": "64a817fce68f35002fd013c3", + "url": "http://apps.local.overhang.io:2002/", + "user_forums_roles": [ + "Student" + ], + "user_course_roles": [] + }, + "context": { + "session": "054c9ddcb76d2096f862e66bda3bc308", + "user_id": 15, + "username": "xiajul7", + "ip": "172.18.0.1", + "host": "local.overhang.io:8000", + "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0", + "path": "/api/discussion/v1/threads/64a817fce68f35002fd013c3/", + "referer": "http://apps.local.overhang.io:2002/", + "accept_language": "en-US,en;q=0.5", + "client_id": null, + "course_id": "course-v1:testX+XAPI101+2019_T2", + "org_id": "testX", + "enterprise_uuid": "" + } +} diff --git a/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.viewed.json b/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.viewed.json new file mode 100644 index 00000000..1e465143 --- /dev/null +++ b/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.viewed.json @@ -0,0 +1,32 @@ +{ + "name": "edx.forum.thread.viewed", + "timestamp": "2023-07-10T09:23:10.354202+00:00", + "data": { + "commentable_id": "856d38cd-a139-4346-bef9-4147a2e4b7bf", + "from_mfe_sidebar": false, + "target_username": "xiajul7", + "title_truncated": false, + "title": "This is first post", + "id": "64a817fce68f35002fd013c3", + "url": "http://apps.local.overhang.io:2002/", + "user_forums_roles": [ + "Student" + ], + "user_course_roles": [] + }, + "context": { + "session": "054c9ddcb76d2096f862e66bda3bc308", + "user_id": 15, + "username": "xiajul7", + "ip": "172.18.0.1", + "host": "local.overhang.io:8000", + "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0", + "path": "/api/discussion/v1/comments/", + "referer": "http://apps.local.overhang.io:2002/", + "accept_language": "en-US,en;q=0.5", + "client_id": null, + "course_id": "course-v1:testX+XAPI101+2019_T2", + "org_id": "testX", + "enterprise_uuid": "" + } +} diff --git a/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.voted.json b/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.voted.json new file mode 100644 index 00000000..b875487f --- /dev/null +++ b/event_routing_backends/processors/tests/fixtures/current/edx.forum.thread.voted.json @@ -0,0 +1,31 @@ +{ + "name": "edx.forum.thread.voted", + "timestamp": "2023-07-10T09:23:10.354202+00:00", + "data": { + "commentable_id": "856d38cd-a139-4346-bef9-4147a2e4b7bf", + "target_username": "xiajul7", + "undo_vote": false, + "vote_value": "up", + "id": "64a817fce68f35002fd013c3", + "url": "http://apps.local.overhang.io:2002/", + "user_forums_roles": [ + "Student" + ], + "user_course_roles": [] + }, + "context": { + "session": "054c9ddcb76d2096f862e66bda3bc308", + "user_id": 16, + "username": "xiajul10", + "ip": "172.18.0.1", + "host": "local.overhang.io:8000", + "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0", + "path": "/api/discussion/v1/threads/64a817fce68f35002fd013c3/", + "referer": "http://apps.local.overhang.io:2002/", + "accept_language": "en-US,en;q=0.5", + "client_id": null, + "course_id": "course-v1:testX+XAPI101+2019_T2", + "org_id": "testX", + "enterprise_uuid": "" + } +} diff --git a/event_routing_backends/processors/xapi/constants.py b/event_routing_backends/processors/xapi/constants.py index 13fe811f..16877806 100644 --- a/event_routing_backends/processors/xapi/constants.py +++ b/event_routing_backends/processors/xapi/constants.py @@ -14,6 +14,11 @@ XAPI_VERB_FAILED = 'http://adlnet.gov/expapi/verbs/failed' XAPI_VERB_EXPERIENCED = 'http://adlnet.gov/expapi/verbs/experienced' XAPI_VERB_NAVIGATED = 'https://w3id.org/xapi/dod-isd/verbs/navigated' +XAPI_VERB_POSTED = 'https://w3id.org/xapi/acrossx/verbs/posted' +XAPI_VERB_EDITED = 'https://w3id.org/xapi/acrossx/verbs/edited' +XAPI_VERB_VIEWED = 'http://id.tincanapi.com/verb/viewed' +XAPI_VERB_DELETED = 'https://w3id.org/xapi/dod-isd/verbs/deleted' +XAPI_VERB_VOTED = 'https://w3id.org/xapi/openedx/verb/voted' XAPI_VERB_TERMINATED = 'http://adlnet.gov/expapi/verbs/terminated' XAPI_VERB_ASKED = 'http://adlnet.gov/expapi/verbs/asked' @@ -34,6 +39,7 @@ XAPI_ACTIVITY_COURSE = 'http://adlnet.gov/expapi/activities/course' XAPI_ACTIVITY_MODULE = 'http://adlnet.gov/expapi/activities/module' XAPI_ACTIVITY_VIDEO = 'https://w3id.org/xapi/video/activity-type/video' +XAPI_ACTIVITY_DISCUSSION = 'http://id.tincanapi.com/activitytype/discussion' XAPI_ACTIVITY_LINK = 'http://adlnet.gov/expapi/activities/link' XAPI_ACTIVITY_POSITION = 'http://id.tincanapi.com/extension/position' XAPI_ACTIVITY_TOTAL_COUNT = 'https://w3id.org/xapi/acrossx/extensions/total-items' @@ -82,6 +88,11 @@ PASSED = 'passed' FAILED = 'failed' SEEKED = 'seeked' +POSTED = 'posted' +VIEWED = 'viewed' +DELETED = 'deleted' +EDITED = 'edited' +VOTED = 'voted' TERMINATED = 'terminated' NAVIGATED = 'navigated' diff --git a/event_routing_backends/processors/xapi/event_transformers/__init__.py b/event_routing_backends/processors/xapi/event_transformers/__init__.py index e56105b7..c46647d8 100644 --- a/event_routing_backends/processors/xapi/event_transformers/__init__.py +++ b/event_routing_backends/processors/xapi/event_transformers/__init__.py @@ -6,6 +6,13 @@ EnrollmentActivatedTransformer, EnrollmentDeactivatedTransformer, ) +from event_routing_backends.processors.xapi.event_transformers.forum_events import ( + ThreadCreatedTransformer, + ThreadDeletedTransformer, + ThreadEditedTransformer, + ThreadViewedTransformer, + ThreadVotedTransformer, +) from event_routing_backends.processors.xapi.event_transformers.navigation_events import ( LinkClickedTransformer, OutlineSelectedTransformer, diff --git a/event_routing_backends/processors/xapi/event_transformers/forum_events.py b/event_routing_backends/processors/xapi/event_transformers/forum_events.py new file mode 100644 index 00000000..5602fa5d --- /dev/null +++ b/event_routing_backends/processors/xapi/event_transformers/forum_events.py @@ -0,0 +1,118 @@ +""" +Transformers for forum related events. +""" +from django.conf import settings +from tincan import Activity, ActivityDefinition, LanguageMap, Verb + +from event_routing_backends.processors.xapi import constants +from event_routing_backends.processors.xapi.registry import XApiTransformersRegistry +from event_routing_backends.processors.xapi.transformer import XApiTransformer + + +class BaseForumThreadTransformer(XApiTransformer): + """ + Base transformer for forum thread events. + """ + + def get_object(self): + """ + Get object for xAPI transformed event related to a thread. + + Returns: + `Activity` + """ + + object_id = self.get_data('data.id', True) + object_path = self.get_data('context.path', True).rstrip('/').replace(object_id, '').rstrip('/') + + return Activity( + id='{lms_root_url}/{object_path}/{object_id}'.format( + lms_root_url=settings.LMS_ROOT_URL, + object_path=object_path, + object_id=object_id + ), + definition=ActivityDefinition( + type=constants.XAPI_ACTIVITY_DISCUSSION, + ) + ) + + +@XApiTransformersRegistry.register('edx.forum.thread.created') +class ThreadCreatedTransformer(BaseForumThreadTransformer): + """ + Transformers for event generated when learner creates a thread in discussion forum. + """ + verb = Verb( + id=constants.XAPI_VERB_POSTED, + display=LanguageMap({constants.EN: constants.POSTED}), + ) + + def get_context_extensions(self): + """ + Get extensions for thread created event context. + + Returns: + `Extensions` + """ + extensions = super().get_context_extensions() + extensions.update({ + constants.XAPI_ACTIVITY_MODE: self.get_data('thread_type') + }) + return extensions + + +@XApiTransformersRegistry.register('edx.forum.thread.edited') +class ThreadEditedTransformer(BaseForumThreadTransformer): + """ + Transformers for event generated when learner modifies a thread in discussion forum. + """ + verb = Verb( + id=constants.XAPI_VERB_EDITED, + display=LanguageMap({constants.EN: constants.EDITED}), + ) + + +@XApiTransformersRegistry.register('edx.forum.thread.viewed') +class ThreadViewedTransformer(BaseForumThreadTransformer): + """ + Transformers for event generated when learner viewes a thread in discussion forum. + """ + verb = Verb( + id=constants.XAPI_VERB_VIEWED, + display=LanguageMap({constants.EN: constants.VIEWED}), + ) + + +@XApiTransformersRegistry.register('edx.forum.thread.deleted') +class ThreadDeletedTransformer(BaseForumThreadTransformer): + """ + Transformers for event generated when learner deletes a thread in discussion forum. + """ + verb = Verb( + id=constants.XAPI_VERB_DELETED, + display=LanguageMap({constants.EN: constants.DELETED}), + ) + + +@XApiTransformersRegistry.register('edx.forum.thread.voted') +class ThreadVotedTransformer(BaseForumThreadTransformer): + """ + Transformers for event generated when learner votes on a thread in discussion forum. + """ + verb = Verb( + id=constants.XAPI_VERB_VOTED, + display=LanguageMap({constants.EN: constants.VOTED}), + ) + + def get_context_extensions(self): + """ + Get extensions for thread voted event context. + + Returns: + `Extensions` + """ + extensions = super().get_context_extensions() + extensions.update({ + constants.XAPI_ACTIVITY_MODE: self.get_data('vote_value') + }) + return extensions diff --git a/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.created.json b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.created.json new file mode 100644 index 00000000..5dbca613 --- /dev/null +++ b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.created.json @@ -0,0 +1,43 @@ +{ + "id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9", + "actor": { + "objectType": "Agent", + "account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"} + }, + "context": { + "contextActivities": { + "parent": [ + { + "id": "http://localhost:18000/course/course-v1:testX+XAPI101+2019_T2", + "objectType": "Activity", + "definition": { + "name": { + "en-US": "Demonstration Course" + }, + "type": "http://adlnet.gov/expapi/activities/course" + } + } + ] + }, + "extensions": { + "https://w3id.org/xapi/openedx/extension/transformer-version": "event-routing-backends@1.1.1", + "https://w3id.org/xapi/openedx/extensions/session-id": "054c9ddcb76d2096f862e66bda3bc308", + "https://w3id.org/xapi/acrossx/extensions/type": "discussion" + } + }, + "object": { + "definition": { + "type": "http://id.tincanapi.com/activitytype/discussion" + }, + "id": "http://localhost:18000//api/discussion/v1/threads/64abcdfee68f35002fd013c6", + "objectType": "Activity" + }, + "timestamp": "2023-07-10T09:23:10.354202+00:00", + "verb": { + "display": { + "en": "posted" + }, + "id": "https://w3id.org/xapi/acrossx/verbs/posted" + }, + "version": "1.0.3" +} diff --git a/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.deleted.json b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.deleted.json new file mode 100644 index 00000000..0026b4da --- /dev/null +++ b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.deleted.json @@ -0,0 +1,42 @@ +{ + "id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9", + "actor": { + "objectType": "Agent", + "account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"} + }, + "context": { + "contextActivities": { + "parent": [ + { + "id": "http://localhost:18000/course/course-v1:testX+XAPI101+2019_T2", + "objectType": "Activity", + "definition": { + "name": { + "en-US": "Demonstration Course" + }, + "type": "http://adlnet.gov/expapi/activities/course" + } + } + ] + }, + "extensions": { + "https://w3id.org/xapi/openedx/extension/transformer-version": "event-routing-backends@1.1.1", + "https://w3id.org/xapi/openedx/extensions/session-id": "054c9ddcb76d2096f862e66bda3bc308" + } + }, + "object": { + "definition": { + "type": "http://id.tincanapi.com/activitytype/discussion" + }, + "id": "http://localhost:18000//api/discussion/v1/threads/64abcdfee68f35002fd013c6", + "objectType": "Activity" + }, + "timestamp": "2023-07-10T09:23:10.354202+00:00", + "verb": { + "display": { + "en": "deleted" + }, + "id": "https://w3id.org/xapi/dod-isd/verbs/deleted" + }, + "version": "1.0.3" +} diff --git a/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.edited.json b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.edited.json new file mode 100644 index 00000000..13f4eb6a --- /dev/null +++ b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.edited.json @@ -0,0 +1,42 @@ +{ + "id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9", + "actor": { + "objectType": "Agent", + "account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"} + }, + "context": { + "contextActivities": { + "parent": [ + { + "id": "http://localhost:18000/course/course-v1:testX+XAPI101+2019_T2", + "objectType": "Activity", + "definition": { + "name": { + "en-US": "Demonstration Course" + }, + "type": "http://adlnet.gov/expapi/activities/course" + } + } + ] + }, + "extensions": { + "https://w3id.org/xapi/openedx/extension/transformer-version": "event-routing-backends@1.1.1", + "https://w3id.org/xapi/openedx/extensions/session-id": "054c9ddcb76d2096f862e66bda3bc308" + } + }, + "object": { + "definition": { + "type": "http://id.tincanapi.com/activitytype/discussion" + }, + "id": "http://localhost:18000//api/discussion/v1/threads/64a817fce68f35002fd013c3", + "objectType": "Activity" + }, + "timestamp": "2023-07-10T09:23:10.354202+00:00", + "verb": { + "display": { + "en": "edited" + }, + "id": "https://w3id.org/xapi/acrossx/verbs/edited" + }, + "version": "1.0.3" +} diff --git a/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.viewed.json b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.viewed.json new file mode 100644 index 00000000..bafe4935 --- /dev/null +++ b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.viewed.json @@ -0,0 +1,42 @@ +{ + "id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9", + "actor": { + "objectType": "Agent", + "account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"} + }, + "context": { + "contextActivities": { + "parent": [ + { + "id": "http://localhost:18000/course/course-v1:testX+XAPI101+2019_T2", + "objectType": "Activity", + "definition": { + "name": { + "en-US": "Demonstration Course" + }, + "type": "http://adlnet.gov/expapi/activities/course" + } + } + ] + }, + "extensions": { + "https://w3id.org/xapi/openedx/extension/transformer-version": "event-routing-backends@1.1.1", + "https://w3id.org/xapi/openedx/extensions/session-id": "054c9ddcb76d2096f862e66bda3bc308" + } + }, + "object": { + "definition": { + "type": "http://id.tincanapi.com/activitytype/discussion" + }, + "id": "http://localhost:18000//api/discussion/v1/comments/64a817fce68f35002fd013c3", + "objectType": "Activity" + }, + "timestamp": "2023-07-10T09:23:10.354202+00:00", + "verb": { + "display": { + "en": "viewed" + }, + "id": "http://id.tincanapi.com/verb/viewed" + }, + "version": "1.0.3" +} diff --git a/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.voted.json b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.voted.json new file mode 100644 index 00000000..bdf50cfd --- /dev/null +++ b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.forum.thread.voted.json @@ -0,0 +1,43 @@ +{ + "id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9", + "actor": { + "objectType": "Agent", + "account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"} + }, + "context": { + "contextActivities": { + "parent": [ + { + "id": "http://localhost:18000/course/course-v1:testX+XAPI101+2019_T2", + "objectType": "Activity", + "definition": { + "name": { + "en-US": "Demonstration Course" + }, + "type": "http://adlnet.gov/expapi/activities/course" + } + } + ] + }, + "extensions": { + "https://w3id.org/xapi/openedx/extension/transformer-version": "event-routing-backends@1.1.1", + "https://w3id.org/xapi/openedx/extensions/session-id": "054c9ddcb76d2096f862e66bda3bc308", + "https://w3id.org/xapi/acrossx/extensions/type": "up" + } + }, + "object": { + "definition": { + "type": "http://id.tincanapi.com/activitytype/discussion" + }, + "id": "http://localhost:18000//api/discussion/v1/threads/64a817fce68f35002fd013c3", + "objectType": "Activity" + }, + "timestamp": "2023-07-10T09:23:10.354202+00:00", + "verb": { + "display": { + "en": "voted" + }, + "id": "https://w3id.org/xapi/openedx/verb/voted" + }, + "version": "1.0.3" +} diff --git a/event_routing_backends/settings/common.py b/event_routing_backends/settings/common.py index ef3d792b..3863bcda 100644 --- a/event_routing_backends/settings/common.py +++ b/event_routing_backends/settings/common.py @@ -70,6 +70,11 @@ def plugin_settings(settings): 'edx.course.enrollment.activated', 'edx.course.enrollment.deactivated', 'edx.course.enrollment.mode_changed', + 'edx.forum.thread.created', + 'edx.forum.thread.deleted', + 'edx.forum.thread.edited', + 'edx.forum.thread.viewed', + 'edx.forum.thread.voted', 'edx.ui.lms.link_clicked', 'edx.ui.lms.sequence.outline.selected', 'edx.ui.lms.outline.selected',