parent
9935509edc
commit
cb303ddc8e
@ -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…
Reference in new issue