ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLPStatusWrapper.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.ilLPStatusFactory.php';
6 
19 {
20  private static $status_cache = array();
21  private static $info_cache = array();
22  private static $failed_cache = array();
23  private static $completed_cache = array();
24  private static $in_progress_cache = array();
25  private static $not_attempted_cache = array();
26 
30  public static function _getCountNotAttempted($a_obj_id)
31  {
32  return count(ilLPStatusWrapper::_getNotAttempted($a_obj_id));
33  }
34 
38  public static function _getNotAttempted($a_obj_id)
39  {
40  if (isset(self::$not_attempted_cache[$a_obj_id])) {
41  return self::$not_attempted_cache[$a_obj_id];
42  }
43 
44  $class = ilLPStatusFactory::_getClassById($a_obj_id);
45  self::$not_attempted_cache[$a_obj_id] = $class::_getNotAttempted($a_obj_id);
46 
47  return self::$not_attempted_cache[$a_obj_id];
48  }
49 
53  public static function _getCountInProgress($a_obj_id)
54  {
55  return count(ilLPStatusWrapper::_getInProgress($a_obj_id));
56  }
57 
61  public static function _getInProgress($a_obj_id)
62  {
63  if (isset(self::$in_progress_cache[$a_obj_id])) {
64  return self::$in_progress_cache[$a_obj_id];
65  }
66 
67  global $ilBench;
68 
69  $class = ilLPStatusFactory::_getClassById($a_obj_id);
70  self::$in_progress_cache[$a_obj_id] = $class::_getInProgress($a_obj_id);
71 
72  return self::$in_progress_cache[$a_obj_id];
73  }
74 
78  public static function _getCountCompleted($a_obj_id)
79  {
80  return count(ilLPStatusWrapper::_getCompleted($a_obj_id));
81  }
82 
86  public static function _getCompleted($a_obj_id)
87  {
88  if (isset(self::$completed_cache[$a_obj_id])) {
89  return self::$completed_cache[$a_obj_id];
90  }
91  $class = ilLPStatusFactory::_getClassById($a_obj_id);
92  self::$completed_cache[$a_obj_id] = $class::_getCompleted($a_obj_id);
93 
94  return self::$completed_cache[$a_obj_id];
95  }
96 
100  public static function _getCountFailed($a_obj_id)
101  {
102  return count(ilLPStatusWrapper::_getFailed($a_obj_id));
103  }
104 
108  public static function _getFailed($a_obj_id)
109  {
110  if (isset(self::$failed_cache[$a_obj_id])) {
111  return self::$failed_cache[$a_obj_id];
112  }
113 
114  $class = ilLPStatusFactory::_getClassById($a_obj_id);
115 
116  self::$failed_cache[$a_obj_id] = $class::_getFailed($a_obj_id);
117 
118  return self::$failed_cache[$a_obj_id];
119  }
120 
124  public static function _getStatusInfo($a_obj_id)
125  {
126  if (isset(self::$info_cache[$a_obj_id])) {
127  return self::$info_cache[$a_obj_id];
128  }
129 
130  $class = ilLPStatusFactory::_getClassById($a_obj_id);
131  self::$info_cache[$a_obj_id] = $class::_getStatusInfo($a_obj_id);
132  return self::$info_cache[$a_obj_id];
133  }
134 
135  public static function _resetInfoCaches($a_obj_id)
136  {
137  unset(self::$info_cache[$a_obj_id]);
138  unset(self::$failed_cache[$a_obj_id]);
139  unset(self::$completed_cache[$a_obj_id]);
140  unset(self::$in_progress_cache[$a_obj_id]);
141  unset(self::$not_attempted_cache[$a_obj_id]);
142  }
143 
147  public static function _getTypicalLearningTime($a_obj_id)
148  {
149  static $cache = array();
150 
151  if (isset($cache[$a_obj_id])) {
152  return $cache[$a_obj_id];
153  }
154 
155  $class = ilLPStatusFactory::_getClassById($a_obj_id);
156  $cache[$a_obj_id] = $class::_getTypicalLearningTime($a_obj_id);
157 
158  return $cache[$a_obj_id];
159  }
160 
162  // Special functions for 'objects' that have not an entry in object_data
163  // E.g. events
165 
169  public static function _getCountNotAttemptedByType($a_obj_id, $a_type)
170  {
171  return count(ilLPStatusWrapper::_getNotAttemptedByType($a_obj_id, $a_type));
172  }
173 
174  public static function _getNotAttemptedByType($a_obj_id, $a_type)
175  {
176  static $cache = array();
177 
178  if (isset($cache[$a_obj_id . '_' . $a_type])) {
179  return $cache[$a_obj_id . '_' . $a_type];
180  }
181 
182  $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
183  $cache[$a_obj_id . '_' . $a_type] = $class::_getNotAttempted($a_obj_id);
184 
185  return $cache[$a_obj_id . '_' . $a_type];
186  }
187 
188  public static function _getCountInProgressByType($a_obj_id, $a_type)
189  {
190  return count(ilLPStatusWrapper::_getInProgressByType($a_obj_id, $a_type));
191  }
192 
193  public static function _getInProgressByType($a_obj_id, $a_type)
194  {
195  static $cache = array();
196 
197  if (isset($cache[$a_obj_id . '_' . $a_type])) {
198  return $cache[$a_obj_id . '_' . $a_type];
199  }
200 
201  $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
202  $cache[$a_obj_id . '_' . $a_type] = $class::_getInProgress($a_obj_id);
203 
204  return $cache[$a_obj_id . '_' . $a_type];
205  }
206 
207  public static function _getCountCompletedByType($a_obj_id, $a_type)
208  {
209  return count(ilLPStatusWrapper::_getCompletedByType($a_obj_id, $a_type));
210  }
211 
212  public static function _getCompletedByType($a_obj_id, $a_type)
213  {
214  static $cache = array();
215 
216  if (isset($cache[$a_obj_id . '_' . $a_type])) {
217  return $cache[$a_obj_id . '_' . $a_type];
218  }
219 
220  $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
221  $cache[$a_obj_id . '_' . $a_type] = $class::_getCompleted($a_obj_id);
222 
223  return $cache[$a_obj_id . '_' . $a_type];
224  }
225 
226  public static function _getCountFailedByType($a_obj_id, $a_type)
227  {
228  return count(ilLPStatusWrapper::_getFailedByType($a_obj_id, $a_type));
229  }
230 
231  public static function _getFailedByType($a_obj_id, $a_type)
232  {
233  static $cache = array();
234 
235  if (isset($cache[$a_obj_id . '_' . $a_type])) {
236  return $cache[$a_obj_id . '_' . $a_type];
237  }
238 
239  $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
240  $cache[$a_obj_id . '_' . $a_type] = $class::_getFailed($a_obj_id);
241 
242  return $cache[$a_obj_id . '_' . $a_type];
243  }
244 
245  public static function _getStatusInfoByType($a_obj_id, $a_type)
246  {
247  static $cache = array();
248 
249  if (isset($cache[$a_obj_id . '_' . $a_type])) {
250  return $cache[$a_obj_id . '_' . $a_type];
251  }
252 
253  $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
254  $cache[$a_obj_id . '_' . $a_type] = $class::_getStatusInfo($a_obj_id);
255 
256  return $cache[$a_obj_id . '_' . $a_type];
257  }
258 
265  public static function _updateStatus($a_obj_id, $a_usr_id, $a_obj = null, $a_percentage = false, $a_force_raise = false)
266  {
267  $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
268  if (strtolower(get_class($trac_obj)) != "illpstatus") {
269  $trac_obj->_updateStatus($a_obj_id, $a_usr_id, $a_obj, $a_percentage, $a_force_raise);
270  }
271  }
272 
278  public static function _setDirty($a_obj_id)
279  {
280  $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
281  $trac_obj->_setDirty($a_obj_id);
282  }
283 
290  public static function _refreshStatus($a_obj_id, $a_users = null)
291  {
292  $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
293  $trac_obj->refreshStatus($a_obj_id, $a_users);
294  }
295 
302  public static function _determineStatus($a_obj_id, $a_usr_id)
303  {
304  if (isset(self::$status_cache[$a_obj_id][$a_usr_id])) {
305  return self::$status_cache[$a_obj_id][$a_usr_id];
306  }
307 
308  $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
309  $st = $trac_obj->determineStatus($a_obj_id, $a_usr_id);
310 
311  self::$status_cache[$a_obj_id][$a_usr_id] = $st;
312 
313  return $st;
314  }
315 
316  public static function _removeStatusCache($a_obj_id, $a_usr_id)
317  {
318  unset(self::$status_cache[$a_obj_id][$a_usr_id]);
319  }
320 
328  public static function _lookupCompletedForObject($a_obj_id, $a_user_ids = null)
329  {
330  $class = ilLPStatusFactory::_getClassById($a_obj_id);
331  return $class::_lookupCompletedForObject($a_obj_id, $a_user_ids);
332  }
333 
341  public static function _lookupFailedForObject($a_obj_id, $a_user_ids = null)
342  {
343  $class = ilLPStatusFactory::_getClassById($a_obj_id);
344  return $class::_lookupFailedForObject($a_obj_id, $a_user_ids);
345  }
346 
354  public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null)
355  {
356  $class = ilLPStatusFactory::_getClassById($a_obj_id);
357  return $class::_lookupInProgressForObject($a_obj_id, $a_user_ids);
358  }
359 }
static _getInProgress($a_obj_id)
Static function to read users who have the status &#39;in_progress&#39;.
static _getCompleted($a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
static _getCountCompleted($a_obj_id)
Static function to read the number of user who have the status &#39;completed&#39;.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _lookupFailedForObject($a_obj_id, $a_user_ids=null)
Get failed users for object.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static _getInstance($a_obj_id, $a_mode=null)
static _getInProgressByType($a_obj_id, $a_type)
static _getCountFailedByType($a_obj_id, $a_type)
static _resetInfoCaches($a_obj_id)
static _getClassById($a_obj_id, $a_mode=null)
static _getNotAttempted($a_obj_id)
Static function to read the number of user who have the status &#39;not_attempted&#39;.
static _getFailed($a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
$a_type
Definition: workflow.php:92
static _getFailedByType($a_obj_id, $a_type)
static _getNotAttemptedByType($a_obj_id, $a_type)
static _getCountNotAttempted($a_obj_id)
Static function to read the number of user who have the status &#39;not_attempted&#39;.
static _getClassByIdAndType($a_obj_id, $a_type)
static _setDirty($a_obj_id)
Set dirty.
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.
static _getCountInProgress($a_obj_id)
Static function to read the number of user who have the status &#39;in_progress&#39;.
static _getCompletedByType($a_obj_id, $a_type)
static _removeStatusCache($a_obj_id, $a_usr_id)
static _lookupInProgressForObject($a_obj_id, $a_user_ids=null)
Get in progress users for object.
static _getCountCompletedByType($a_obj_id, $a_type)
global $ilBench
Definition: ilias.php:18
static _getCountFailed($a_obj_id)
Static function to read the number of user who have the status &#39;failed&#39;.
static _getCountNotAttemptedByType($a_obj_id, $a_type)
Static function to read the number of user who have the status &#39;not_attempted&#39;.
static _lookupCompletedForObject($a_obj_id, $a_user_ids=null)
Get completed users for object.
Class ilLPStatusWrapper This class is wrapper for all ilLPStatus classes.
static _getStatusInfoByType($a_obj_id, $a_type)
static _getTypicalLearningTime($a_obj_id)
Reads Typical learning time.
static _getCountInProgressByType($a_obj_id, $a_type)
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.