ILIAS  release_8 Revision v8.24
class.ilLPStatusWrapper.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
4
5/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
6
16{
17 private static array $status_cache = array();
18 private static array $info_cache = array();
19 private static array $failed_cache = array();
20 private static array $completed_cache = array();
21 private static array $in_progress_cache = array();
22 private static array $not_attempted_cache = array();
23
27 public static function _getCountNotAttempted(int $a_obj_id): int
28 {
29 return count(ilLPStatusWrapper::_getNotAttempted($a_obj_id));
30 }
31
35 public static function _getNotAttempted(int $a_obj_id): array
36 {
37 if (isset(self::$not_attempted_cache[$a_obj_id])) {
38 return self::$not_attempted_cache[$a_obj_id];
39 }
40
41 $class = ilLPStatusFactory::_getClassById($a_obj_id);
42 self::$not_attempted_cache[$a_obj_id] = $class::_getNotAttempted(
43 $a_obj_id
44 );
45
46 return self::$not_attempted_cache[$a_obj_id];
47 }
48
52 public static function _getCountInProgress(int $a_obj_id): int
53 {
54 return count(ilLPStatusWrapper::_getInProgress($a_obj_id));
55 }
56
60 public static function _getInProgress(int $a_obj_id): array
61 {
62 if (isset(self::$in_progress_cache[$a_obj_id])) {
63 return self::$in_progress_cache[$a_obj_id];
64 }
65
66 global $DIC;
67
68 $class = ilLPStatusFactory::_getClassById($a_obj_id);
69 self::$in_progress_cache[$a_obj_id] = $class::_getInProgress($a_obj_id);
70
71 return self::$in_progress_cache[$a_obj_id];
72 }
73
77 public static function _getCountCompleted(int $a_obj_id): int
78 {
79 return count(ilLPStatusWrapper::_getCompleted($a_obj_id));
80 }
81
85 public static function _getCompleted(int $a_obj_id): array
86 {
87 if (isset(self::$completed_cache[$a_obj_id])) {
88 return self::$completed_cache[$a_obj_id];
89 }
90 $class = ilLPStatusFactory::_getClassById($a_obj_id);
91 self::$completed_cache[$a_obj_id] = $class::_getCompleted($a_obj_id);
92
93 return self::$completed_cache[$a_obj_id];
94 }
95
99 public static function _getCountFailed(int $a_obj_id): int
100 {
101 return count(ilLPStatusWrapper::_getFailed($a_obj_id));
102 }
103
107 public static function _getFailed(int $a_obj_id): array
108 {
109 if (isset(self::$failed_cache[$a_obj_id])) {
110 return self::$failed_cache[$a_obj_id];
111 }
112
113 $class = ilLPStatusFactory::_getClassById($a_obj_id);
114
115 self::$failed_cache[$a_obj_id] = $class::_getFailed($a_obj_id);
116
117 return self::$failed_cache[$a_obj_id];
118 }
119
123 public static function _getStatusInfo(int $a_obj_id): array
124 {
125 if (isset(self::$info_cache[$a_obj_id])) {
126 return self::$info_cache[$a_obj_id];
127 }
128
129 $class = ilLPStatusFactory::_getClassById($a_obj_id);
130 self::$info_cache[$a_obj_id] = $class::_getStatusInfo($a_obj_id);
131 return self::$info_cache[$a_obj_id];
132 }
133
134 public static function _resetInfoCaches($a_obj_id)
135 {
136 unset(self::$info_cache[$a_obj_id]);
137 unset(self::$failed_cache[$a_obj_id]);
138 unset(self::$completed_cache[$a_obj_id]);
139 unset(self::$in_progress_cache[$a_obj_id]);
140 unset(self::$not_attempted_cache[$a_obj_id]);
141 }
142
146 public static function _getTypicalLearningTime(int $a_obj_id): int
147 {
148 static $cache = array();
149
150 if (isset($cache[$a_obj_id])) {
151 return $cache[$a_obj_id];
152 }
153
154 $class = ilLPStatusFactory::_getClassById($a_obj_id);
155 $cache[$a_obj_id] = $class::_getTypicalLearningTime($a_obj_id);
156
157 return $cache[$a_obj_id];
158 }
159
161 // Special functions for 'objects' that have not an entry in object_data
162 // E.g. events
164
168 public static function _getCountNotAttemptedByType(
169 int $a_obj_id,
170 string $a_type
171 ): int {
172 return count(
173 ilLPStatusWrapper::_getNotAttemptedByType($a_obj_id, $a_type)
174 );
175 }
176
177 public static function _getNotAttemptedByType(
178 int $a_obj_id,
179 string $a_type
180 ): array {
181 static $cache = array();
182
183 if (isset($cache[$a_obj_id . '_' . $a_type])) {
184 return $cache[$a_obj_id . '_' . $a_type];
185 }
186
187 $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
188 $cache[$a_obj_id . '_' . $a_type] = $class::_getNotAttempted($a_obj_id);
189
190 return $cache[$a_obj_id . '_' . $a_type];
191 }
192
193 public static function _getCountInProgressByType(
194 int $a_obj_id,
195 string $a_type
196 ): int {
197 return count(
198 ilLPStatusWrapper::_getInProgressByType($a_obj_id, $a_type)
199 );
200 }
201
202 public static function _getInProgressByType(
203 int $a_obj_id,
204 string $a_type
205 ): array {
206 static $cache = array();
207
208 if (isset($cache[$a_obj_id . '_' . $a_type])) {
209 return $cache[$a_obj_id . '_' . $a_type];
210 }
211
212 $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
213 $cache[$a_obj_id . '_' . $a_type] = $class::_getInProgress($a_obj_id);
214
215 return $cache[$a_obj_id . '_' . $a_type];
216 }
217
218 public static function _getCountCompletedByType(
219 int $a_obj_id,
220 string $a_type
221 ): int {
222 return count(
223 ilLPStatusWrapper::_getCompletedByType($a_obj_id, $a_type)
224 );
225 }
226
227 public static function _getCompletedByType(
228 int $a_obj_id,
229 string $a_type
230 ): array {
231 static $cache = array();
232
233 if (isset($cache[$a_obj_id . '_' . $a_type])) {
234 return $cache[$a_obj_id . '_' . $a_type];
235 }
236
237 $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
238 $cache[$a_obj_id . '_' . $a_type] = $class::_getCompleted($a_obj_id);
239
240 return $cache[$a_obj_id . '_' . $a_type];
241 }
242
243 public static function _getCountFailedByType(
244 int $a_obj_id,
245 string $a_type
246 ): int {
247 return count(ilLPStatusWrapper::_getFailedByType($a_obj_id, $a_type));
248 }
249
250 public static function _getFailedByType(
251 int $a_obj_id,
252 string $a_type
253 ): array {
254 static $cache = array();
255
256 if (isset($cache[$a_obj_id . '_' . $a_type])) {
257 return $cache[$a_obj_id . '_' . $a_type];
258 }
259
260 $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
261 $cache[$a_obj_id . '_' . $a_type] = $class::_getFailed($a_obj_id);
262
263 return $cache[$a_obj_id . '_' . $a_type];
264 }
265
266 public static function _getStatusInfoByType(
267 int $a_obj_id,
268 string $a_type
269 ): array {
270 static $cache = array();
271
272 if (isset($cache[$a_obj_id . '_' . $a_type])) {
273 return $cache[$a_obj_id . '_' . $a_type];
274 }
275
276 $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
277 $cache[$a_obj_id . '_' . $a_type] = $class::_getStatusInfo($a_obj_id);
278
279 return $cache[$a_obj_id . '_' . $a_type];
280 }
281
282 public static function _updateStatus(
283 int $a_obj_id,
284 int $a_usr_id,
285 ?object $a_obj = null,
286 bool $a_percentage = false,
287 bool $a_force_raise = false
288 ): void {
289 $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
290 if (strtolower(get_class($trac_obj)) != "illpstatus") {
291 $trac_obj->_updateStatus(
292 $a_obj_id,
293 $a_usr_id,
294 $a_obj,
295 $a_percentage,
296 $a_force_raise
297 );
298 }
299 }
300
301 public static function _setDirty(int $a_obj_id): void
302 {
303 $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
304 $trac_obj->_setDirty($a_obj_id);
305 }
306
307 public static function _refreshStatus(
308 int $a_obj_id,
309 ?array $a_users = null
310 ): void {
311 $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
312 $trac_obj->refreshStatus($a_obj_id, $a_users);
313 }
314
315 public static function _determineStatus(int $a_obj_id, int $a_usr_id): int
316 {
317 if (isset(self::$status_cache[$a_obj_id][$a_usr_id])) {
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 return $st;
326 }
327
328 public static function _removeStatusCache(
329 int $a_obj_id,
330 int $a_usr_id
331 ): void {
332 unset(self::$status_cache[$a_obj_id][$a_usr_id]);
333 }
334
335 public static function _lookupCompletedForObject(
336 int $a_obj_id,
337 ?array $a_user_ids = null
338 ): array {
339 $class = ilLPStatusFactory::_getClassById($a_obj_id);
340 return $class::_lookupCompletedForObject($a_obj_id, $a_user_ids);
341 }
342
343 public static function _lookupFailedForObject(
344 int $a_obj_id,
345 ?array $a_user_ids = null
346 ): array {
347 $class = ilLPStatusFactory::_getClassById($a_obj_id);
348 return $class::_lookupFailedForObject($a_obj_id, $a_user_ids);
349 }
350
351 public static function _lookupInProgressForObject(
352 int $a_obj_id,
353 ?array $a_user_ids = null
354 ): array {
355 $class = ilLPStatusFactory::_getClassById($a_obj_id);
356 return $class::_lookupInProgressForObject($a_obj_id, $a_user_ids);
357 }
358}
Class ilLPStatusFactory Creates status class instances for learning progress modes of an object.
static _getInstance(int $a_obj_id, ?int $a_mode=null)
static _getClassByIdAndType(int $a_obj_id, string $a_type)
static _getClassById(int $a_obj_id, ?int $a_mode=null)
Class ilLPStatusWrapper This class is wrapper for all ilLPStatus classes.
static _getCountCompleted(int $a_obj_id)
Static function to read the number of user who have the status 'completed'.
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
static _getCountInProgress(int $a_obj_id)
Static function to read the number of user who have the status 'in_progress'.
static _getInProgress(int $a_obj_id)
Static function to read users who have the status 'in_progress'.
static _getCompletedByType(int $a_obj_id, string $a_type)
static _getNotAttemptedByType(int $a_obj_id, string $a_type)
static _getFailedByType(int $a_obj_id, string $a_type)
static _getInProgressByType(int $a_obj_id, string $a_type)
static _getFailed(int $a_obj_id)
Static function to read the users who have the status 'completed'.
static _getCountCompletedByType(int $a_obj_id, string $a_type)
static _getStatusInfoByType(int $a_obj_id, string $a_type)
static _resetInfoCaches($a_obj_id)
static _getTypicalLearningTime(int $a_obj_id)
Reads Typical learning time.
static _determineStatus(int $a_obj_id, int $a_usr_id)
static _getCountNotAttempted(int $a_obj_id)
Static function to read the number of user who have the status 'not_attempted'.
static _setDirty(int $a_obj_id)
static _removeStatusCache(int $a_obj_id, int $a_usr_id)
static _getCountFailed(int $a_obj_id)
Static function to read the number of user who have the status 'failed'.
static _getCountNotAttemptedByType(int $a_obj_id, string $a_type)
Static function to read the number of user who have the status 'not_attempted'.
static _lookupCompletedForObject(int $a_obj_id, ?array $a_user_ids=null)
static _lookupFailedForObject(int $a_obj_id, ?array $a_user_ids=null)
static _getNotAttempted(int $a_obj_id)
Static function to read the number of user who have the status 'not_attempted'.
static _getCountInProgressByType(int $a_obj_id, string $a_type)
static _lookupInProgressForObject(int $a_obj_id, ?array $a_user_ids=null)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
static _getCountFailedByType(int $a_obj_id, string $a_type)
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status 'completed'.
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28