ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  static private $status_cache = array();
21  static private $info_cache = array();
22  static private $failed_cache = array();
23  static private $completed_cache = array();
24  static private $in_progress_cache = array();
25  static private $not_attempted_cache = array();
26 
30  static function _getCountNotAttempted($a_obj_id)
31  {
32  return count(ilLPStatusWrapper::_getNotAttempted($a_obj_id));
33  }
34 
38  static function _getNotAttempted($a_obj_id)
39  {
40  if(isset(self::$not_attempted_cache[$a_obj_id]))
41  {
42  return self::$not_attempted_cache[$a_obj_id];
43  }
44 
45  $class = ilLPStatusFactory::_getClassById($a_obj_id);
46  self::$not_attempted_cache[$a_obj_id] = $class::_getNotAttempted($a_obj_id);
47 
48  return self::$not_attempted_cache[$a_obj_id];
49  }
50 
54  static function _getCountInProgress($a_obj_id)
55  {
56  return count(ilLPStatusWrapper::_getInProgress($a_obj_id));
57  }
58 
62  static function _getInProgress($a_obj_id)
63  {
64  if(isset(self::$in_progress_cache[$a_obj_id]))
65  {
66  return self::$in_progress_cache[$a_obj_id];
67  }
68 
69  global $ilBench;
70 
71  $class = ilLPStatusFactory::_getClassById($a_obj_id);
72  self::$in_progress_cache[$a_obj_id] = $class::_getInProgress($a_obj_id);
73 
74  return self::$in_progress_cache[$a_obj_id];
75  }
76 
80  static function _getCountCompleted($a_obj_id)
81  {
82  return count(ilLPStatusWrapper::_getCompleted($a_obj_id));
83  }
84 
88  static function _getCompleted($a_obj_id)
89  {
90  if(isset(self::$completed_cache[$a_obj_id]))
91  {
92  return self::$completed_cache[$a_obj_id];
93  }
94  $class = ilLPStatusFactory::_getClassById($a_obj_id);
95  self::$completed_cache[$a_obj_id] = $class::_getCompleted($a_obj_id);
96 
97  return self::$completed_cache[$a_obj_id];
98  }
99 
103  static function _getCountFailed($a_obj_id)
104  {
105  return count(ilLPStatusWrapper::_getFailed($a_obj_id));
106  }
107 
111  static function _getFailed($a_obj_id)
112  {
113  if(isset(self::$failed_cache[$a_obj_id]))
114  {
115  return self::$failed_cache[$a_obj_id];
116  }
117 
118  $class = ilLPStatusFactory::_getClassById($a_obj_id);
119 
120  self::$failed_cache[$a_obj_id] = $class::_getFailed($a_obj_id);
121 
122  return self::$failed_cache[$a_obj_id];
123  }
124 
128  static function _getStatusInfo($a_obj_id)
129  {
130  if(isset(self::$info_cache[$a_obj_id]))
131  {
132  return self::$info_cache[$a_obj_id];
133  }
134 
135  $class = ilLPStatusFactory::_getClassById($a_obj_id);
136  self::$info_cache[$a_obj_id] = $class::_getStatusInfo($a_obj_id);
137  return self::$info_cache[$a_obj_id];
138  }
139 
140  public static function _resetInfoCaches($a_obj_id)
141  {
142  unset(self::$info_cache[$a_obj_id]);
143  unset(self::$failed_cache[$a_obj_id]);
144  unset(self::$completed_cache[$a_obj_id]);
145  unset(self::$in_progress_cache[$a_obj_id]);
146  unset(self::$not_attempted_cache[$a_obj_id]);
147  }
148 
152  static function _getTypicalLearningTime($a_obj_id)
153  {
154  static $cache = array();
155 
156  if(isset($cache[$a_obj_id]))
157  {
158  return $cache[$a_obj_id];
159  }
160 
161  $class = ilLPStatusFactory::_getClassById($a_obj_id);
162  $cache[$a_obj_id] = $class::_getTypicalLearningTime($a_obj_id);
163 
164  return $cache[$a_obj_id];
165  }
166 
168  // Special functions for 'objects' that have not an entry in object_data
169  // E.g. events
171 
175  static function _getCountNotAttemptedByType($a_obj_id,$a_type)
176  {
177  return count(ilLPStatusWrapper::_getNotAttemptedByType($a_obj_id,$a_type));
178  }
179 
180  static function _getNotAttemptedByType($a_obj_id,$a_type)
181  {
182  static $cache = array();
183 
184  if(isset($cache[$a_obj_id.'_'.$a_type]))
185  {
186  return $cache[$a_obj_id.'_'.$a_type];
187  }
188 
189  $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id,$a_type);
190  $cache[$a_obj_id.'_'.$a_type] = $class::_getNotAttempted($a_obj_id);
191 
192  return $cache[$a_obj_id.'_'.$a_type];
193  }
194 
195  static function _getCountInProgressByType($a_obj_id,$a_type)
196  {
197  return count(ilLPStatusWrapper::_getInProgressByType($a_obj_id,$a_type));
198  }
199 
200  static function _getInProgressByType($a_obj_id,$a_type)
201  {
202  static $cache = array();
203 
204  if(isset($cache[$a_obj_id.'_'.$a_type]))
205  {
206  return $cache[$a_obj_id.'_'.$a_type];
207  }
208 
209  $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id,$a_type);
210  $cache[$a_obj_id.'_'.$a_type] = $class::_getInProgress($a_obj_id);
211 
212  return $cache[$a_obj_id.'_'.$a_type];
213  }
214 
215  static function _getCountCompletedByType($a_obj_id,$a_type)
216  {
217  return count(ilLPStatusWrapper::_getCompletedByType($a_obj_id,$a_type));
218  }
219 
220  static function _getCompletedByType($a_obj_id,$a_type)
221  {
222  static $cache = array();
223 
224  if(isset($cache[$a_obj_id.'_'.$a_type]))
225  {
226  return $cache[$a_obj_id.'_'.$a_type];
227  }
228 
229  $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id,$a_type);
230  $cache[$a_obj_id.'_'.$a_type] = $class::_getCompleted($a_obj_id);
231 
232  return $cache[$a_obj_id.'_'.$a_type];
233  }
234 
235  static function _getCountFailedByType($a_obj_id,$a_type)
236  {
237  return count(ilLPStatusWrapper::_getFailedByType($a_obj_id,$a_type));
238  }
239 
240  static function _getFailedByType($a_obj_id,$a_type)
241  {
242  static $cache = array();
243 
244  if(isset($cache[$a_obj_id.'_'.$a_type]))
245  {
246  return $cache[$a_obj_id.'_'.$a_type];
247  }
248 
249  $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id,$a_type);
250  $cache[$a_obj_id.'_'.$a_type] = $class::_getFailed($a_obj_id);
251 
252  return $cache[$a_obj_id.'_'.$a_type];
253  }
254 
255  static function _getStatusInfoByType($a_obj_id,$a_type)
256  {
257  static $cache = array();
258 
259  if(isset($cache[$a_obj_id.'_'.$a_type]))
260  {
261  return $cache[$a_obj_id.'_'.$a_type];
262  }
263 
264  $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id,$a_type);
265  $cache[$a_obj_id.'_'.$a_type] = $class::_getStatusInfo($a_obj_id);
266 
267  return $cache[$a_obj_id.'_'.$a_type];
268  }
269 
276  static function _updateStatus($a_obj_id, $a_usr_id, $a_obj = null, $a_percentage = false, $a_force_raise = false)
277  {
278  $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
279  if (strtolower(get_class($trac_obj)) != "illpstatus")
280  {
281  $trac_obj->_updateStatus($a_obj_id, $a_usr_id, $a_obj, $a_percentage, $a_force_raise);
282  }
283  }
284 
290  static function _setDirty($a_obj_id)
291  {
292  $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
293  $trac_obj->_setDirty($a_obj_id);
294  }
295 
302  static function _refreshStatus($a_obj_id, $a_users = null)
303  {
304  $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
305  $trac_obj->refreshStatus($a_obj_id, $a_users);
306  }
307 
314  public static function _determineStatus($a_obj_id, $a_usr_id)
315  {
316  if (isset(self::$status_cache[$a_obj_id][$a_usr_id]))
317  {
318  return self::$status_cache[$a_obj_id][$a_usr_id];
319  }
320 
321  $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
322  $st = $trac_obj->determineStatus($a_obj_id, $a_usr_id);
323 
324  self::$status_cache[$a_obj_id][$a_usr_id] = $st;
325 
326  return $st;
327  }
328 
329  public static function _removeStatusCache($a_obj_id, $a_usr_id)
330  {
331  unset(self::$status_cache[$a_obj_id][$a_usr_id]);
332  }
333 
341  public static function _lookupCompletedForObject($a_obj_id, $a_user_ids = null)
342  {
343  $class = ilLPStatusFactory::_getClassById($a_obj_id);
344  return $class::_lookupCompletedForObject($a_obj_id, $a_user_ids);
345  }
346 
354  public static function _lookupFailedForObject($a_obj_id, $a_user_ids = null)
355  {
356  $class = ilLPStatusFactory::_getClassById($a_obj_id);
357  return $class::_lookupFailedForObject($a_obj_id, $a_user_ids);
358  }
359 
367  public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null)
368  {
369  $class = ilLPStatusFactory::_getClassById($a_obj_id);
370  return $class::_lookupInProgressForObject($a_obj_id, $a_user_ids);
371  }
372 }
373 ?>
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 _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:93
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.
static _getInstance($a_obj_id, $a_mode=NULL)
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.