You are here

function opigno_learning_path_is_attempted in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 opigno_learning_path.module \opigno_learning_path_is_attempted()

Returns attempted flag.

Parameters

array|\Drupal\group\Entity\GroupInterface $step: Learning Path or Course Group entity, or step array, returned by opigno_learning_path_get_steps()

int $uid: User ID.

Return value

bool Attempted flag.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

7 calls to opigno_learning_path_is_attempted()
LearningPathAchievementController::build_course_steps in src/Controller/LearningPathAchievementController.php
Returns course steps renderable array.
LearningPathAchievementController::build_lp_steps in src/Controller/LearningPathAchievementController.php
Returns LP steps.
LearningPathAchievementController::build_step_score in src/Controller/LearningPathAchievementController.php
Returns step score renderable array.
opigno_learning_path_get_steps in ./opigno_learning_path.module
Builds up a list of steps in a group for a user.
opigno_learning_path_get_steps_current_attempt in ./opigno_learning_path.module
Builds a list of group steps for a user current attempt.

... See full list

File

./opigno_learning_path.module, line 3146
Contains opigno_learning_path.module.

Code

function opigno_learning_path_is_attempted($step, $uid) {
  if (is_array($step)) {
    if ($step['typology'] === 'Course') {
      $steps = opigno_learning_path_get_steps($step['id'], $uid);
    }
    else {
      return $step['attempts'] > 0;
    }
  }
  else {
    $steps = opigno_learning_path_get_steps($step
      ->id(), $uid);
  }

  // If at least one step has attempted.
  return !empty(array_filter($steps, function ($step) use ($uid) {
    return opigno_learning_path_is_attempted($step, $uid);
  }));
}