You are here

public function Progress::buildSummary in Opigno Learning path 3.x

1 call to Progress::buildSummary()
Progress::getProgressBuildGroupPage in src/Progress.php
Get get progress for group page.

File

src/Progress.php, line 420

Class

Progress
Class JoinService.

Namespace

Drupal\opigno_learning_path

Code

public function buildSummary($group, $account) : array {
  $uid = $account
    ->id();
  $gid = (int) $group
    ->id();

  // Get user training expiration flag.
  $expired = LPStatus::isCertificateExpired($group, $uid);
  $status = $this
    ->getProgressAchievementsData($gid, $uid);
  $result = LPResult::getCurrentLPAttempt($group, $account);
  $is_passed = opigno_learning_path_is_passed($group, $uid, $expired);
  return isset($result->started) ? [
    '#theme' => 'opigno_learning_path_step_block_progress',
    '#passed' => $is_passed,
    '#expired' => $expired,
    '#has_experation_date' => LPStatus::isCertificateExpireSet($group),
    '#expired_date' => LPStatus::getCertificateExpireTimestamp($gid, $uid),
    '#complite_date' => strtotime($status["registered"]) ?? 0,
    '#started_date' => $result->started->value ?? 0,
  ] : [];
}