You are here

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

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

Get get progress bar it self.

Parameters

int|string $group_id: Group ID.

int|string $account_id: User ID.

int|string $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 189

Class

Progress
Class JoinService.

Namespace

Drupal\opigno_learning_path

Code

public function getProgressBuild($group_id, $account_id, $latest_cert_date, string $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':

      // @todo We can reuse a getProgressBuildGroupPage method.
      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':
    case 'mini':

      // Full: value, mini - with the progress bar.
      return [
        '#theme' => 'opigno_learning_path_progress',
        '#value' => $this
          ->getProgressRound($group_id, $account_id, $latest_cert_date),
        '#show_bar' => $class === 'mini',
      ];
    case 'circle':
      return [
        '#theme' => 'lp_circle_progress',
        '#radius' => 31,
        '#progress' => $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);
  }
}