protected function LearningPathAchievementController::course_steps_passed in Opigno Learning path 3.x
Same name and namespace in other branches
- 8 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::getStatusPercentCourseByStep in src/
Controller/ LearningPathAchievementController.php - Gets an passed/percent of course state by the step.
File
- src/
Controller/ LearningPathAchievementController.php, line 584
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),
];
}