private function OpignoLinkConditionTest::finishCurrentModuleAttempt in Opigno Learning path 8
Same name and namespace in other branches
- 3.x tests/src/Functional/OpignoLinkConditionTest.php \Drupal\Tests\opigno_learning_path\Functional\OpignoLinkConditionTest::finishCurrentModuleAttempt()
Force finish module current attempt.
1 call to OpignoLinkConditionTest::finishCurrentModuleAttempt()
- OpignoLinkConditionTest::testLinkCondition in tests/
src/ Functional/ OpignoLinkConditionTest.php - Test.
File
- tests/
src/ Functional/ OpignoLinkConditionTest.php, line 105
Class
- OpignoLinkConditionTest
- Tests Opigno Group Link behavior.
Namespace
Drupal\Tests\opigno_learning_path\FunctionalCode
private function finishCurrentModuleAttempt($stack, $training, OpignoModule $module, UserInterface $user, $score) {
/* @var \Drupal\opigno_module\Entity\UserModuleStatus $current_attempt */
$current_attempt = $module
->getModuleActiveAttempt($user);
$current_attempt
->setModule($module);
$current_attempt
->setScore($score);
$current_attempt
->setMaxScore(70);
$current_attempt
->setEvaluated(1);
$current_attempt
->setFinished(time());
$current_attempt
->save();
// Reset all static variables.
$stack
->resetAll();
// Save all achievements.
$step = opigno_learning_path_get_module_step($training
->id(), $user
->id(), $module);
$step['best score'] = $step['current attempt score'] = $score;
opigno_learning_path_save_step_achievements($training
->id(), $user
->id(), $step);
opigno_learning_path_save_achievements($training
->id(), $user
->id());
}