ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLearnerProgressDB.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
27 protected ilAccess $access;
29
30 public function __construct(
34 ) {
35 $this->items_db = $items_db;
36 $this->access = $access;
37 $this->obj_data_cache = $obj_data_cache;
38 }
39
45 public function getLearnerItems(int $usr_id, int $container_ref_id): array
46 {
47 $items = [];
48 $ls_items = $this->items_db->getLSItems($container_ref_id);
49
50 foreach ($ls_items as $ls_item) {
51 if ($this->isItemVisibleForUser($usr_id, $ls_item) === false) {
52 continue;
53 }
54 $lp = $this->getLearningProgressFor($usr_id, $ls_item);
55 $av = $this->getAvailabilityFor($usr_id, $ls_item);
56 $items[] = new LSLearnerItem($usr_id, $lp, $av, $ls_item);
57 }
58
59 return $items;
60 }
61
62 protected function getObjIdForRefId(int $ref_id): int
63 {
65 }
66
67 protected function getLearningProgressFor(int $usr_id, LSItem $ls_item): int
68 {
69 $obj_id = $this->getObjIdForRefId($ls_item->getRefId());
70
72 if (ilObjectLP::isSupportedObjectType($this->obj_data_cache->lookupType($obj_id))) {
73 $il_lp_status = ilLPStatus::_lookupStatus($obj_id, $usr_id, true);
74 }
75 return (int) $il_lp_status;
76 }
77
78 protected function isItemVisibleForUser(int $usr_id, LSItem $ls_item): bool
79 {
80 $online = $ls_item->isOnline();
81 $access = $this->access->checkAccessOfUser(
82 $usr_id,
83 "visible",
84 "",
85 $ls_item->getRefId()
86 );
87 return ($online && $access);
88 }
89
90 protected function getAvailabilityFor(int $usr_id, LSItem $ls_item): int
91 {
92 $this->access->clear(); //clear access cache; condition-checks refer to previous state otherwise.
93 $readable = $this->access->checkAccessOfUser($usr_id, 'read', '', $ls_item->getRefId());
94 if ($readable) {
96 }
98 }
99}
Data holding class LSItem .
Definition: LSItem.php:25
getRefId()
Definition: LSItem.php:93
isOnline()
Definition: LSItem.php:78
Add learning progress and availability information to the LSItem.
Class ilAccessHandler Checks access for ILIAS objects.
const LP_STATUS_NOT_ATTEMPTED_NUM
static _lookupStatus(int $a_obj_id, int $a_user_id, bool $a_create=true)
Lookup status.
Class ilLSItemsDB.
Definition: ilLSItemsDB.php:25
Get LearningProgress and availability of items in sequence.
isItemVisibleForUser(int $usr_id, LSItem $ls_item)
ilObjectDataCache $obj_data_cache
getLearningProgressFor(int $usr_id, LSItem $ls_item)
getLearnerItems(int $usr_id, int $container_ref_id)
Decorate LSItems with learning progress and availability (from conditions)
__construct(ilLSItemsDB $items_db, ilAccess $access, ilObjectDataCache $obj_data_cache)
getAvailabilityFor(int $usr_id, LSItem $ls_item)
class ilObjectDataCache
static isSupportedObjectType(string $type)
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:66