public function LearningPathContentController::getModuleRequiredActivities in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathContentController.php \Drupal\opigno_learning_path\Controller\LearningPathContentController::getModuleRequiredActivities()
Returns conditional activities with the module.
Parameters
string $opigno_entity_type: Entity type, like "ContentTypeModule" or "ContentTypeCourse".
string $opigno_entity_id: Entity ID.
Return value
\Symfony\Component\HttpFoundation\JsonResponse Json response.
1 string reference to 'LearningPathContentController::getModuleRequiredActivities'
File
- src/
Controller/ LearningPathContentController.php, line 479
Class
- LearningPathContentController
- Controller for all the actions of the Learning Path content.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function getModuleRequiredActivities($opigno_entity_type, $opigno_entity_id) {
$results = [
'conditional' => [],
'simple' => TRUE,
];
if ($opigno_entity_type == 'ContentTypeModule') {
$opigno_module = OpignoModule::load($opigno_entity_id);
$this
->getModuleConditionals($opigno_module, $results);
}
if ($opigno_entity_type == 'ContentTypeCourse') {
$course_steps = OpignoGroupManagedContent::loadByGroupId($opigno_entity_id);
if (!empty($course_steps)) {
// Check if each course module has at least one activity.
foreach ($course_steps as $course_step) {
$id = $course_step
->getEntityId();
$opigno_module = OpignoModule::load($id);
$this
->getModuleConditionals($opigno_module, $results);
}
}
}
// Return all the contents in JSON format.
return new JsonResponse($results, Response::HTTP_OK);
}