You are here

protected function LearningPathAchievementController::getTargetAttempt in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 src/Controller/LearningPathAchievementController.php \Drupal\opigno_learning_path\Controller\LearningPathAchievementController::getTargetAttempt()

Get last or best user attempt for Module.

Parameters

array $attempts: User module attempts.

\Drupal\opigno_module\Entity\OpignoModule $module: Module.

Return value

\Drupal\opigno_module\Entity\UserModuleStatus $attempt

3 calls to LearningPathAchievementController::getTargetAttempt()
LearningPathAchievementController::build_module_panel in src/Controller/LearningPathAchievementController.php
Returns module panel renderable array.
LearningPathAchievementController::getApprovedModuleByStep in src/Controller/LearningPathAchievementController.php
Gets an approved state by the step.
LearningPathAchievementController::module_approved_activities in src/Controller/LearningPathAchievementController.php
Returns module approved activities.

File

src/Controller/LearningPathAchievementController.php, line 1109

Class

LearningPathAchievementController
Class LearningPathAchievementController.

Namespace

Drupal\opigno_learning_path\Controller

Code

protected function getTargetAttempt(array $attempts, OpignoModule $module) {
  if ($module
    ->getKeepResultsOption() == 'newest') {
    $attempt = end($attempts);
  }
  else {
    $attempt = opigno_learning_path_best_attempt($attempts);
  }
  return $attempt;
}