public function LearningPathContentController::getModuleActivitiesEntities in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathContentController.php \Drupal\opigno_learning_path\Controller\LearningPathContentController::getModuleActivitiesEntities()
Returns activities entities with the module.
2 calls to LearningPathContentController::getModuleActivitiesEntities()
- LearningPathContentController::getModuleActivities in src/
Controller/ LearningPathContentController.php - This method is called on learning path load.
- LearningPathContentController::getModuleConditionals in src/
Controller/ LearningPathContentController.php - Returns conditional activities with the module.
File
- src/
Controller/ LearningPathContentController.php, line 509
Class
- LearningPathContentController
- Controller for all the actions of the Learning Path content.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function getModuleActivitiesEntities(OpignoModule $opigno_module) {
$activities = [];
/* @var $db_connection \Drupal\Core\Database\Connection */
$db_connection = \Drupal::service('database');
$query = $db_connection
->select('opigno_activity', 'oa');
$query
->fields('oafd', [
'id',
'vid',
'type',
'name',
]);
$query
->fields('omr', [
'weight',
'max_score',
'auto_update_max_score',
'omr_id',
'omr_pid',
'child_id',
'child_vid',
]);
$query
->addJoin('inner', 'opigno_activity_field_data', 'oafd', 'oa.id = oafd.id');
$query
->addJoin('inner', 'opigno_module_relationship', 'omr', 'oa.id = omr.child_id');
$query
->condition('oafd.status', 1);
$query
->condition('omr.parent_id', $opigno_module
->id());
if ($opigno_module
->getRevisionId()) {
$query
->condition('omr.parent_vid', $opigno_module
->getRevisionId());
}
$query
->condition('omr_pid', NULL, 'IS');
$query
->orderBy('omr.weight');
$result = $query
->execute();
foreach ($result as $activity) {
$activities[$activity->id] = $activity;
}
return $activities;
}