You are here

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

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

Get round integer of progress.

Parameters

int $group_id: Group ID.

int $uid: User ID.

int $latest_cert_date: Latest certification date.

Return value

integer Attempted activities count / total activities count.

4 calls to Progress::getProgressRound()
Progress::getProgressBuild in src/Progress.php
Get get progress bar it self.
Progress::getProgressBuildAchievementsPage in src/Progress.php
Get get progress for achievements page.
Progress::getProgressBuildGroupPage in src/Progress.php
Get get progress for group page.
Progress::getProgressBuildModulePage in src/Progress.php
Get get progress for module page.

File

src/Progress.php, line 107

Class

Progress
Class JoinService.

Namespace

Drupal\opigno_learning_path

Code

public function getProgressRound($group_id, $account_id, $latest_cert_date = '') {

  // Firstly check achievements data.
  $query = $this->database
    ->select('opigno_learning_path_achievements', 'a')
    ->fields('a', [
    'score',
  ])
    ->condition('a.gid', $group_id)
    ->condition('a.uid', $account_id)
    ->condition('a.status', 'completed');
  $achievements_data = $query
    ->execute()
    ->fetchAssoc();
  if ($achievements_data) {
    return $achievements_data['score'];
  }
  if (!$latest_cert_date) {
    $group = Group::load($group_id);
    $latest_cert_date = LPStatus::getTrainingStartDate($group, $account_id);
  }
  return round(100 * $this
    ->getProgress($group_id, $account_id, $latest_cert_date));
}