You are here

protected function LearningPathAchievementController::getTargetAttempt in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x 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_lp_steps in src/Controller/LearningPathAchievementController.php
Returns LP steps.
LearningPathAchievementController::build_module_panel in src/Controller/LearningPathAchievementController.php
Returns module panel renderable array.
LearningPathAchievementController::module_approved_activities in src/Controller/LearningPathAchievementController.php
Returns module approved activities.

File

src/Controller/LearningPathAchievementController.php, line 1112

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;
}