You are here

protected function LearningPathAchievementController::trainingStepCourseBuild in Opigno Learning path 3.x

If step is course prepares a render array of content.

1 call to LearningPathAchievementController::trainingStepCourseBuild()
LearningPathAchievementController::trainingStepContentBuild in src/Controller/LearningPathAchievementController.php
Prepares a render array of content.

File

src/Controller/LearningPathAchievementController.php, line 1230

Class

LearningPathAchievementController
Class LearningPathAchievementController.

Namespace

Drupal\opigno_learning_path\Controller

Code

protected function trainingStepCourseBuild($step, $group, $user, $latest_cert_date = NULL) : array {
  $time_spent = $this
    ->getTimeSpentByStep($step);
  $completed = $this
    ->getComplitedByStep($step);
  $time_spent = $time_spent ? $this->dateFormatter
    ->formatInterval($time_spent) : 0;
  $completed = $completed ? $this->dateFormatter
    ->format($completed, 'custom', 'm/d/Y') : '';
  $badges = $this
    ->getModulesStatusBadges($step, $group, $user
    ->id());
  list($passed, $passed_percent, $score_percent) = $this
    ->getStatusPercentCourseByStep($step, $latest_cert_date, $group);
  return [
    '#type' => 'container',
    '#attributes' => [],
    [
      '#theme' => 'opigno_learning_path_training_course',
      '#passed' => [
        'value' => $passed,
        'percent' => $passed_percent,
      ],
      '#score' => $score_percent,
      '#step' => $step,
      '#completed' => $completed,
      '#badges' => $badges,
      '#time_spent' => $time_spent,
    ],
    $this
      ->build_course_steps($group, Group::load($step['id'])),
  ];
}