You are here

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

If step is module prepares a render array of content.

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

File

src/Controller/LearningPathAchievementController.php, line 1197

Class

LearningPathAchievementController
Class LearningPathAchievementController.

Namespace

Drupal\opigno_learning_path\Controller

Code

protected function trainingStepModuleBuild($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') : '';
  $completed = $completed ?: '';
  list($approved, $approved_percent, ) = $this
    ->getApprovedModuleByStep($step, $user, $latest_cert_date, $group);
  $badges = $this
    ->getModulesStatusBadges($step, $group, $user
    ->id());

  /** @var \Drupal\opigno_module\Entity\OpignoModule $module */
  $module = OpignoModule::load($step['id']);
  return [
    '#theme' => 'opigno_learning_path_training_module',
    '#status' => $this
      ->mapStatusToTemplateClasses($step['status']),
    '#group_id' => $group
      ->id(),
    '#step' => $step,
    '#time_spent' => $time_spent,
    '#completed' => $completed,
    '#badges' => $badges,
    '#approved' => [
      'value' => $approved,
      'percent' => $approved_percent,
    ],
    '#activities' => $this
      ->build_module_panel($group, NULL, $module, $user),
  ];
}