parent
45b695b054
commit
b0761b03b9
@ -0,0 +1,77 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\MigrationMoodle\Loader; |
||||
|
||||
use Chamilo\PluginBundle\MigrationMoodle\Interfaces\LoaderInterface; |
||||
|
||||
/** |
||||
* Class CourseModulesScormLoader. |
||||
* |
||||
* @package Chamilo\PluginBundle\MigrationMoodle\Loader |
||||
*/ |
||||
class CourseModulesScormLoader implements LoaderInterface |
||||
{ |
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function load(array $incomingData) |
||||
{ |
||||
$tblLpMain = \Database::get_course_table(TABLE_LP_MAIN); |
||||
|
||||
$resultDisplayOrder = \Database::query( |
||||
"SELECT |
||||
CASE WHEN MAX(display_order) > 0 THEN MAX(display_order) + 1 ELSE 1 END AS display_order |
||||
FROM $tblLpMain WHERE c_id = {$incomingData['c_id']}" |
||||
); |
||||
$row = \Database::fetch_assoc($resultDisplayOrder); |
||||
$displayOrder = $row['display_order']; |
||||
|
||||
$now = api_get_utc_datetime(); |
||||
$courseInfo = api_get_course_info_by_id($incomingData['c_id']); |
||||
$userId = 1; |
||||
|
||||
$incomingData['path'] = str_replace('.zip', '/.', $incomingData['path']); |
||||
$incomingData['use_max_score'] = $incomingData['use_max_score'] == 100; |
||||
|
||||
$params = array_merge( |
||||
$incomingData, |
||||
[ |
||||
'lp_type' => 2, |
||||
'description' => '', |
||||
'force_commit' => 0, |
||||
'default_view_mod' => 'embedded', |
||||
'default_encoding' => 'UTF-8', |
||||
'js_lib' => 'scorm_api.php', |
||||
'display_order' => $displayOrder, |
||||
'session_id' => 0, |
||||
'content_maker' => '', |
||||
'content_license' => '', |
||||
'debug' => 0, |
||||
'theme' => '', |
||||
'preview_image' => '', |
||||
'author' => '', |
||||
'prerequisite' => 0, |
||||
'seriousgame_mode' => 0, |
||||
'autolaunch' => 0, |
||||
'category_id' => 0, |
||||
'max_attempts' => 0, |
||||
'subscribe_users' => 0, |
||||
'created_on' => $now, |
||||
'modified_on' => $now, |
||||
'publicated_on' => $now, |
||||
] |
||||
); |
||||
|
||||
$lpId = \Database::insert($tblLpMain, $params); |
||||
|
||||
if ($lpId) { |
||||
\Database::query("UPDATE $tblLpMain SET id = iid WHERE iid = $lpId"); |
||||
|
||||
api_item_property_update($courseInfo, TOOL_LEARNPATH, $lpId, 'LearnpathAdded', $userId); |
||||
api_item_property_update($courseInfo, TOOL_LEARNPATH, $lpId, 'visible', $userId); |
||||
} |
||||
|
||||
return $lpId; |
||||
} |
||||
} |
||||
@ -0,0 +1,77 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\PluginBundle\MigrationMoodle\Task; |
||||
|
||||
use Chamilo\PluginBundle\MigrationMoodle\Extractor\CourseExtractor; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Loader\CourseModulesScormLoader; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\BaseTransformer; |
||||
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LoadedCourseLookup; |
||||
|
||||
/** |
||||
* Class CourseModulesScormTask. |
||||
* |
||||
* Task to convert Moodle scorm in Chamilo scorm. |
||||
* |
||||
* @package Chamilo\PluginBundle\MigrationMoodle\Task |
||||
*/ |
||||
class CourseModulesScormTask extends BaseTask |
||||
{ |
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getExtractConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => CourseExtractor::class, |
||||
'query' => "SELECT |
||||
cm.id, |
||||
sco.course, |
||||
sco.name, |
||||
sco.reference, |
||||
sco.version, |
||||
sco.maxgrade, |
||||
sco.hidetoc, |
||||
i.identifier |
||||
FROM mdl_scorm sco |
||||
INNER JOIN mdl_scorm_scoes i on sco.id = i.scorm |
||||
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' |
||||
AND i.parent = '/' |
||||
ORDER BY cs.id, FIND_IN_SET(cm.id, cs.sequence)", |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getTransformConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => BaseTransformer::class, |
||||
'map' => [ |
||||
'c_id' => [ |
||||
'class' => LoadedCourseLookup::class, |
||||
'properties' => ['course'], |
||||
], |
||||
'name' => 'name', |
||||
'ref' => 'identifier', |
||||
'path' => 'reference', |
||||
'use_max_score' => 'maxgrade', |
||||
'hide_toc_frame' => 'hidetoc', |
||||
], |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @inheritDoc |
||||
*/ |
||||
public function getLoadConfiguration() |
||||
{ |
||||
return [ |
||||
'class' => CourseModulesScormLoader::class, |
||||
]; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue