You are here

public function Progress::getProgressBuild in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/Progress.php \Drupal\opigno_learning_path\Progress::getProgressBuild()

Get get progress bar it self.

Parameters

int $group_id: Group ID.

int $uid: User ID.

int $latest_cert_date: Latest certification date.

string $class: identifier for progress bar.

Return value

array Renderable array.

1 call to Progress::getProgressBuild()
Progress::getProgressAjaxContainer in src/Progress.php
Get html container where progress will be loaded via ajax.

File

src/Progress.php, line 173

Class

Progress
Class JoinService.

Namespace

Drupal\opigno_learning_path

Code

public function getProgressBuild($group_id, $account_id, $latest_cert_date, $class) {

  // If $latest_cert_date argument is 0 than it means it empty;
  if ($latest_cert_date === 0) {
    $latest_cert_date = '';
  }

  // Progress should be shown only for member of group.
  $group = Group::load($group_id);
  $account = User::load($account_id);
  $existing = $group
    ->getMember($account);
  if ($existing === FALSE) {
    $class = 'empty';
  }
  switch ($class) {
    case 'group-page':
      return $this
        ->getProgressBuildGroupPage($group_id, $account_id, $latest_cert_date);
    case 'module-page':
      return $this
        ->getProgressBuildModulePage($group_id, $account_id, $latest_cert_date);
    case 'achievements-page':
      return $this
        ->getProgressBuildAchievementsPage($group_id, $account_id, $latest_cert_date);
    case 'full':

      // Full: label, value, bar.
      return [
        '#theme' => 'opigno_learning_path_progress',
        '#label' => $this
          ->t('Some title'),
        '#class' => $class,
        '#value' => $this
          ->getProgressRound($group_id, $account_id, $latest_cert_date),
      ];
    case 'mini':

      // Mini: value, bar.
      return [
        '#theme' => 'opigno_learning_path_progress',
        '#class' => $class,
        '#value' => $this
          ->getProgressRound($group_id, $account_id, $latest_cert_date),
      ];
    case 'empty':

      // Empty progress.
      return [
        '#markup' => '',
      ];
    default:

      // Only value.
      return $this
        ->getProgressRound($group_id, $account_id, $latest_cert_date);
  }
}