public function LearningPathContentController::countActivityInModule in Opigno Learning path 3.x
Same name and namespace in other branches
- 8 src/Controller/LearningPathContentController.php \Drupal\opigno_learning_path\Controller\LearningPathContentController::countActivityInModule()
Returns module activities count.
1 call to LearningPathContentController::countActivityInModule()
- LearningPathContentController::getModules in src/
Controller/ LearningPathContentController.php - This method is called on learning path load.
File
- src/
Controller/ LearningPathContentController.php, line 328
Class
- LearningPathContentController
- Controller for all the actions of the Learning Path content.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function countActivityInModule(OpignoModule $opigno_module) {
/* @var $db_connection \Drupal\Core\Database\Connection */
$db_connection = \Drupal::service('database');
$query = $db_connection
->select('opigno_activity', 'oa');
$query
->fields('oa', [
'id',
]);
$query
->fields('omr', [
'omr_pid',
'child_id',
]);
$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');
$result = $query
->execute();
$result->allowRowCount = TRUE;
return $result
->rowCount();
}