You are here

public static function LPResult::getCurrentLPAttempt in Opigno Learning path 3.x

Same name and namespace in other branches
  1. 8 src/Entity/LPResult.php \Drupal\opigno_learning_path\Entity\LPResult::getCurrentLPAttempt()

Returns LP attempt.

3 calls to LPResult::getCurrentLPAttempt()
LearningPathStepsController::finish in src/Controller/LearningPathStepsController.php
Show the finish page and save the score.
opigno_learning_path_started in ./opigno_learning_path.module
Function to detect if user already started Learning path.
Progress::buildSummary in src/Progress.php

File

src/Entity/LPResult.php, line 195

Class

LPResult
Defines the Learning Path Content entity.

Namespace

Drupal\opigno_learning_path\Entity

Code

public static function getCurrentLPAttempt(Group $group, AccountInterface $user) {
  $results_storage = \Drupal::entityTypeManager()
    ->getStorage('learning_path_result');
  $query = $results_storage
    ->getQuery();
  $results = $query
    ->condition('learning_path_id', $group
    ->id())
    ->condition('user_id', $user
    ->id())
    ->condition('finished', 0)
    ->execute();
  return !empty($results) ? $results_storage
    ->load(key($results)) : FALSE;
}