From 9ae82a652d9c9d802dbf607a0c096c1f37748512 Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Wed, 23 Aug 2023 10:29:19 -0500 Subject: [PATCH] test: add fixtures for completion events --- ...x.completion.block_completion.changed.json | 33 +++++++++++++++++ .../event_transformers/completion_events.py | 4 --- .../xapi/event_transformers/event.json | 33 ----------------- ...x.completion.block_completion.changed.json | 36 +++++++++++++++++++ 4 files changed, 69 insertions(+), 37 deletions(-) create mode 100644 event_routing_backends/processors/tests/fixtures/current/edx.completion.block_completion.changed.json delete mode 100644 event_routing_backends/processors/xapi/event_transformers/event.json create mode 100644 event_routing_backends/processors/xapi/tests/fixtures/expected/edx.completion.block_completion.changed.json diff --git a/event_routing_backends/processors/tests/fixtures/current/edx.completion.block_completion.changed.json b/event_routing_backends/processors/tests/fixtures/current/edx.completion.block_completion.changed.json new file mode 100644 index 00000000..38524a7b --- /dev/null +++ b/event_routing_backends/processors/tests/fixtures/current/edx.completion.block_completion.changed.json @@ -0,0 +1,33 @@ +{ + "name": "edx.completion.block_completion.changed", + "timestamp": "2023-08-22T20:16:25.500832Z", + "data": { + "user_id": 4, + "course_id": "course-v1:edX+DemoX+Demo_Course", + "context_key": "course-v1:edX+DemoX+Demo_Course", + "block_key": "block-v1:edX+DemoX+Demo_Course+type@problem+block@7c54b16c8ed34f9f8772015178c7a175", + "block_type": "problem", + "completion": 1.0, + "is_new": false + }, + "context": { + "course_id": "course-v1:edX+DemoX+Demo_Course", + "course_user_tags": {}, + "session": "056aca2a1c6b76742b283e73d3424453", + "user_id": 3, + "username": "edx", + "ip": "172.18.0.1", + "host": "localhost:18000", + "agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36", + "path": "/courses/course-v1:edX+DemoX+Demo_Course/xblock/block-v1:edX+DemoX+Demo_Course+type@problem+block@7c54b16c8ed34f9f8772015178c7a175/handler/xmodule_handler/problem_check", + "referer": "http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course+type@vertical+block@dd8110c941b94d929b56841195213797?show_title=0&show_bookmark_button=0&recheck_access=1&view=student_view", + "accept_language": "en-US,en;q=0.9,es;q=0.8", + "client_id": null, + "org_id": "edX", + "enterprise_uuid": "", + "module": { + "display_name": "Checkboxes", + "usage_key": "block-v1:edX+DemoX+Demo_Course+type@problem+block@7c54b16c8ed34f9f8772015178c7a175" + } + } +} diff --git a/event_routing_backends/processors/xapi/event_transformers/completion_events.py b/event_routing_backends/processors/xapi/event_transformers/completion_events.py index fd716467..ad08c931 100644 --- a/event_routing_backends/processors/xapi/event_transformers/completion_events.py +++ b/event_routing_backends/processors/xapi/event_transformers/completion_events.py @@ -1,8 +1,6 @@ """ Transformers for forum related events. """ -import json - from tincan import Activity, ActivityDefinition, Extensions, LanguageMap, Verb from event_routing_backends.processors.xapi import constants @@ -27,8 +25,6 @@ def get_object(self): Returns: `Activity` """ - print(json.dumps(self.event)) - print(self.get_context_activities()) return Activity( id=self.get_object_iri('xblock', self.get_data('data.block_key')), definition=ActivityDefinition( diff --git a/event_routing_backends/processors/xapi/event_transformers/event.json b/event_routing_backends/processors/xapi/event_transformers/event.json deleted file mode 100644 index 54c3d63d..00000000 --- a/event_routing_backends/processors/xapi/event_transformers/event.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "edx.completion.block_completion.changed", - "timestamp": "2023-08-22T20:16:25.500832Z", - "data": { - "user_id": 4, - "course_id": "course-v1:asdasd+asdasd+asdas", - "context_key": "course-v1:asdasd+asdasd+asdas", - "block_key": "block-v1:asdasd+asdasd+asdas+type@problem+block@7c54b16c8ed34f9f8772015178c7a175", - "block_type": "problem", - "completion": 1.0, - "is_new": false - }, - "context": { - "course_id": "course-v1:asdasd+asdasd+asdas", - "course_user_tags": {}, - "session": "056aca2a1c6b76742b283e73d3424453", - "user_id": 4, - "username": "yourusername", - "ip": "172.19.0.1", - "host": "local.overhang.io:8000", - "agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36", - "path": "/courses/course-v1:asdasd+asdasd+asdas/xblock/block-v1:asdasd+asdasd+asdas+type@problem+block@7c54b16c8ed34f9f8772015178c7a175/handler/xmodule_handler/problem_check", - "referer": "http://local.overhang.io:8000/xblock/block-v1:asdasd+asdasd+asdas+type@vertical+block@dd8110c941b94d929b56841195213797?show_title=0&show_bookmark_button=0&recheck_access=1&view=student_view", - "accept_language": "en-US,en;q=0.9,es;q=0.8", - "client_id": null, - "org_id": "asdasd", - "enterprise_uuid": "", - "module": { - "display_name": "Checkboxes", - "usage_key": "block-v1:asdasd+asdasd+asdas+type@problem+block@7c54b16c8ed34f9f8772015178c7a175" - } - } -} diff --git a/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.completion.block_completion.changed.json b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.completion.block_completion.changed.json new file mode 100644 index 00000000..c0bb72d4 --- /dev/null +++ b/event_routing_backends/processors/xapi/tests/fixtures/expected/edx.completion.block_completion.changed.json @@ -0,0 +1,36 @@ +{ + "id": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb", + "version": "1.0.3", + "actor": { + "objectType": "Agent", + "account": { "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb", "homePage": "http://localhost:18000" } + }, + "verb": { "id": "http://adlnet.gov/expapi/verbs/progressed", "display": { "en": "progressed" } }, + "object": { + "id": "http://localhost:18000/xblock/block-v1:edX+DemoX+Demo_Course+type@problem+block@7c54b16c8ed34f9f8772015178c7a175", + "objectType": "Activity", + "definition": { + "type": "http://id.tincanapi.com/activitytype/resource", + "extensions": { "https://w3id.org/xapi/cmi5/result/extensions/progress": 100.0 } + } + }, + "timestamp": "2023-08-22T20:16:25.500832+00:00", + "context": { + "contextActivities": { + "parent": [ + { + "id": "http://localhost:18000/course/course-v1:edX+DemoX+Demo_Course", + "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": "056aca2a1c6b76742b283e73d3424453" + } + } +}