From eb835dc0f140ed24688d74bc5af0531bf7432f6e Mon Sep 17 00:00:00 2001 From: Lee Kirkland Date: Fri, 17 Aug 2018 14:24:51 -0400 Subject: [PATCH 1/2] adding additional question type added an additional case statement to handle multichoiceset qtype. Will need to add a better default handler for future qtypes. --- src/transformer/events/mod_quiz/question_answered/handler.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/transformer/events/mod_quiz/question_answered/handler.php b/src/transformer/events/mod_quiz/question_answered/handler.php index 5a3115e33..a875e4266 100644 --- a/src/transformer/events/mod_quiz/question_answered/handler.php +++ b/src/transformer/events/mod_quiz/question_answered/handler.php @@ -38,6 +38,7 @@ function handler(array $config, \stdClass $event, \stdClass $questionattempt) { case 'match': return match($config, $event, $questionattempt, $question); case 'multichoice': + case 'multichoiceset': return multichoice($config, $event, $questionattempt, $question); case 'numerical': return numerical($config, $event, $questionattempt, $question); From 750989b8dd73e2106acd9651c7c2646032c3567b Mon Sep 17 00:00:00 2001 From: Lee Kirkland Date: Tue, 21 Aug 2018 10:41:20 -0400 Subject: [PATCH 2/2] updated test to test for multichoiceset test for multichoice set. --- .../multichoiceset/data.json | 71 +++++++ .../multichoiceset/event.json | 10 + .../multichoiceset/statements.json | 190 ++++++++++++++++++ .../attempt_submitted/multichoiceset/test.php | 24 +++ 4 files changed, 295 insertions(+) create mode 100644 tests/mod_quiz/attempt_submitted/multichoiceset/data.json create mode 100644 tests/mod_quiz/attempt_submitted/multichoiceset/event.json create mode 100644 tests/mod_quiz/attempt_submitted/multichoiceset/statements.json create mode 100644 tests/mod_quiz/attempt_submitted/multichoiceset/test.php diff --git a/tests/mod_quiz/attempt_submitted/multichoiceset/data.json b/tests/mod_quiz/attempt_submitted/multichoiceset/data.json new file mode 100644 index 000000000..d61d4a6d4 --- /dev/null +++ b/tests/mod_quiz/attempt_submitted/multichoiceset/data.json @@ -0,0 +1,71 @@ +{ + "user": [ + { + "id": 1, + "firstname": "test_fullname", + "email": "test@test.com" + } + ], + "course": [ + { + "id": 1, + "fullname": "test_name", + "lang": "en" + } + ], + "course_modules": [ + { + "id": 1, + "course": 1, + "module": 1, + "instance": 1 + } + ], + "modules": [ + { + "id": 1, + "name": "quiz" + } + ], + "quiz_attempts": [ + { + "id": 1, + "quiz": 1, + "sumgrades": 50, + "state": "finished", + "timefinish": 1, + "timestart": 0 + } + ], + "quiz": [ + { + "id": 1, + "name": "test_quiz_name" + } + ], + "grade_items": [ + { + "id": 1, + "iteminstance": 1, + "itemmodule": "quiz", + "grademin": 0, + "grademax": 100, + "gradepass": 50 + } + ], + "question_attempts": [ + { + "id": 1, + "questionusageid": 1, + "questionid": 1, + "responsesummary": "test_answer" + } + ], + "question": [ + { + "id": 1, + "qtype": "multichoiceset", + "questiontext": "test_question" + } + ] +} \ No newline at end of file diff --git a/tests/mod_quiz/attempt_submitted/multichoiceset/event.json b/tests/mod_quiz/attempt_submitted/multichoiceset/event.json new file mode 100644 index 000000000..0f8370b23 --- /dev/null +++ b/tests/mod_quiz/attempt_submitted/multichoiceset/event.json @@ -0,0 +1,10 @@ +{ + "id": 1, + "relateduserid": 1, + "courseid": 1, + "timecreated": 1433946701, + "objecttable": "attempt", + "objectid": 1, + "contextinstanceid": 1, + "eventname": "\\mod_quiz\\event\\attempt_submitted" +} \ No newline at end of file diff --git a/tests/mod_quiz/attempt_submitted/multichoiceset/statements.json b/tests/mod_quiz/attempt_submitted/multichoiceset/statements.json new file mode 100644 index 000000000..aabc3d691 --- /dev/null +++ b/tests/mod_quiz/attempt_submitted/multichoiceset/statements.json @@ -0,0 +1,190 @@ +[ + { + "actor": { + "name": "test_fullname", + "account": { + "homePage": "http:\/\/www.example.org", + "name": "1" + } + }, + "verb": { + "id": "http:\/\/adlnet.gov\/expapi\/verbs\/completed", + "display": { + "en": "completed" + } + }, + "object": { + "id": "http:\/\/www.example.org\/mod\/quiz\/view.php?id=1", + "definition": { + "type": "http:\/\/adlnet.gov\/expapi\/activities\/assessment", + "name": { + "en": "test_quiz_name" + } + } + }, + "timestamp": "2015-06-10T15:31:41+01:00", + "result": { + "score": { + "raw": 50, + "min": 0, + "max": 100, + "scaled": 0.5 + }, + "completion": true, + "success": true, + "duration": "PT1S" + }, + "context": { + "platform": "Moodle", + "language": "en", + "extensions": { + "http:\/\/lrs.learninglocker.net\/define\/extensions\/info": { + "http:\/\/moodle.org": "1.0.0", + "https:\/\/github.com\/xAPI-vle\/moodle-logstore_xapi": "0.0.0-development", + "event_name": "\\mod_quiz\\event\\attempt_submitted", + "event_function": "\\src\\transformer\\events\\mod_quiz\\attempt_submitted\\handler" + } + }, + "contextActivities": { + "other": [ + { + "id": "http:\/\/www.example.org\/mod\/quiz\/attempt.php?attempt=1&cmid=1", + "definition": { + "type": "http:\/\/adlnet.gov\/expapi\/activities\/attempt", + "name": { + "en": "Attempt" + } + } + } + ], + "grouping": [ + { + "id": "http:\/\/www.example.org", + "definition": { + "type": "http:\/\/id.tincanapi.com\/activitytype\/lms", + "name": { + "en": "test_name" + } + } + }, + { + "id": "http:\/\/www.example.org\/course\/view.php?id=1", + "definition": { + "type": "http:\/\/id.tincanapi.com\/activitytype\/lms\/course", + "name": { + "en": "test_name" + } + } + } + ], + "category": [ + { + "id": "http:\/\/moodle.org", + "definition": { + "type": "http:\/\/id.tincanapi.com\/activitytype\/source", + "name": { + "en": "Moodle" + } + } + } + ] + } + } + }, + { + "actor": { + "name": "test_fullname", + "account": { + "homePage": "http:\/\/www.example.org", + "name": "1" + } + }, + "verb": { + "id": "http:\/\/adlnet.gov\/expapi\/verbs\/answered", + "display": { + "en": "answered" + } + }, + "object": { + "id": "http:\/\/www.example.org\/question\/question.php?cmid=1&id=1", + "definition": { + "type": "http:\/\/adlnet.gov\/expapi\/activities\/cmi.interaction", + "name": { + "en": "test_question" + }, + "interactionType": "choice" + } + }, + "timestamp": "2015-06-10T15:31:41+01:00", + "result": { + "response": "test_answer", + "completion": true, + "extensions": { + "http:\/\/learninglocker.net\/xapi\/cmi\/choice\/response": "test_answer" + } + }, + "context": { + "platform": "Moodle", + "language": "en", + "extensions": { + "http:\/\/lrs.learninglocker.net\/define\/extensions\/info": { + "http:\/\/moodle.org": "1.0.0", + "https:\/\/github.com\/xAPI-vle\/moodle-logstore_xapi": "0.0.0-development", + "event_name": "\\mod_quiz\\event\\attempt_submitted", + "event_function": "\\src\\transformer\\events\\mod_quiz\\attempt_submitted\\handler" + } + }, + "contextActivities": { + "grouping": [ + { + "id": "http:\/\/www.example.org", + "definition": { + "type": "http:\/\/id.tincanapi.com\/activitytype\/lms", + "name": { + "en": "test_name" + } + } + }, + { + "id": "http:\/\/www.example.org\/course\/view.php?id=1", + "definition": { + "type": "http:\/\/id.tincanapi.com\/activitytype\/lms\/course", + "name": { + "en": "test_name" + } + } + }, + { + "id": "http:\/\/www.example.org\/mod\/quiz\/view.php?id=1", + "definition": { + "type": "http:\/\/adlnet.gov\/expapi\/activities\/assessment", + "name": { + "en": "test_quiz_name" + } + } + }, + { + "id": "http:\/\/www.example.org\/mod\/quiz\/attempt.php?attempt=1&cmid=1", + "definition": { + "type": "http:\/\/adlnet.gov\/expapi\/activities\/attempt", + "name": { + "en": "Attempt" + } + } + } + ], + "category": [ + { + "id": "http:\/\/moodle.org", + "definition": { + "type": "http:\/\/id.tincanapi.com\/activitytype\/source", + "name": { + "en": "Moodle" + } + } + } + ] + } + } + } +] \ No newline at end of file diff --git a/tests/mod_quiz/attempt_submitted/multichoiceset/test.php b/tests/mod_quiz/attempt_submitted/multichoiceset/test.php new file mode 100644 index 000000000..f8b8fbd3e --- /dev/null +++ b/tests/mod_quiz/attempt_submitted/multichoiceset/test.php @@ -0,0 +1,24 @@ +. + +namespace tests\mod_quiz\attempt_submitted\multichoiceset; +defined('MOODLE_INTERNAL') || die(); + +class test extends \tests\xapi_test_case { + protected function get_test_dir() { + return __DIR__; + } +} \ No newline at end of file