ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilLPStatus.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
16{
17 protected $obj_id = null;
18
19 protected $db = null;
20
21 public static $list_gui_cache;
22
23 const LP_STATUS_NOT_ATTEMPTED = 'trac_no_attempted';
24 const LP_STATUS_IN_PROGRESS = 'trac_in_progress';
25 const LP_STATUS_COMPLETED = 'trac_completed';
26 const LP_STATUS_FAILED = 'trac_failed';
27
32
33 const LP_STATUS_REGISTERED = 'trac_registered';
34 const LP_STATUS_NOT_REGISTERED = 'trac_not_registered';
35 const LP_STATUS_PARTICIPATED = 'trac_participated';
36 const LP_STATUS_NOT_PARTICIPATED = 'trac_not_participated';
37
38 public function __construct($a_obj_id)
39 {
40 global $DIC;
41
42 $ilDB = $DIC['ilDB'];
43
44 $this->obj_id = $a_obj_id;
45 $this->db = $ilDB;
46 }
47
48 public static function _getCountNotAttempted($a_obj_id)
49 {
50 return 0;
51 }
52
53 public static function _getNotAttempted($a_obj_id)
54 {
55 return array();
56 }
57
58 public static function _getCountInProgress($a_obj_id)
59 {
60 return 0;
61 }
62
63 public static function _getInProgress($a_obj_id)
64 {
65 return array();
66 }
67
68 public static function _getCountCompleted($a_obj_id)
69 {
70 return 0;
71 }
72
73 public static function _getCompleted($a_obj_id)
74 {
75 return array();
76 }
77
78 public static function _getFailed($a_obj_id)
79 {
80 return array();
81 }
82
83 public static function _getCountFailed()
84 {
85 return 0;
86 }
87
88 public static function _getStatusInfo($a_obj_id)
89 {
90 return array();
91 }
92
93 public static function _getTypicalLearningTime($a_obj_id)
94 {
95 include_once 'Services/MetaData/classes/class.ilMDEducational.php';
97 }
98
99
203 public function _updateStatus($a_obj_id, $a_usr_id, $a_obj = null, $a_percentage = false, $a_force_raise = false)
204 {
206 $log->debug(sprintf(
207 "obj_id: %s, user id: %s, object: %s",
208 $a_obj_id,
209 $a_usr_id,
210 (is_object($a_obj) ? get_class($a_obj) : 'null')
211 ));
212
213 $status = $this->determineStatus($a_obj_id, $a_usr_id, $a_obj);
214 $percentage = $this->determinePercentage($a_obj_id, $a_usr_id, $a_obj);
215 $old_status = null;
216 $changed = self::writeStatus($a_obj_id, $a_usr_id, $status, $percentage, false, $old_status);
217
218 // ak: I don't think that this is a good way to fix 15529, we should not
219 // raise the event, if the status does not change imo.
220 // for now the changes in the next line just prevent the event being raised twice
221 if (!$changed && (bool) $a_force_raise) { // #15529
222 self::raiseEvent($a_obj_id, $a_usr_id, $status, $old_status, $percentage);
223 }
224 }
225
232 public function determinePercentage($a_obj_id, $a_usr_id, $a_obj = null)
233 {
234 return false;
235 }
236
243 public function determineStatus($a_obj_id, $a_usr_id, $a_obj = null)
244 {
245 return false;
246 }
247
248
256 public static function checkStatusForObject($a_obj_id, $a_users = false)
257 {
258 global $DIC;
259
260 $ilDB = $DIC['ilDB'];
261
262 //@todo: there maybe the need to add extra handling for sessions here, since the
263 // "in progress" status is time dependent here. On the other hand, if they registered
264 // to the session, they already accessed the course and should have a "in progress"
265 // anyway. But the status on the session itself may not be correct.
266
267 $sql = "SELECT usr_id FROM ut_lp_marks WHERE " .
268 " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " .
269 " status_dirty = " . $ilDB->quote(1, "integer");
270 if (is_array($a_users) && count($a_users) > 0) {
271 $sql .= " AND " . $ilDB->in("usr_id", $a_users, false, "integer");
272 }
273 $set = $ilDB->query($sql);
274 $dirty = false;
275 if ($rec = $ilDB->fetchAssoc($set)) {
276 $dirty = true;
277 }
278
279 // check if any records are missing
280 $missing = false;
281 if (!$dirty && is_array($a_users) && count($a_users) > 0) {
282 $set = $ilDB->query("SELECT count(usr_id) cnt FROM ut_lp_marks WHERE " .
283 " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " .
284 $ilDB->in("usr_id", $a_users, false, "integer"));
285 $r = $ilDB->fetchAssoc($set);
286 if ($r["cnt"] < count($a_users)) {
287 $missing = true;
288 }
289 }
290
291 // refresh status, if records are dirty or missing
292 if ($dirty || $missing) {
293 require_once "Services/Tracking/classes/class.ilLPStatusFactory.php"; // #13330
294 $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
295 $trac_obj->refreshStatus($a_obj_id, $a_users);
296 }
297 }
298
299 protected static function raiseEvent($a_obj_id, $a_usr_id, $a_status, $a_old_status, $a_percentage)
300 {
301 global $DIC;
302
303 $ilAppEventHandler = $DIC['ilAppEventHandler'];
304
306 $log->debug("obj_id: " . $a_obj_id . ", user id: " . $a_usr_id . ", status: " .
307 $a_status . ", percentage: " . $a_percentage);
308
309 $ilAppEventHandler->raise("Services/Tracking", "updateStatus", array(
310 "obj_id" => $a_obj_id,
311 "usr_id" => $a_usr_id,
312 "status" => $a_status,
313 "old_status" => $a_old_status,
314 "percentage" => $a_percentage
315 ));
316 }
317
324 public function refreshStatus($a_obj_id, $a_users = null)
325 {
326 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
327 $not_attempted = ilLPStatusWrapper::_getNotAttempted($a_obj_id);
328 foreach ($not_attempted as $user_id) {
329 $percentage = $this->determinePercentage($a_obj_id, $user_id);
330 if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_NOT_ATTEMPTED_NUM, $percentage, true)) {
331 //self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_NOT_ATTEMPTED_NUM, $percentage);
332 }
333 }
334 $in_progress = ilLPStatusWrapper::_getInProgress($a_obj_id);
335 foreach ($in_progress as $user_id) {
336 $percentage = $this->determinePercentage($a_obj_id, $user_id);
337 if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_IN_PROGRESS_NUM, $percentage, true)) {
338 //self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_IN_PROGRESS_NUM, $percentage);
339 }
340 }
341 $completed = ilLPStatusWrapper::_getCompleted($a_obj_id);
342 foreach ($completed as $user_id) {
343 $percentage = $this->determinePercentage($a_obj_id, $user_id);
344 if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_COMPLETED_NUM, $percentage, true)) {
345 //self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_COMPLETED_NUM, $percentage);
346 }
347 }
349 foreach ($failed as $user_id) {
350 $percentage = $this->determinePercentage($a_obj_id, $user_id);
351 if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_FAILED_NUM, $percentage, true)) {
352 //self::raiseEvent($a_obj_id, $user_id, self::LP_STATUS_FAILED_NUM, $percentage);
353 }
354 }
355 if ($a_users) {
356 $missing_users = array_diff($a_users, $not_attempted + $in_progress + $completed + $failed);
357 if ($missing_users) {
358 foreach ($missing_users as $user_id) {
359 ilLPStatusWrapper::_updateStatus($a_obj_id, $user_id);
360 }
361 }
362 }
363 }
364
371 public static function writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage = false, $a_force_per = false, &$a_old_status = self::LP_STATUS_NOT_ATTEMPTED_NUM)
372 {
373 global $DIC;
374
375 $ilDB = $DIC->database();
376 $log = $DIC->logger()->trac();
377
378 $log->debug('Write status for: ' . "obj_id: " . $a_obj_id . ", user id: " . $a_user_id . ", status: " . $a_status . ", percentage: " . $a_percentage . ", force: " . $a_force_per);
379 $update_dependencies = false;
380
381 $a_old_status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
382
383 // get status in DB
384 $set = $ilDB->query(
385 "SELECT usr_id,status,status_dirty FROM ut_lp_marks WHERE " .
386 " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " .
387 " usr_id = " . $ilDB->quote($a_user_id, "integer")
388 );
389 $rec = $ilDB->fetchAssoc($set);
390
391 // update
392 if ($rec) {
393 $a_old_status = $rec["status"];
394
395 // status has changed: update
396 if ($rec["status"] != $a_status) {
397 $ret = $ilDB->manipulate(
398 "UPDATE ut_lp_marks SET " .
399 " status = " . $ilDB->quote($a_status, "integer") . "," .
400 " status_changed = " . $ilDB->now() . "," .
401 " status_dirty = " . $ilDB->quote(0, "integer") .
402 " WHERE usr_id = " . $ilDB->quote($a_user_id, "integer") .
403 " AND obj_id = " . $ilDB->quote($a_obj_id, "integer")
404 );
405 if ($ret != 0) {
406 $update_dependencies = true;
407 }
408 }
409 // status has not changed: reset dirty flag
410 elseif ($rec["status_dirty"]) {
411 $ilDB->manipulate(
412 "UPDATE ut_lp_marks SET " .
413 " status_dirty = " . $ilDB->quote(0, "integer") .
414 " WHERE usr_id = " . $ilDB->quote($a_user_id, "integer") .
415 " AND obj_id = " . $ilDB->quote($a_obj_id, "integer")
416 );
417 }
418 }
419 // insert
420 else {
421 // #13783
422 $ilDB->replace(
423 "ut_lp_marks",
424 array(
425 "obj_id" => array("integer", $a_obj_id),
426 "usr_id" => array("integer", $a_user_id)
427 ),
428 array(
429 "status" => array("integer", $a_status),
430 "status_changed" => array("timestamp", date("Y-m-d H:i:s")), // was $ilDB->now()
431 "status_dirty" => array("integer", 0)
432 )
433 );
434
435 $update_dependencies = true;
436 }
437
438 // update percentage
439 if ($a_percentage !== false || $a_force_per) {
440 $a_percentage = max(0, (int) $a_percentage);
441 $a_percentage = min(100, $a_percentage);
442 $ret = $ilDB->manipulate(
443 "UPDATE ut_lp_marks SET " .
444 " percentage = " . $ilDB->quote($a_percentage, "integer") .
445 " WHERE usr_id = " . $ilDB->quote($a_user_id, "integer") .
446 " AND obj_id = " . $ilDB->quote($a_obj_id, "integer")
447 );
448 }
449
450 $log->debug('Update dependecies is ' . ($update_dependencies ? 'true' : 'false'));
451
452 // update collections
453 if ($update_dependencies) {
454 $log->debug('update dependencies');
455
456 // a change occured - remove existing cache entry
457 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
458 ilLPStatusWrapper::_removeStatusCache($a_obj_id, $a_user_id);
459
460 $set = $ilDB->query("SELECT ut_lp_collections.obj_id obj_id FROM " .
461 "object_reference JOIN ut_lp_collections ON " .
462 "(object_reference.obj_id = " . $ilDB->quote($a_obj_id, "integer") .
463 " AND object_reference.ref_id = ut_lp_collections.item_id)");
464 while ($rec = $ilDB->fetchAssoc($set)) {
465 if (in_array(ilObject::_lookupType($rec["obj_id"]), array("crs", "grp", "fold"))) {
466 $log->debug('Calling update status for collection obj_id: ' . $rec['obj_id']);
467 // just to make sure - remove existing cache entry
468 ilLPStatusWrapper::_removeStatusCache($rec["obj_id"], $a_user_id);
469 ilLPStatusWrapper::_updateStatus($rec["obj_id"], $a_user_id);
470 }
471 }
472
473 // find all course references
474 if (ilObject::_lookupType($a_obj_id) == 'crs') {
475 $log->debug('update references');
476
477 $query = 'select obj_id from container_reference ' .
478 'where target_obj_id = ' . $ilDB->quote($a_obj_id, ilDBConstants::T_INTEGER);
479 $res = $ilDB->query($query);
480 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
481 $log->debug('Calling update status for reference obj_id: ' . $row->obj_id);
482 \ilLPStatusWrapper::_removeStatusCache($row->obj_id, $a_user_id);
483 \ilLPStatusWrapper::_updateStatus($row->obj_id, $a_user_id);
484 }
485 }
486
487 self::raiseEvent($a_obj_id, $a_user_id, $a_status, $a_old_status, $a_percentage);
488 }
489
490 return $update_dependencies;
491 }
492
498 public static function setInProgressIfNotAttempted($a_obj_id, $a_user_id)
499 {
500 global $DIC;
501
502 $ilDB = $DIC['ilDB'];
503
504 // #11513
505
506 $needs_update = false;
507
508 $set = $ilDB->query(
509 "SELECT usr_id, status FROM ut_lp_marks WHERE " .
510 " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " .
511 " usr_id = " . $ilDB->quote($a_user_id, "integer")
512 );
513 if ($rec = $ilDB->fetchAssoc($set)) {
514 // current status is not attempted, so we need to update
515 if ($rec["status"] == self::LP_STATUS_NOT_ATTEMPTED_NUM) {
516 $needs_update = true;
517 }
518 } else {
519 // no ut_lp_marks yet, we should update
520 $needs_update = true;
521 }
522
523 if ($needs_update) {
524 require_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
525 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
526 }
527 }
528
535 public static function setAllDirty()
536 {
537 global $DIC;
538
539 $ilDB = $DIC['ilDB'];
540
541 $ilDB->manipulate(
542 "UPDATE ut_lp_marks SET " .
543 " status_dirty = " . $ilDB->quote(1, "integer")
544 );
545 }
546
553 public static function setDirty($a_obj_id)
554 {
555 global $DIC;
556
557 $ilDB = $DIC['ilDB'];
558
559 $ilDB->manipulate(
560 "UPDATE ut_lp_marks SET " .
561 " status_dirty = " . $ilDB->quote(1, "integer") .
562 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer")
563 );
564 }
565
573 public static function _lookupStatus($a_obj_id, $a_user_id, $a_create = true)
574 {
575 global $DIC;
576
577 $ilDB = $DIC['ilDB'];
578
579 $set = $ilDB->query(
580 "SELECT status FROM ut_lp_marks WHERE " .
581 " status_dirty = " . $ilDB->quote(0, "integer") .
582 " AND usr_id = " . $ilDB->quote($a_user_id, "integer") .
583 " AND obj_id = " . $ilDB->quote($a_obj_id, "integer")
584 );
585 if ($rec = $ilDB->fetchAssoc($set)) {
586 return $rec["status"];
587 } elseif ((bool) $a_create) {
588 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
589 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
590 $set = $ilDB->query(
591 "SELECT status FROM ut_lp_marks WHERE " .
592 " status_dirty = " . $ilDB->quote(0, "integer") .
593 " AND usr_id = " . $ilDB->quote($a_user_id, "integer") .
594 " AND obj_id = " . $ilDB->quote($a_obj_id, "integer")
595 );
596 if ($rec = $ilDB->fetchAssoc($set)) {
597 return $rec["status"];
598 }
599 }
600 }
601
608 public static function _lookupPercentage($a_obj_id, $a_user_id)
609 {
610 global $DIC;
611
612 $ilDB = $DIC['ilDB'];
613
614 $set = $ilDB->query(
615 "SELECT percentage FROM ut_lp_marks WHERE " .
616 " status_dirty = " . $ilDB->quote(0, "integer") .
617 " AND usr_id = " . $ilDB->quote($a_user_id, "integer") .
618 " AND obj_id = " . $ilDB->quote($a_obj_id, "integer")
619 );
620 if ($rec = $ilDB->fetchAssoc($set)) {
621 return $rec["percentage"];
622 }
623 }
624
632 public static function _hasUserCompleted($a_obj_id, $a_user_id)
633 {
634 return (self::_lookupStatus($a_obj_id, $a_user_id) == self::LP_STATUS_COMPLETED_NUM);
635 }
636
643 public static function _lookupStatusChanged($a_obj_id, $a_user_id)
644 {
645 global $DIC;
646
647 $ilDB = $DIC['ilDB'];
648
649 $set = $ilDB->query(
650 "SELECT status_changed FROM ut_lp_marks WHERE " .
651 " status_dirty = " . $ilDB->quote(0, "integer") .
652 " AND usr_id = " . $ilDB->quote($a_user_id, "integer") .
653 " AND obj_id = " . $ilDB->quote($a_obj_id, "integer")
654 );
655 if ($rec = $ilDB->fetchAssoc($set)) {
656 return $rec["status_changed"];
657 } else {
658 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
659 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
660 $set = $ilDB->query(
661 "SELECT status_changed FROM ut_lp_marks WHERE " .
662 " status_dirty = " . $ilDB->quote(0, "integer") .
663 " AND usr_id = " . $ilDB->quote($a_user_id, "integer") .
664 " AND obj_id = " . $ilDB->quote($a_obj_id, "integer")
665 );
666 if ($rec = $ilDB->fetchAssoc($set)) {
667 return $rec["status_changed"];
668 }
669 }
670 }
671
680 protected static function _lookupStatusForObject($a_obj_id, $a_status, $a_user_ids = null)
681 {
682 global $DIC;
683
684 $ilDB = $DIC['ilDB'];
685
686 $sql = "SELECT usr_id, status, status_dirty FROM ut_lp_marks" .
687 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
688 " AND status = " . $ilDB->quote($a_status, "integer");
689 if ($a_user_ids) {
690 $sql .= " AND " . $ilDB->in("usr_id", $a_user_ids, "", "integer");
691 }
692
693 $set = $ilDB->query($sql);
694 $res = array();
695 while ($rec = $ilDB->fetchAssoc($set)) {
696 if ($res["status_dirty"]) {
697 // update status and check again
698 if (self::_lookupStatus($a_obj_id, $rec["usr_id"]) != $a_status) {
699 continue;
700 }
701 }
702 $res[] = $rec["usr_id"];
703 }
704
705 return $res;
706 }
707
715 public static function _lookupCompletedForObject($a_obj_id, $a_user_ids = null)
716 {
717 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
718 }
719
727 public static function _lookupFailedForObject($a_obj_id, $a_user_ids = null)
728 {
729 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_FAILED_NUM, $a_user_ids);
730 }
731
739 public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null)
740 {
741 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
742 }
743
744
745 //
746 // LIST GUI
747 //
748
757 protected static function validateLPForObjects($a_user_id, $a_obj_ids, $a_parent_ref_id)
758 {
759 $lp_invalid = array();
760
761 include_once "Services/Object/classes/class.ilObjectLP.php";
762 $memberships = ilObjectLP::getLPMemberships($a_user_id, $a_obj_ids, $a_parent_ref_id);
763 foreach ($memberships as $obj_id => $status) {
764 if (!$status) {
765 $lp_invalid[] = $obj_id;
766 }
767 }
768
769 return array_diff($a_obj_ids, $lp_invalid);
770 }
771
778 protected static function checkLPModesForObjects($a_obj_ids, array &$a_coll_obj_ids)
779 {
780 $valid = array();
781
782 // all lp modes with collections (gathered separately)
783 include_once "Services/Tracking/classes/collection/class.ilLPCollection.php";
785
786 include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
787
788 // check if objects have LP activated at all (DB entries)
789 $existing = ilLPObjSettings::_lookupDBModeForObjects($a_obj_ids);
790 foreach ($existing as $obj_id => $obj_mode) {
791 if ($obj_mode != ilLPObjSettings::LP_MODE_DEACTIVATED) {
793
794 if (in_array($obj_mode, $coll_modes)) {
795 $a_coll_obj_ids[] = $obj_id;
796 }
797 }
798 }
799
800 // missing objects in DB (default mode)
801 include_once "Services/Object/classes/class.ilObjectLP.php";
802 if (sizeof($existing) != sizeof($a_obj_ids)) {
803 foreach (array_diff($a_obj_ids, $existing) as $obj_id) {
805 $mode = $olp->getCurrentMode();
807 // #11141
808 unset($valid[$obj_id]);
809 } elseif ($mode != ilLPObjSettings::LP_MODE_UNDEFINED) {
811
812 if (in_array($mode, $coll_modes)) {
813 $a_coll_obj_ids[] = $obj_id;
814 }
815 }
816 }
817 unset($existing);
818 }
819
820 return array_values($valid);
821 }
822
830 protected static function getLPStatusForObjects($a_user_id, $a_obj_ids)
831 {
832 global $DIC;
833
834 $ilDB = $DIC['ilDB'];
835
836 $res = array();
837
838 // get user lp data
839 $sql = "SELECT status, status_dirty, obj_id FROM ut_lp_marks" .
840 " WHERE " . $ilDB->in("obj_id", $a_obj_ids, "", "integer") .
841 " AND usr_id = " . $ilDB->quote($a_user_id, "integer");
842 $set = $ilDB->query($sql);
843 while ($row = $ilDB->fetchAssoc($set)) {
844 if (!$row["status_dirty"]) {
845 $res[$row["obj_id"]] = $row["status"];
846 } else {
847 $res[$row["obj_id"]] = self::_lookupStatus($row["obj_id"], $a_user_id);
848 }
849 }
850
851 // process missing user entries (same as dirty entries, see above)
852 foreach ($a_obj_ids as $obj_id) {
853 if (!isset($res[$obj_id])) {
854 $res[$obj_id] = self::_lookupStatus($obj_id, $a_user_id);
855 if ($res[$obj_id] === null) {
857 }
858 }
859 }
860
861 return $res;
862 }
863
864 public static function preloadListGUIData($a_obj_ids)
865 {
866 global $DIC;
867
868 $ilUser = $DIC['ilUser'];
869 $lng = $DIC['lng'];
870
871 $user_id = $ilUser->getId();
872
873 $res = array();
874
875 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
876 if ($ilUser->getId() != ANONYMOUS_USER_ID &&
880 // -- validate
881
882 // :TODO: we need the parent ref id, but this is awful
883 $a_obj_ids = self::validateLPForObjects($user_id, $a_obj_ids, (int) $_GET["ref_id"]);
884
885 // we are not handling the collections differently yet
886 $coll_obj_ids = array();
887 $a_obj_ids = self::checkLPModesForObjects($a_obj_ids, $coll_obj_ids);
888
889
890 // -- gather
891
892 $res = self::getLPStatusForObjects($user_id, $a_obj_ids);
893
894
895 // -- render
896
897 // value to icon
898 $lng->loadLanguageModule("trac");
899 include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
900 foreach ($res as $obj_id => $status) {
902 $text = ilLearningProgressBaseGUI::_getStatusText((int) $status);
903 $res[$obj_id] = [
904 "image" => ilUtil::img($path, $text),
905 "status" => $status
906 ];
907 }
908 }
909
910 self::$list_gui_cache = $res;
911 }
912
913 public static function getListGUIStatus($a_obj_id, $a_image_only = true)
914 {
915 if ($a_image_only) {
916 $image = '';
917 if (isset(self::$list_gui_cache[$a_obj_id]["image"])) {
918 $image = self::$list_gui_cache[$a_obj_id]["image"];
919 }
920
921 return $image;
922 }
923 return self::$list_gui_cache[$a_obj_id];
924 }
925}
$failed
Definition: Utf8Test.php:85
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static _lookupDBModeForObjects(array $a_obj_ids)
static _getInstance($a_obj_id, $a_mode=null)
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _getNotAttempted($a_obj_id)
Static function to read the number of user who have the status 'not_attempted'.
static _removeStatusCache($a_obj_id, $a_usr_id)
static _getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
static _getInProgress($a_obj_id)
Static function to read users who have the status 'in_progress'.
static _getFailed($a_obj_id)
Static function to read the users who have the status 'completed'.
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
_updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
New status handling (st: status, nr: accesses, p: percentage, t: time spent, m: mark)
static _lookupStatusForObject($a_obj_id, $a_status, $a_user_ids=null)
Get users with given status for object.
const LP_STATUS_NOT_PARTICIPATED
static writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage=false, $a_force_per=false, &$a_old_status=self::LP_STATUS_NOT_ATTEMPTED_NUM)
Write status for user and object.
static _getStatusInfo($a_obj_id)
static preloadListGUIData($a_obj_ids)
determineStatus($a_obj_id, $a_usr_id, $a_obj=null)
Determine status.
static _getInProgress($a_obj_id)
static _getCountInProgress($a_obj_id)
static _getTypicalLearningTime($a_obj_id)
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
determinePercentage($a_obj_id, $a_usr_id, $a_obj=null)
Determine percentage.
const LP_STATUS_COMPLETED
static _lookupInProgressForObject($a_obj_id, $a_user_ids=null)
Get in progress users for object.
static setInProgressIfNotAttempted($a_obj_id, $a_user_id)
This function shoudl be clalled for normal "read events".
static _lookupFailedForObject($a_obj_id, $a_user_ids=null)
Get failed users for object.
const LP_STATUS_NOT_REGISTERED
const LP_STATUS_PARTICIPATED
const LP_STATUS_FAILED
const LP_STATUS_IN_PROGRESS_NUM
static checkStatusForObject($a_obj_id, $a_users=false)
This function checks whether the status for a given number of users is dirty and must be recalculated...
static _getCompleted($a_obj_id)
__construct($a_obj_id)
static _getCountNotAttempted($a_obj_id)
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_REGISTERED
static raiseEvent($a_obj_id, $a_usr_id, $a_status, $a_old_status, $a_percentage)
static checkLPModesForObjects($a_obj_ids, array &$a_coll_obj_ids)
Process lp modes for given objects.
refreshStatus($a_obj_id, $a_users=null)
Refresh status.
static _getNotAttempted($a_obj_id)
static setAllDirty()
Sets all status to dirty.
static _getCountCompleted($a_obj_id)
static getLPStatusForObjects($a_user_id, $a_obj_ids)
Get LP status for given objects (and user)
static _lookupStatusChanged($a_obj_id, $a_user_id)
Lookup status changed.
static $list_gui_cache
static _lookupCompletedForObject($a_obj_id, $a_user_ids=null)
Get completed users for object.
static setDirty($a_obj_id)
Sets status of an object to dirty.
const LP_STATUS_FAILED_NUM
static validateLPForObjects($a_user_id, $a_obj_ids, $a_parent_ref_id)
Process given objects for lp-relevance.
static _lookupPercentage($a_obj_id, $a_user_id)
Lookup percentage.
static getListGUIStatus($a_obj_id, $a_image_only=true)
static _getFailed($a_obj_id)
static _getCountFailed()
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
static _getImagePathForStatus($a_status)
Get image path for status.
static getLogger($a_component_id)
Get component logger.
static _getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
static _enabledLearningProgress()
check wether learing progress is enabled or not
static getLPMemberships($a_usr_id, array $a_obj_ids, $a_parent_ref_id=null, $a_mapped_ref_ids=false)
Get all objects where given user is member (from LP POV)
static getInstance($a_obj_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
$valid
$ret
Definition: parser.php:6
$query
$log
Definition: result.php:15
$lng
foreach($_POST as $key=> $value) $res
global $ilDB
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46