ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPStatusWrapper.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
30{
31 private static array $status_cache = array();
32 private static array $info_cache = array();
33 private static array $failed_cache = array();
34 private static array $completed_cache = array();
35 private static array $in_progress_cache = array();
36 private static array $not_attempted_cache = array();
37
41 public static function _getCountNotAttempted(int $a_obj_id): int
42 {
43 return count(ilLPStatusWrapper::_getNotAttempted($a_obj_id));
44 }
45
49 public static function _getNotAttempted(int $a_obj_id): array
50 {
51 if (isset(self::$not_attempted_cache[$a_obj_id])) {
52 return self::$not_attempted_cache[$a_obj_id];
53 }
54
55 $class = ilLPStatusFactory::_getClassById($a_obj_id);
56 self::$not_attempted_cache[$a_obj_id] = $class::_getNotAttempted(
57 $a_obj_id
58 );
59
60 return self::$not_attempted_cache[$a_obj_id];
61 }
62
66 public static function _getCountInProgress(int $a_obj_id): int
67 {
68 return count(ilLPStatusWrapper::_getInProgress($a_obj_id));
69 }
70
74 public static function _getInProgress(int $a_obj_id): array
75 {
76 if (isset(self::$in_progress_cache[$a_obj_id])) {
77 return self::$in_progress_cache[$a_obj_id];
78 }
79
80 global $DIC;
81
82 $class = ilLPStatusFactory::_getClassById($a_obj_id);
83 self::$in_progress_cache[$a_obj_id] = $class::_getInProgress($a_obj_id);
84
85 return self::$in_progress_cache[$a_obj_id];
86 }
87
91 public static function _getCountCompleted(int $a_obj_id): int
92 {
93 return count(ilLPStatusWrapper::_getCompleted($a_obj_id));
94 }
95
99 public static function _getCompleted(int $a_obj_id): array
100 {
101 if (isset(self::$completed_cache[$a_obj_id])) {
102 return self::$completed_cache[$a_obj_id];
103 }
104 $class = ilLPStatusFactory::_getClassById($a_obj_id);
105 self::$completed_cache[$a_obj_id] = $class::_getCompleted($a_obj_id);
106
107 return self::$completed_cache[$a_obj_id];
108 }
109
113 public static function _getCountFailed(int $a_obj_id): int
114 {
115 return count(ilLPStatusWrapper::_getFailed($a_obj_id));
116 }
117
121 public static function _getFailed(int $a_obj_id): array
122 {
123 if (isset(self::$failed_cache[$a_obj_id])) {
124 return self::$failed_cache[$a_obj_id];
125 }
126
127 $class = ilLPStatusFactory::_getClassById($a_obj_id);
128
129 self::$failed_cache[$a_obj_id] = $class::_getFailed($a_obj_id);
130
131 return self::$failed_cache[$a_obj_id];
132 }
133
137 public static function _getStatusInfo(int $a_obj_id): array
138 {
139 if (isset(self::$info_cache[$a_obj_id])) {
140 return self::$info_cache[$a_obj_id];
141 }
142
143 $class = ilLPStatusFactory::_getClassById($a_obj_id);
144 self::$info_cache[$a_obj_id] = $class::_getStatusInfo($a_obj_id);
145 return self::$info_cache[$a_obj_id];
146 }
147
148 public static function _resetInfoCaches($a_obj_id)
149 {
150 unset(self::$info_cache[$a_obj_id]);
151 unset(self::$failed_cache[$a_obj_id]);
152 unset(self::$completed_cache[$a_obj_id]);
153 unset(self::$in_progress_cache[$a_obj_id]);
154 unset(self::$not_attempted_cache[$a_obj_id]);
155 }
156
160 public static function _getTypicalLearningTime(string $type, int $a_obj_id): int
161 {
162 static $cache = array();
163
164 if (isset($cache[$a_obj_id])) {
165 return $cache[$a_obj_id];
166 }
167
168 $class = ilLPStatusFactory::_getClassById($a_obj_id);
169 $cache[$a_obj_id] = $class::_getTypicalLearningTime($type, $a_obj_id);
170
171 return $cache[$a_obj_id];
172 }
173
175 // Special functions for 'objects' that have not an entry in object_data
176 // E.g. events
178
182 public static function _getCountNotAttemptedByType(
183 int $a_obj_id,
184 string $a_type
185 ): int {
186 return count(
187 ilLPStatusWrapper::_getNotAttemptedByType($a_obj_id, $a_type)
188 );
189 }
190
191 public static function _getNotAttemptedByType(
192 int $a_obj_id,
193 string $a_type
194 ): array {
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::_getNotAttempted($a_obj_id);
203
204 return $cache[$a_obj_id . '_' . $a_type];
205 }
206
207 public static function _getCountInProgressByType(
208 int $a_obj_id,
209 string $a_type
210 ): int {
211 return count(
212 ilLPStatusWrapper::_getInProgressByType($a_obj_id, $a_type)
213 );
214 }
215
216 public static function _getInProgressByType(
217 int $a_obj_id,
218 string $a_type
219 ): array {
220 static $cache = array();
221
222 if (isset($cache[$a_obj_id . '_' . $a_type])) {
223 return $cache[$a_obj_id . '_' . $a_type];
224 }
225
226 $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
227 $cache[$a_obj_id . '_' . $a_type] = $class::_getInProgress($a_obj_id);
228
229 return $cache[$a_obj_id . '_' . $a_type];
230 }
231
232 public static function _getCountCompletedByType(
233 int $a_obj_id,
234 string $a_type
235 ): int {
236 return count(
237 ilLPStatusWrapper::_getCompletedByType($a_obj_id, $a_type)
238 );
239 }
240
241 public static function _getCompletedByType(
242 int $a_obj_id,
243 string $a_type
244 ): array {
245 static $cache = array();
246
247 if (isset($cache[$a_obj_id . '_' . $a_type])) {
248 return $cache[$a_obj_id . '_' . $a_type];
249 }
250
251 $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
252 $cache[$a_obj_id . '_' . $a_type] = $class::_getCompleted($a_obj_id);
253
254 return $cache[$a_obj_id . '_' . $a_type];
255 }
256
257 public static function _getCountFailedByType(
258 int $a_obj_id,
259 string $a_type
260 ): int {
261 return count(ilLPStatusWrapper::_getFailedByType($a_obj_id, $a_type));
262 }
263
264 public static function _getFailedByType(
265 int $a_obj_id,
266 string $a_type
267 ): array {
268 static $cache = array();
269
270 if (isset($cache[$a_obj_id . '_' . $a_type])) {
271 return $cache[$a_obj_id . '_' . $a_type];
272 }
273
274 $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
275 $cache[$a_obj_id . '_' . $a_type] = $class::_getFailed($a_obj_id);
276
277 return $cache[$a_obj_id . '_' . $a_type];
278 }
279
280 public static function _getStatusInfoByType(
281 int $a_obj_id,
282 string $a_type
283 ): array {
284 static $cache = array();
285
286 if (isset($cache[$a_obj_id . '_' . $a_type])) {
287 return $cache[$a_obj_id . '_' . $a_type];
288 }
289
290 $class = ilLPStatusFactory::_getClassByIdAndType($a_obj_id, $a_type);
291 $cache[$a_obj_id . '_' . $a_type] = $class::_getStatusInfo($a_obj_id);
292
293 return $cache[$a_obj_id . '_' . $a_type];
294 }
295
296 public static function _updateStatus(
297 int $a_obj_id,
298 int $a_usr_id,
299 ?object $a_obj = null,
300 bool $a_percentage = false,
301 bool $a_force_raise = false
302 ): void {
303 $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
304 if (strtolower(get_class($trac_obj)) != "illpstatus") {
305 $trac_obj->_updateStatus(
306 $a_obj_id,
307 $a_usr_id,
308 $a_obj,
309 $a_percentage,
310 $a_force_raise
311 );
312 }
313 }
314
315 public static function _setDirty(int $a_obj_id): void
316 {
317 $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
318 $trac_obj->_setDirty($a_obj_id);
319 }
320
321 public static function _refreshStatus(
322 int $a_obj_id,
323 ?array $a_users = null
324 ): void {
325 $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
326 $trac_obj->refreshStatus($a_obj_id, $a_users);
327 }
328
329 public static function _determineStatus(int $a_obj_id, int $a_usr_id): int
330 {
331 if (isset(self::$status_cache[$a_obj_id][$a_usr_id])) {
332 return self::$status_cache[$a_obj_id][$a_usr_id];
333 }
334
335 $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
336 $st = $trac_obj->determineStatus($a_obj_id, $a_usr_id);
337
338 self::$status_cache[$a_obj_id][$a_usr_id] = $st;
339 return $st;
340 }
341
342 public static function _removeStatusCache(
343 int $a_obj_id,
344 int $a_usr_id
345 ): void {
346 unset(self::$status_cache[$a_obj_id][$a_usr_id]);
347 }
348
349 public static function _lookupCompletedForObject(
350 int $a_obj_id,
351 ?array $a_user_ids = null
352 ): array {
353 $class = ilLPStatusFactory::_getClassById($a_obj_id);
354 return $class::_lookupCompletedForObject($a_obj_id, $a_user_ids);
355 }
356
357 public static function _lookupFailedForObject(
358 int $a_obj_id,
359 ?array $a_user_ids = null
360 ): array {
361 $class = ilLPStatusFactory::_getClassById($a_obj_id);
362 return $class::_lookupFailedForObject($a_obj_id, $a_user_ids);
363 }
364
365 public static function _lookupInProgressForObject(
366 int $a_obj_id,
367 ?array $a_user_ids = null
368 ): array {
369 $class = ilLPStatusFactory::_getClassById($a_obj_id);
370 return $class::_lookupInProgressForObject($a_obj_id, $a_user_ids);
371 }
372}
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 _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 _getTypicalLearningTime(string $type, int $a_obj_id)
Reads Typical learning time.
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['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26