function opigno_module_get_activities in Opigno module 3.x
Same name and namespace in other branches
- 8 opigno_module.module \opigno_module_get_activities()
Helper function.
Get Activities related to specific module.
File
- ./
opigno_module.module, line 748 - Contains opigno_module.module.
Code
function opigno_module_get_activities($module_id, $module_vid = NULL) {
/* @todo join table with activity revisions */
$questions = [];
/* @var $db_connection \Drupal\Core\Database\Connection */
$db_connection = \Drupal::service('database');
$query = $db_connection
->select('opigno_activity', 'oa');
$query
->fields('oafd', [
'id',
'type',
'name',
]);
$query
->fields('omr', [
'activity_status',
'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_vid');
$query
->condition('oafd.status', 1);
$query
->condition('omr.parent_id', $module_id);
if ($module_vid) {
$query
->condition('omr.parent_vid', $module_vid);
}
$query
->condition('omr_pid', NULL, 'IS');
$query
->orderBy('omr.weight');
$result = $query
->execute();
foreach ($result as $question) {
$questions[] = $question;
}
return $questions;
}