You are here

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

Same name and namespace in other branches
  1. 8 src/Controller/LearningPathStepsController.php \Drupal\opigno_learning_path\Controller\LearningPathStepsController::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

1 call to LearningPathStepsController::getTargetAttempt()
LearningPathStepsController::getNextStep in src/Controller/LearningPathStepsController.php
Redirect the user to the next step.

File

src/Controller/LearningPathStepsController.php, line 796

Class

LearningPathStepsController
Class LearningPathStepsController.

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