function opigno_learning_path_best_attempt in Opigno Learning path 8
Same name and namespace in other branches
- 3.x opigno_learning_path.module \opigno_learning_path_best_attempt()
Select best attempt from list.
Parameters
array $attempts: List of attempts.
Return value
object Best Attempt.
4 calls to opigno_learning_path_best_attempt()
- LearningPathAchievementController::getTargetAttempt in src/
Controller/ LearningPathAchievementController.php - Get last or best user attempt for Module.
- LearningPathStepsController::getTargetAttempt in src/
Controller/ LearningPathStepsController.php - Get last or best user attempt for Module.
- opigno_learning_path_get_all_steps in ./
opigno_learning_path.module - Builds up a full list of all the steps in a group for a user.
- opigno_learning_path_get_steps in ./
opigno_learning_path.module - Builds up a list of steps in a group for a user.
File
- ./
opigno_learning_path.module, line 2813 - Contains opigno_learning_path.module.
Code
function opigno_learning_path_best_attempt(array $attempts) {
usort($attempts, function ($a, $b) {
/** @var \Drupal\opigno_module\Entity\UserModuleStatus $a */
/** @var \Drupal\opigno_module\Entity\UserModuleStatus $b */
$b_score = $b
->getAttemptScore();
$a_score = $a
->getAttemptScore();
return $b_score - $a_score;
});
return reset($attempts);
}