public function LearningPathStepsController::finish in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathStepsController.php \Drupal\opigno_learning_path\Controller\LearningPathStepsController::finish()
Show the finish page and save the score.
1 string reference to 'LearningPathStepsController::finish'
File
- src/
Controller/ LearningPathStepsController.php, line 623
Class
- LearningPathStepsController
- Class LearningPathStepsController.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function finish(Group $group) {
// Get the "user passed" status.
$current_uid = \Drupal::currentUser()
->id();
$user_passed = LearningPathValidator::userHasPassed($current_uid, $group);
if ($user_passed) {
// Store the result in database.
$current_result_attempt = LPResult::getCurrentLPAttempt($group, \Drupal::currentUser());
if ($current_result_attempt) {
$current_result_attempt
->setHasPassed($user_passed);
$current_result_attempt
->setFinished(\Drupal::time()
->getRequestTime());
$current_result_attempt
->save();
}
else {
// Store the result in database.
$result = LPResult::createWithValues($group
->id(), $current_uid, $user_passed, \Drupal::time()
->getRequestTime());
$result
->save();
}
return $this
->failedStep('passed');
}
else {
return $this
->failedStep('failed');
}
}