private function OpignoModuleScoreTest::createAndFinishAttempt in Opigno Learning path 8
Same name and namespace in other branches
- 3.x tests/src/Functional/OpignoModuleScoreTest.php \Drupal\Tests\opigno_learning_path\Functional\OpignoModuleScoreTest::createAndFinishAttempt()
Creates and finishes attempt.
1 call to OpignoModuleScoreTest::createAndFinishAttempt()
- OpignoModuleScoreTest::testModuleScoreDisplay in tests/
src/ Functional/ OpignoModuleScoreTest.php - Test Opigno Module score on different pages (achievements, statistics etc).
File
- tests/
src/ Functional/ OpignoModuleScoreTest.php, line 116
Class
- OpignoModuleScoreTest
- Tests Opigno module score display.
Namespace
Drupal\Tests\opigno_learning_path\FunctionalCode
private function createAndFinishAttempt($training, $module, $user, $score, $newest = FALSE) {
$attempt = UserModuleStatus::create([]);
$attempt
->setModule($module);
$attempt
->setScore($score);
$attempt
->setEvaluated(1);
$attempt
->setFinished(time());
$attempt
->save();
// Reset all static variables.
drupal_static_reset();
// Save all achievements.
$step = opigno_learning_path_get_module_step($training
->id(), $user
->id(), $module);
if ($newest) {
$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());
return $attempt;
}