MigrationMoodle: Add task for learning paths views - refs BT#15992

pull/3127/head
Angel Fernando Quiroz Campos 6 years ago
parent 9935509edc
commit cb303ddc8e
  1. 1
      plugin/migrationmoodle/admin.php
  2. 1
      plugin/migrationmoodle/lang/english.php
  3. 45
      plugin/migrationmoodle/src/Loader/UserLearnPathsLoader.php
  4. 56
      plugin/migrationmoodle/src/Task/UsersLearnPathsTask.php

@ -92,6 +92,7 @@ $menu = [
],
'efc_users' => [
'efc_user_sessions',
'users_learn_paths',
'users_scorms_view',
],
'users_scorms_view' => [

@ -50,3 +50,4 @@ $strings['UrlsTask'] = 'URLs';
$strings['SortSectionModulesTask'] = 'Sort modules in section';
$strings['UsersScormsViewTask'] = 'Scorm views for users';
$strings['UsersScormsProgressTask'] = 'Scorm progress';
$strings['UsersLearnPathsTask'] = 'Learn paths views of users';

@ -0,0 +1,45 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\PluginBundle\MigrationMoodle\Loader;
use Chamilo\PluginBundle\MigrationMoodle\Interfaces\LoaderInterface;
/**
* Class UserLearnPathsLoader.
*
* @package Chamilo\PluginBundle\MigrationMoodle\Loader
*/
class UserLearnPathsLoader implements LoaderInterface
{
/**
* @inheritDoc
*/
public function load(array $incomingData)
{
$em = \Database::getManager();
$subscriptionsRepo = $em->getRepository('ChamiloCoreBundle:SessionRelCourseRelUser');
$learnPathsRepo = $em->getRepository('ChamiloCourseBundle:CLp');
$userId = $incomingData['user_id'];
$subscriptions = $subscriptionsRepo->findBy(['user' => $userId]);
foreach ($subscriptions as $subscription) {
$course = $subscription->getCourse();
$lps = $learnPathsRepo->findBy(['cId' => $course->getId(), 'lpType' => 1]);
foreach ($lps as $lp) {
new \learnpath(
$course->getCode(),
$lp->getId(),
$userId
);
}
}
return $userId;
}
}

@ -0,0 +1,56 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\PluginBundle\MigrationMoodle\Task;
use Chamilo\PluginBundle\MigrationMoodle\Extractor\UserExtractor;
use Chamilo\PluginBundle\MigrationMoodle\Loader\UserLearnPathsLoader;
use Chamilo\PluginBundle\MigrationMoodle\Transformer\BaseTransformer;
use Chamilo\PluginBundle\MigrationMoodle\Transformer\Property\LoadedUserLookup;
/**
* Class UsersLearnPathsTask.
*
* Create views LP and LP items for each user in platform.
*
* @package Chamilo\PluginBundle\MigrationMoodle\Task
*/
class UsersLearnPathsTask extends BaseTask
{
/**
* @inheritDoc
*/
public function getExtractConfiguration()
{
return [
'class' => UserExtractor::class,
'query' => 'SELECT id FROM mdl_user WHERE username LIKE "efc%"',
];
}
/**
* @inheritDoc
*/
public function getTransformConfiguration()
{
return [
'class' => BaseTransformer::class,
'map' => [
'user_id' => [
'class' => LoadedUserLookup::class,
'properties' => ['id'],
],
],
];
}
/**
* @inheritDoc
*/
public function getLoadConfiguration()
{
return [
'class' => UserLearnPathsLoader::class,
];
}
}
Loading…
Cancel
Save