You are here

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

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

2 calls to LearningPathAchievementTrait::getTargetAttempt()
LearningPathAchievementTrait::getActivities in src/Traits/LearningPathAchievementTrait.php
Gets the activities list by the group and module.
LearningPathAchievementTrait::getActivityStatus in src/Traits/LearningPathAchievementTrait.php
Gets a statuses of activities.

File

src/Traits/LearningPathAchievementTrait.php, line 121

Class

LearningPathAchievementTrait
LearningPathAchievementTrait trait.

Namespace

Drupal\opigno_learning_path\Traits

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