-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds statement for multichoiceset quiz answers. (#235)
- Loading branch information
Showing
18 changed files
with
808 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
namespace src\transformer\utils; | ||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
function get_multichoice_definition(array $config, \stdClass $questionattempt, \stdClass $question, $lang) { | ||
if ($config['send_response_choices']) { | ||
$repo = $config['repo']; | ||
$answers = $repo->read_records('question_answers', [ | ||
'question' => $questionattempt->questionid | ||
]); | ||
$choices = array_map(function ($answer) use ($lang) { | ||
return [ | ||
"id" => "$answer->id", | ||
"description" => [ | ||
$lang => $answer->answer | ||
] | ||
]; | ||
}, $answers); | ||
return [ | ||
'type' => 'http://adlnet.gov/expapi/activities/cmi.interaction', | ||
'name' => [ | ||
$lang => $question->questiontext, | ||
], | ||
'interactionType' => 'choice', | ||
'correctResponsesPattern' => [ | ||
$questionattempt->rightanswer, | ||
], | ||
'choices' => $choices | ||
]; | ||
} | ||
|
||
return [ | ||
'type' => 'http://adlnet.gov/expapi/activities/cmi.interaction', | ||
'name' => [ | ||
$lang => $question->questiontext, | ||
], | ||
'interactionType' => 'choice' | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
tests/mod_quiz/attempt_submitted/multichoice_withchoices/data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"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": "answer 1", | ||
"rightanswer": "answer 1" | ||
} | ||
], | ||
"question": [ | ||
{ | ||
"id": 1, | ||
"qtype": "multichoice", | ||
"questiontext": "test_question" | ||
} | ||
], | ||
"question_answers": [ | ||
{ | ||
"id": 1, | ||
"fraction": 1.000, | ||
"answer": "answer 1", | ||
"question": 1 | ||
} | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/mod_quiz/attempt_submitted/multichoice_withchoices/event.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"id": 1, | ||
"relateduserid": 1, | ||
"courseid": 1, | ||
"timecreated": 1433946701, | ||
"objecttable": "attempt", | ||
"objectid": 1, | ||
"contextinstanceid": 1, | ||
"eventname": "\\mod_quiz\\event\\attempt_submitted" | ||
} |
Oops, something went wrong.