function opigno_learning_path_is_attempted in Opigno Learning path 8
Same name and namespace in other branches
- 3.x opigno_learning_path.module \opigno_learning_path_is_attempted()
Returns attempted flag.
Parameters
array|\Drupal\group\Entity\GroupInterface $step: Learning Path or Course Group entity, or step array, returned by opigno_learning_path_get_steps()
int $uid: User ID.
Return value
bool Attempted flag.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
6 calls to opigno_learning_path_is_attempted()
- LearningPathAchievementController::build_lp_steps in src/
Controller/ LearningPathAchievementController.php - Returns LP steps.
- LearningPathAchievementController::build_step_score in src/
Controller/ LearningPathAchievementController.php - Returns step score renderable array.
- opigno_learning_path_get_steps in ./
opigno_learning_path.module - Builds up a list of steps in a group for a user.
- opigno_learning_path_get_steps_current_attempt in ./
opigno_learning_path.module - Builds a list of group steps for a user current attempt.
- opigno_learning_path_is_passed in ./
opigno_learning_path.module - Returns LP passed flag.
File
- ./
opigno_learning_path.module, line 3237 - Contains opigno_learning_path.module.
Code
function opigno_learning_path_is_attempted($step, $uid) {
if (is_array($step)) {
if ($step['typology'] === 'Course') {
$steps = opigno_learning_path_get_steps($step['id'], $uid);
}
else {
return $step['attempts'] > 0;
}
}
else {
$steps = opigno_learning_path_get_steps($step
->id(), $uid);
}
// If at least one step has attempted.
return !empty(array_filter($steps, function ($step) use ($uid) {
return opigno_learning_path_is_attempted($step, $uid);
}));
}