public function LpSteps::getTimeSpent in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/LpSteps.php \Drupal\opigno_learning_path\LpSteps::getTimeSpent()
Get Time spent.
Parameters
array $attempts: List of attempts.
Return value
numeric Time was spending for attempts.
1 call to LpSteps::getTimeSpent()
- LpSteps::getModuleStep in src/
LpSteps.php - Get list of module steps.
File
- src/
LpSteps.php, line 454
Class
Namespace
Drupal\opigno_learning_pathCode
public function getTimeSpent($attempts) {
return array_sum(array_map(function ($attempt) {
/** @var \Drupal\opigno_module\Entity\UserModuleStatus $attempt */
$started = (int) $attempt
->get('started')
->getString();
$finished = (int) $attempt
->get('finished')
->getString();
return $finished > $started ? $finished - $started : 0;
}, $attempts));
}