ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
19  function __construct($a_obj_id)
20  {
21  global $ilDB;
22 
23  parent::__construct($a_obj_id);
24  $this->db = $ilDB;
25  }
26 
27  static function _getInProgress($a_obj_id)
28  {
29  global $ilDB;
30 
31  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
32  $tlt = $status_info['tlt'];
33 
34  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
35  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
36 
37  foreach($all as $event)
38  {
39  if($event['spent_seconds'] < $tlt)
40  {
41  $user_ids[] = $event['usr_id'];
42  }
43  }
44  return $user_ids ? $user_ids : array();
45  }
46 
47  static function _getCompleted($a_obj_id)
48  {
49  global $ilDB;
50 
51  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
52  $tlt = $status_info['tlt'];
53 
54  // TODO: move to status info
55  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
56  $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
57 
58  foreach($all as $event)
59  {
60  if($event['spent_seconds'] >= $tlt)
61  {
62  $user_ids[] = $event['usr_id'];
63  }
64  }
65  return $user_ids ? $user_ids : array();
66  }
67 
68  static function _getStatusInfo($a_obj_id)
69  {
70  $status_info['tlt'] = ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
71 
72  return $status_info;
73  }
74 
83  function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
84  {
85  global $ilObjDataCache, $ilDB;
86 
87  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
88  switch ($ilObjDataCache->lookupType($a_obj_id))
89  {
90  case 'lm':
91  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
92  {
93  $status = self::LP_STATUS_IN_PROGRESS_NUM;
94 
95  // completed?
96  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
97  $tlt = $status_info['tlt'];
98 
99  include_once './Services/Tracking/classes/class.ilChangeEvent.php';
100  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
101  if ($re[0]['spent_seconds'] >= $tlt)
102  {
103  $status = self::LP_STATUS_COMPLETED_NUM;
104  }
105  }
106  break;
107  }
108  return $status;
109  }
110 
119  function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
120  {
121  $tlt = (int) ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
122  $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
123  $spent = (int) $re[0]["spent_seconds"];
124 
125  if ($tlt > 0)
126  {
127  $per = min(100, 100 / $tlt * $spent);
128  }
129  else
130  {
131  $per = 100;
132  }
133 
134  return $per;
135  }
136 }
137 ?>
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
static _getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
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 ...
Create styles array
The data for the language used.
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 ...