parent
4b8e2c3413
commit
b8e325788c
@ -0,0 +1,51 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\MigrationMoodle\Loader; |
||||
|
||||
use Chamilo\PluginBundle\MigrationMoodle\Interfaces\LoaderInterface; |
||||
|
||||
/** |
||||
* Class CourseModulesUrlLoader. |
||||
* |
||||
* @package Chamilo\PluginBundle\MigrationMoodle\Loader |
||||
*/ |
||||
class CourseModulesUrlLoader implements LoaderInterface |
||||
{ |
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function load(array $incomingData) |
||||
{ |
||||
$courseId = api_get_course_int_id($incomingData['c_code']); |
||||
|
||||
$link = new \Link(); |
||||
$linkId = $link->save( |
||||
[ |
||||
'c_id' => $courseId, |
||||
'url' => $incomingData['url'], |
||||
'title' => $incomingData['title'], |
||||
'description' => null, |
||||
'category_id' => null, |
||||
'on_homepage' => '0', |
||||
'target' => '_self', |
||||
'session_id' => 0, |
||||
] |
||||
); |
||||
|
||||
$lp = new \learnpath( |
||||
$incomingData['c_code'], |
||||
$incomingData['lp_id'], |
||||
api_get_user_id() |
||||
); |
||||
|
||||
return $lp->add_item( |
||||
0, |
||||
$incomingData['previous'], |
||||
'link', |
||||
$linkId, |
||||
$incomingData['title'], |
||||
'' |
||||
); |
||||
} |
||||
} |
||||
@ -0,0 +1,83 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\MigrationMoodle\Task; |
||||
|
||||
use Chamilo\PluginBundle\MigrationMoodle\Extractor\CourseExtractor; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Loader\CourseModulesUrlLoader; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\BaseTransformer; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LoadedCourseCodeLookup; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LoadedLpItemInSequenceLookup; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LoadedLpLookup; |
||||
|
||||
/** |
||||
* Class CourseModulesUrlTask. |
||||
* |
||||
* Task to create a Chamilo Link from a Moodle URL module. |
||||
* |
||||
* The Link created is added in a learning path (from a Moodle course section). |
||||
* |
||||
* @package Chamilo\PluginBundle\MigrationMoodle\Task |
||||
*/ |
||||
class CourseModulesUrlTask extends BaseTask |
||||
{ |
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getExtractConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => CourseExtractor::class, |
||||
'query' => "SELECT cm.id, u.course, u.name, u.externalurl, cm.section, cs.sequence |
||||
FROM mdl_url u |
||||
INNER JOIN mdl_course_modules cm ON (u.course = cm.course AND cm.instance = u.id) |
||||
INNER JOIN mdl_modules m ON cm.module = m.id |
||||
INNER JOIN mdl_course_sections cs ON (cm.course = cs.course AND cm.section = cs.id ) |
||||
WHERE m.name = 'url' |
||||
AND u.course NOT IN ( |
||||
SELECT sco.course |
||||
FROM mdl_scorm sco |
||||
INNER JOIN mdl_course_modules cm ON (sco.course = cm.course AND cm.instance = sco.id) |
||||
INNER JOIN mdl_modules m ON cm.module = m.id |
||||
INNER JOIN mdl_course_sections cs ON (cm.course = cs.course AND cm.section = cs.id ) |
||||
WHERE m.name = 'scorm' |
||||
)", |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getTransformConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => BaseTransformer::class, |
||||
'map' => [ |
||||
'c_code' => [ |
||||
'class' => LoadedCourseCodeLookup::class, |
||||
'properties' => ['course'], |
||||
], |
||||
'lp_id' => [ |
||||
'class' => LoadedLpLookup::class, |
||||
'properties' => ['section'], |
||||
], |
||||
'previous' => [ |
||||
'class' => LoadedLpItemInSequenceLookup::class, |
||||
'properties' => ['id', 'sequence'], |
||||
], |
||||
'title' => 'name', |
||||
'url' => 'externalurl', |
||||
], |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getLoadConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => CourseModulesUrlLoader::class, |
||||
]; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue