parent
d03754ea03
commit
24db80b9f8
@ -0,0 +1,43 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
namespace Chamilo\PluginBundle\MigrationMoodle\Loader; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class UserLearnPathLessonAttemptLoader. |
||||||
|
* |
||||||
|
* @package Chamilo\PluginBundle\MigrationMoodle\Loader |
||||||
|
*/ |
||||||
|
class UserLearnPathLessonAttemptLoader extends UserLearnPathLessonBranchLoader |
||||||
|
{ |
||||||
|
/** |
||||||
|
* @param array $incomingData |
||||||
|
* |
||||||
|
* @throws \Doctrine\ORM\ORMException |
||||||
|
* @throws \Doctrine\ORM\OptimisticLockException |
||||||
|
* @throws \Doctrine\ORM\TransactionRequiredException |
||||||
|
* |
||||||
|
* @return int |
||||||
|
*/ |
||||||
|
public function load(array $incomingData) |
||||||
|
{ |
||||||
|
$em = \Database::getManager(); |
||||||
|
|
||||||
|
$itemViewId = parent::load($incomingData); |
||||||
|
|
||||||
|
$itemView = $em->find('ChamiloCourseBundle:CLpItemView', $itemViewId); |
||||||
|
|
||||||
|
if ((bool) $incomingData['is_correct']) { |
||||||
|
$itemView->setScore( |
||||||
|
$itemView->getMaxScore() |
||||||
|
); |
||||||
|
} else { |
||||||
|
$itemView->setScore(0); |
||||||
|
} |
||||||
|
|
||||||
|
$em->persist($itemView); |
||||||
|
$em->flush(); |
||||||
|
|
||||||
|
return $itemViewId; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,48 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
namespace Chamilo\PluginBundle\MigrationMoodle\Task; |
||||||
|
|
||||||
|
use Chamilo\PluginBundle\MigrationMoodle\Extractor\LoadedUsersFilterExtractor; |
||||||
|
use Chamilo\PluginBundle\MigrationMoodle\Loader\UserLearnPathLessonAttemptLoader; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class UsersLearnPathsLessonAttemptsTask. |
||||||
|
* |
||||||
|
* @package Chamilo\PluginBundle\MigrationMoodle\Task |
||||||
|
*/ |
||||||
|
class UsersLearnPathsLessonAttemptsTask extends UsersLearnPathsLessonBranchTask |
||||||
|
{ |
||||||
|
/** |
||||||
|
* @inheritDoc |
||||||
|
*/ |
||||||
|
public function getExtractConfiguration() |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'class' => LoadedUsersFilterExtractor::class, |
||||||
|
'query' => "SELECT * FROM mdl_lesson_attempts", |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @inheritDoc |
||||||
|
*/ |
||||||
|
public function getTransformConfiguration() |
||||||
|
{ |
||||||
|
$config = parent::getTransformConfiguration(); |
||||||
|
|
||||||
|
$config['map']['is_correct'] = 'correct'; |
||||||
|
|
||||||
|
return $config; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @inheritDoc |
||||||
|
*/ |
||||||
|
public function getLoadConfiguration() |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'class' => UserLearnPathLessonAttemptLoader::class, |
||||||
|
]; |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue