ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLMExplorerGUI.php
Go to the documentation of this file.
1<?php
2
24{
26 protected ilObjUser $user;
27 protected array $lp_cache = [];
28 protected int $cnt_lmobj = 0;
29 protected string $obj_id = "";
30 protected string $transl = "";
31
35 public function __construct(
36 $a_parent_obj,
37 string $a_parent_cmd,
39 string $a_id = ""
40 ) {
41 global $DIC;
42
43 $this->user = $DIC->user();
44 $this->lm = $a_lm;
45
46 $tree = ilLMTree::getInstance($this->lm->getId());
47
48 $this->cnt_lmobj = ilLMObject::preloadDataByLM($this->lm->getId());
49
51
52 if ($a_id == "") {
53 $a_id = "lm_exp";
54
55 // this does not work, since it is not set yet
56 if ($this->getOfflineMode()) {
57 $a_id = "lm_exp_off";
58 }
59 }
60
61 parent::__construct($a_id, $a_parent_obj, $a_parent_cmd, $tree);
62
63 $this->setSkipRootNode(false);
64 $this->setAjax(false);
65 $this->setPreloadChilds(true);
66
67 $this->setPathOpen($tree->readRootId());
68
69 $params = $DIC->http()->request()->getQueryParams();
70 $this->obj_id = (string) ($params["obj_id"] ?? "");
71 $this->transl = (string) ($params["transl"] ?? "");
72
73 if ($this->obj_id > 0) {
74 $this->setPathOpen($this->obj_id);
75 }
76 }
77
78 public function beforeRendering(): void
79 {
80 if ($this->cnt_lmobj > 200 && !$this->getOfflineMode()) {
81 $class = (is_object($this->parent_obj))
82 ? get_class($this->parent_obj)
84 $this->ctrl->setParameterByClass($class, "obj_id", $this->obj_id);
85 $this->setAjax(true);
86 }
87 }
88
89
93 public function getNodeContent($a_node): string
94 {
95 if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
96 return $this->lm->getTitle();
97 }
98
99 $lang = ($this->transl != "")
100 ? $this->transl
101 : "-";
103 $a_node,
105 $this->lm->isActiveNumbering(),
106 false,
107 false,
108 $this->lm->getId(),
109 $lang
110 );
111 }
112
116 public function isNodeHighlighted($a_node): bool
117 {
118 if ($a_node["child"] == $this->obj_id ||
119 ($this->obj_id == "" && $a_node["child"] == $this->getNodeId($this->getRootNode()))) {
120 return true;
121 }
122 return false;
123 }
124
129 protected function checkLPIcon(int $a_id): string
130 {
131 $ilUser = $this->user;
132
133 // do it once for all chapters
134 if (!isset($this->lp_cache[$this->lm->getId()])) {
135 $this->lp_cache[$this->lm->getId()] = [];
136
137 if (ilLearningProgressAccess::checkAccess($this->lm->getRefId())) {
138 $info = null;
139
140 $olp = ilObjectLP::getInstance($this->lm->getId());
141 if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL ||
142 $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) {
143 $class = ilLPStatusFactory::_getClassById($this->lm->getId(), $olp->getCurrentMode());
144 $info = $class::_getStatusInfo($this->lm->getId());
145 }
146
147 // parse collection items
148 if (isset($info["items"])) {
149 foreach ($info["items"] as $item_id) {
151 if (isset($info["in_progress"][$item_id]) &&
152 in_array($ilUser->getId(), $info["in_progress"][$item_id])) {
154 } elseif (isset($info["completed"][$item_id]) &&
155 in_array($ilUser->getId(), $info["completed"][$item_id])) {
157 }
158 $this->lp_cache[$this->lm->getId()][$item_id] = $status;
159 }
160 }
161 }
162 }
163
164 if (isset($this->lp_cache[$this->lm->getId()]) &&
165 isset($this->lp_cache[$this->lm->getId()][$a_id])) {
167 return $icons->getImagePathForStatus($this->lp_cache[$this->lm->getId()][$a_id]);
168 }
169
170 return "";
171 }
172}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct( $a_parent_obj, string $a_parent_cmd, ilObjContentObject $a_lm, string $a_id="")
beforeRendering()
Before rendering.
ilObjContentObject $lm
static preloadDataByLM(int $a_lm_id)
Preload data records by lm.
static _getNodePresentationTitle(array $a_node, string $a_mode=self::PAGE_TITLE, bool $a_include_numbers=false, bool $a_time_scheduled_activation=false, bool $a_force_content=false, int $a_lm_id=0, string $a_lang="-")
static getInstance(int $a_tree_id)
static _getClassById(int $a_obj_id, ?int $a_mode=null)
static getInstance(int $variant=ilLPStatusIcons::ICON_VARIANT_DEFAULT, ?\ILIAS\UI\Renderer $renderer=null, ?\ILIAS\UI\Factory $factory=null)
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
static getInstance(int $obj_id)
static preloadActivationDataByParentId(int $a_parent_id)
Preload activation data by Parent Id.
Explorer class that works on tree objects (Services/Tree)
setPathOpen($a_id)
Set node path to be opened.
getNodeId($a_node)
Get id for node.
$info
Definition: entry_point.php:21
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$lang
Definition: xapiexit.php:25