ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilLPStatusTypicalLearningTime.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/Tracking/classes/class.ilLPStatus.php';
6 include_once './Services/MetaData/classes/class.ilMDEducational.php'; // #15556
7 
17 {
18  public function __construct($a_obj_id)
19  {
20  global $DIC;
21 
22  $ilDB = $DIC['ilDB'];
23 
24  parent::__construct($a_obj_id);
25  $this->db = $ilDB;
26  }
27 
28  public static function _getInProgress($a_obj_id)
29  {
30  global $DIC;
31 
32  $ilDB = $DIC['ilDB'];
33 
34  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
35  $tlt = $status_info['tlt'];
36 
37  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
38  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
39 
40  foreach ($all as $event) {
41  if ($event['spent_seconds'] < $tlt) {
42  $user_ids[] = $event['usr_id'];
43  }
44  }
45  return $user_ids ? $user_ids : array();
46  }
47 
48  public static function _getCompleted($a_obj_id)
49  {
50  global $DIC;
51 
52  $ilDB = $DIC['ilDB'];
53 
54  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
55  $tlt = $status_info['tlt'];
56 
57  // TODO: move to status info
58  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
59  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
60 
61  foreach ($all as $event) {
62  if ($event['spent_seconds'] >= $tlt) {
63  $user_ids[] = $event['usr_id'];
64  }
65  }
66  return $user_ids ? $user_ids : array();
67  }
68 
69  public static function _getStatusInfo($a_obj_id)
70  {
71  $status_info['tlt'] = ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
72 
73  return $status_info;
74  }
75 
84  public function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
85  {
86  global $DIC;
87 
88  $ilObjDataCache = $DIC['ilObjDataCache'];
89  $ilDB = $DIC['ilDB'];
90 
91  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
92  switch ($ilObjDataCache->lookupType($a_obj_id)) {
93  case 'lm':
94  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
95  $status = self::LP_STATUS_IN_PROGRESS_NUM;
96 
97  // completed?
98  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
99  $tlt = $status_info['tlt'];
100 
101  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
102  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
103  if ($re[0]['spent_seconds'] >= $tlt) {
104  $status = self::LP_STATUS_COMPLETED_NUM;
105  }
106  }
107  break;
108  }
109  return $status;
110  }
111 
120  public function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
121  {
122  $tlt = (int) ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
123  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
124  $spent = (int) $re[0]["spent_seconds"];
125 
126  if ($tlt > 0) {
127  $per = min(100, 100 / $tlt * $spent);
128  } else {
129  $per = 100;
130  }
131 
132  return $per;
133  }
134 }
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
static _getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
global $DIC
Definition: saml.php:7
determinePercentage($a_obj_id, $a_user_id, $a_obj=null)
Determine percentage.
static _lookupReadEvents($obj_id, $usr_id=null)
Reads all read events which occured on the object which happened after the last time the user caught ...
static _getStatusInfo($a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
Determine status.
global $ilDB
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...