You are here

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

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

Calculates progress in a group for a user.

Parameters

int $group_id: Group ID.

int $uid: User ID.

int $latest_cert_date: Latest certification date.

Return value

float Attempted activities count / total activities count.

1 call to Progress::getProgress()
Progress::getProgressRound in src/Progress.php
Get round integer of progress.

File

src/Progress.php, line 67

Class

Progress
Class JoinService.

Namespace

Drupal\opigno_learning_path

Code

public function getProgress($group_id, $account_id, $latest_cert_date) {
  $activities = opigno_learning_path_get_activities($group_id, $account_id, $latest_cert_date);
  $total = count($activities);
  $attempted = count(array_filter($activities, function ($activity) {
    return $activity['answers'] > 0;
  }));
  return $total > 0 ? $attempted / $total : 0;
}