diff --git a/plugin/migrationmoodle/admin.php b/plugin/migrationmoodle/admin.php index 31e9aa29ea..950b4aa612 100644 --- a/plugin/migrationmoodle/admin.php +++ b/plugin/migrationmoodle/admin.php @@ -75,6 +75,7 @@ $menu = [ 'question_multi_choice_single', 'question_multi_choice_multiple', 'questions_true_false', + 'question_short_answer', ], 'course_modules_scorm' => [ 'scorm_scoes', diff --git a/plugin/migrationmoodle/lang/english.php b/plugin/migrationmoodle/lang/english.php index a6ca5b6a59..32a9172693 100644 --- a/plugin/migrationmoodle/lang/english.php +++ b/plugin/migrationmoodle/lang/english.php @@ -37,6 +37,7 @@ $strings['QuestionsTask'] = 'Questions'; $strings['QuestionMultiChoiceSingleTask'] = 'Answers for multichoice questions (single)'; $strings['QuestionMultiChoiceMultipleTask'] = 'Answers for multichoice questions (multiple)'; $strings['QuestionsTrueFalseTask'] = 'Answers for truefalse questions'; +$strings['QuestionShortAnswerTask'] = 'Answers for shortanswers questions'; $strings['CourseModulesScormTask'] = 'Course Scorms'; $strings['ScormScoesTask'] = 'Scorms items'; $strings['FilesForScormScoesTask'] = 'Files for Scorm items'; diff --git a/plugin/migrationmoodle/src/Task/QuestionShortAnswerTask.php b/plugin/migrationmoodle/src/Task/QuestionShortAnswerTask.php new file mode 100644 index 0000000000..0b4fcee7e4 --- /dev/null +++ b/plugin/migrationmoodle/src/Task/QuestionShortAnswerTask.php @@ -0,0 +1,73 @@ + CourseExtractor::class, + 'query' => "SELECT + qa.id, + qa.question, + GROUP_CONCAT(qa.answer SEPARATOR '|') answers, + GROUP_CONCAT(qa.fraction * qq.defaultmark) scores, + GROUP_CONCAT(qa.feedback SEPARATOR '\n') feedback, + COUNT(qa.id) nb, + q.id quizid, + q.course + FROM mdl_question_answers qa + INNER JOIN mdl_question qq ON qa.question = qq.id + INNER JOIN mdl_qtype_shortanswer_options qo ON qq.id = qo.questionid + INNER JOIN mdl_quiz_slots qs ON qq.id = qs.questionid + INNER JOIN mdl_quiz q ON qs.quizid = q.id + WHERE qq.qtype = 'shortanswer' + GROUP BY qq.id + ORDER BY q.course, qq.id", + ]; + } + + /** + * @inheritDoc + */ + public function getTransformConfiguration() + { + return [ + 'class' => BaseTransformer::class, + 'map' => [ + 'c_id' => [ + 'class' => LoadedCourseLookup::class, + 'properties' => ['course'], + ], + 'quiz_id' => [ + 'class' => LoadedLpQuizLookup::class, + 'properties' => ['quizid'], + ], + 'question_id' => [ + 'class' => LoadedQuestionLookup::class, + 'properties' => ['question'], + ], + 'scores' => 'scores', + 'answers' => 'answers', + 'comment' => 'feedback', + 'nb' => 'nb', + ], + ]; + } +}