Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/plugin/migrationmoodle/src/Task/LessonAnswersMatchingTask.php

80 lines
2.6 KiB

<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\PluginBundle\MigrationMoodle\Task;
use Chamilo\PluginBundle\MigrationMoodle\Extractor\BaseExtractor;
use Chamilo\PluginBundle\MigrationMoodle\Loader\LessonAnswersMatchingLoader;
use Chamilo\PluginBundle\MigrationMoodle\Transformer\BaseTransformer;
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LessonAnswersMatchingScoreLookup;
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LoadedCourseLookup;
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LoadedLpQuizLookup;
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LoadedLpQuizQuestionLookup;
/**
* Class LessonAnswersMatchingTask.
*
* Task to convert Matching answers from a lesson page in quiz answers for chamilo.
*
* @package Chamilo\PluginBundle\MigrationMoodle\Task
*/
class LessonAnswersMatchingTask extends BaseTask
{
/**
* @return array
*/
public function getExtractConfiguration()
{
return [
'class' => BaseExtractor::class,
'query' => "SELECT la.id, la.pageid, la.answer, la.response, la.lessonid, l.course
FROM mdl_lesson_answers la
INNER JOIN mdl_lesson_pages lp ON (la.pageid = lp.id AND la.lessonid = lp.lessonid)
INNER JOIN mdl_lesson l ON (lp.lessonid = l.id AND la.lessonid = l.id)
WHERE lp.qtype = 5
AND (la.response IS NOT NULL OR la.response != '')
ORDER BY lp.id",
];
}
/**
* @return array
*/
public function getTransformConfiguration()
{
return [
'class' => BaseTransformer::class,
'map' => [
'c_id' => [
'class' => LoadedCourseLookup::class,
'properties' => ['course'],
],
'quiz_id' => [
'class' => LoadedLpQuizLookup::class,
'properties' => ['pageid'],
],
'question_id' => [
'class' => LoadedLpQuizQuestionLookup::class,
'properties' => ['pageid'],
],
'score' => [
'class' => LessonAnswersMatchingScoreLookup::class,
'properties' => ['pageid', 'lessonid', 'course'],
],
'answer' => 'answer',
'feedback' => 'response',
],
];
}
/**
* @return array
*/
public function getLoadConfiguration()
{
return [
'class' => LessonAnswersMatchingLoader::class,
];
}
}