ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLPStatusTypicalLearningTime.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=0);
4 
5 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
6 
12 {
13  public static function _getInProgress(int $a_obj_id): array
14  {
15  global $DIC;
16 
17  $ilDB = $DIC['ilDB'];
18 
19  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
20  $tlt = $status_info['tlt'];
21 
22  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
23 
24  $user_ids = [];
25  foreach ($all as $event) {
26  if ($event['spent_seconds'] < $tlt) {
27  $user_ids[] = (int) $event['usr_id'];
28  }
29  }
30  return $user_ids;
31  }
32 
33  public static function _getCompleted(int $a_obj_id): array
34  {
35  global $DIC;
36 
37  $ilDB = $DIC['ilDB'];
38 
39  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
40  $tlt = $status_info['tlt'];
41  // TODO: move to status info
42  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
43 
44  $user_ids = [];
45  foreach ($all as $event) {
46  if ($event['spent_seconds'] >= $tlt) {
47  $user_ids[] = (int) $event['usr_id'];
48  }
49  }
50  return $user_ids;
51  }
52 
53  public static function _getStatusInfo(int $a_obj_id): array
54  {
56  $a_obj_id
57  );
58  return $status_info;
59  }
60 
61  public function determineStatus(
62  int $a_obj_id,
63  int $a_usr_id,
64  object $a_obj = null
65  ): int {
66  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
67  switch ($this->ilObjDataCache->lookupType($a_obj_id)) {
68  case 'lm':
69  if (ilChangeEvent::hasAccessed($a_obj_id, $a_usr_id)) {
70  $status = self::LP_STATUS_IN_PROGRESS_NUM;
71 
72  // completed?
73  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
74  $tlt = $status_info['tlt'];
75 
77  $a_obj_id,
78  $a_usr_id
79  );
80  if ($re[0]['spent_seconds'] >= $tlt) {
81  $status = self::LP_STATUS_COMPLETED_NUM;
82  }
83  }
84  break;
85  }
86  return $status;
87  }
88 
89  public function determinePercentage(
90  int $a_obj_id,
91  int $a_usr_id,
92  ?object $a_obj = null
93  ): int {
95  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_usr_id);
96  $spent = (int) ($re[0]["spent_seconds"] ?? 0);
97 
98  if ($tlt > 0) {
99  $per = min(100, 100 / $tlt * $spent);
100  } else {
101  $per = 100;
102  }
103  return $per;
104  }
105 }
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
static hasAccessed(int $a_obj_id, int $a_usr_id)
Has accessed.
global $DIC
Definition: feed.php:28
static _getTypicalLearningTimeSeconds(int $a_rbac_id, int $a_obj_id=0)
determinePercentage(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
static _lookupReadEvents($obj_id, $usr_id=null)
Reads all read events which occured on the object.
determineStatus(int $a_obj_id, int $a_usr_id, object $a_obj=null)