protected function LearningPathAchievementController::course_steps_passed in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathAchievementController.php \Drupal\opigno_learning_path\Controller\LearningPathAchievementController::course_steps_passed()
Returns course passed steps.
Parameters
\Drupal\group\Entity\GroupInterface $training: Parent training group entity.
\Drupal\group\Entity\GroupInterface $course: Course group entity.
Return value
array Course passed steps.
1 call to LearningPathAchievementController::course_steps_passed()
- LearningPathAchievementController::build_lp_steps in src/
Controller/ LearningPathAchievementController.php - Returns LP steps.
File
- src/
Controller/ LearningPathAchievementController.php, line 613
Class
- LearningPathAchievementController
- Class LearningPathAchievementController.
Namespace
Drupal\opigno_learning_path\ControllerCode
protected function course_steps_passed(GroupInterface $training, GroupInterface $course, $latest_cert_date = NULL) {
$user = $this
->currentUser();
$steps = opigno_learning_path_get_steps($course
->id(), $user
->id(), NULL, $latest_cert_date);
$passed = 0;
foreach ($steps as $step) {
$status = opigno_learning_path_get_step_status($step, $user
->id(), FALSE, $latest_cert_date);
if ($status == 'passed') {
$passed++;
}
}
return [
'passed' => $passed,
'total' => count($steps),
];
}