diff --git a/plugin/migrationmoodle/admin.php b/plugin/migrationmoodle/admin.php index 6c737cf41e..7fe2186688 100644 --- a/plugin/migrationmoodle/admin.php +++ b/plugin/migrationmoodle/admin.php @@ -112,6 +112,10 @@ $menu = [ 'action' => 'questions', 'parent' => 21, ], + 25 => [ + 'action' => 'question_multi_choice', + 'parent' => 24, + ], ]; Display::display_header($plugin->get_title()); diff --git a/plugin/migrationmoodle/lang/english.php b/plugin/migrationmoodle/lang/english.php index d1346fd828..3b113470a9 100644 --- a/plugin/migrationmoodle/lang/english.php +++ b/plugin/migrationmoodle/lang/english.php @@ -32,3 +32,4 @@ $strings['QuizzesTask'] = 'Quizzes'; $strings['FilesForQuizzesTask'] = 'Files for quizzes'; $strings['QuestionCategoriesTask'] = 'Question categories'; $strings['QuestionsTask'] = 'Questions'; +$strings['QuestionMultiChoiceTask'] = 'Answers for multichoice questions'; diff --git a/plugin/migrationmoodle/src/Task/QuestionMultiChoiceTask.php b/plugin/migrationmoodle/src/Task/QuestionMultiChoiceTask.php new file mode 100644 index 0000000000..e5351f2b26 --- /dev/null +++ b/plugin/migrationmoodle/src/Task/QuestionMultiChoiceTask.php @@ -0,0 +1,88 @@ + BaseExtractor::class, + 'query' => "SELECT + qa.id, + qa.question, + qa.answer, + qa.feedback, + (qa.fraction * qq.defaultmark) score, + q.id quizid, + q.course + FROM mdl_question_answers qa + INNER JOIN mdl_question qq ON qa.question = qq.id + INNER JOIN mdl_quiz_slots qs ON qq.id = qs.questionid + INNER JOIN mdl_quiz q ON qs.quizid = q.id + WHERE qq.qtype = 'multichoice'", + ]; + } + + /** + * @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'], + ], + 'score' => 'score', + 'answer' => [ + 'class' => ReplaceFilePaths::class, + 'properties' => ['answer', 'course'], + ], + 'feedback' => [ + 'class' => ReplaceFilePaths::class, + 'properties' => ['feedback', 'course'], + ], + ], + ]; + } + + /** + * @inheritDoc + */ + public function getLoadConfiguration() + { + return [ + 'class' => LessonAnswersMultipleChoiceLoader::class, + ]; + } +} diff --git a/plugin/migrationmoodle/src/Transformer/Property/LoadedQuestionLookup.php b/plugin/migrationmoodle/src/Transformer/Property/LoadedQuestionLookup.php new file mode 100644 index 0000000000..43aea916fc --- /dev/null +++ b/plugin/migrationmoodle/src/Transformer/Property/LoadedQuestionLookup.php @@ -0,0 +1,22 @@ +calledClass = QuestionsTask::class; + } +}