ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLearningProgressGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
28{
32 public function executeCommand()
33 {
34 $this->ctrl->setReturn($this, "");
35
36 // E.g personal desktop mode needs locator header icon ...
37 $this->__buildHeader();
38 switch ($this->__getNextClass()) {
39 case 'illplistofprogressgui':
40
41 $this->help->setScreenIdComponent(
42 "lp_" . ilObject::_lookupType($this->getRefId(), true)
43 );
44
45 $this->__setSubTabs(self::LP_ACTIVE_PROGRESS);
46 $this->__setCmdClass(ilLPListOfProgressGUI::class);
47 $lop_gui = new ilLPListOfProgressGUI(
48 $this->getMode(),
49 $this->getRefId(),
50 $this->getUserId()
51 );
52 $this->ctrl->forwardCommand($lop_gui);
53 break;
54
55 case 'illplistofobjectsgui':
56 if ($this->getRefId() &&
58 'read_learning_progress',
59 $this->getRefId()
60 )) {
61 return;
62 }
63
64 if (stristr($this->ctrl->getCmd(), "matrix")) {
65 $this->__setSubTabs(self::LP_ACTIVE_MATRIX);
66 } elseif (stristr($this->ctrl->getCmd(), "summary")) {
67 $this->__setSubTabs(self::LP_ACTIVE_SUMMARY);
68 } else {
69 $this->__setSubTabs(self::LP_ACTIVE_OBJECTS);
70 }
71 $loo_gui = new ilLPListOfObjectsGUI(
72 $this->getMode(),
73 $this->getRefId()
74 );
75 $this->__setCmdClass(ilLPListOfObjectsGUI::class);
76 $this->ctrl->forwardCommand($loo_gui);
77 break;
78
79 case 'illplistofsettingsgui':
80 if ($this->getRefId() &&
82 'edit_learning_progress',
83 $this->getRefId()
84 )) {
85 return;
86 }
87
88 $this->__setSubTabs(self::LP_ACTIVE_SETTINGS);
89 $los_gui = new ilLPListOfSettingsGUI(
90 $this->getMode(),
91 $this->getRefId()
92 );
93 $this->__setCmdClass(ilLPListOfSettingsGUI::class);
94 $this->ctrl->forwardCommand($los_gui);
95 break;
96
97 case 'illpobjectstatisticsgui':
98 if (stristr($this->ctrl->getCmd(), "access")) {
99 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATACCESS);
100 } elseif (stristr($this->ctrl->getCmd(), "types")) {
101 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATTYPES);
102 } elseif (stristr($this->ctrl->getCmd(), "daily")) {
103 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATDAILY);
104 } else {
105 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATADMIN);
106 }
107 $this->__setCmdClass(ilLPObjectStatisticsGUI::class);
108 $this->tabs_gui->activateTab('statistics');
109 $ost_gui = new ilLPObjectStatisticsGUI(
110 $this->getMode(),
111 $this->getRefId()
112 );
113 $this->ctrl->forwardCommand($ost_gui);
114 break;
115
116 default:
117 $cmd = $this->ctrl->getCmd();
118 if (!$cmd) {
119 return;
120 }
121 $this->$cmd();
122 $this->tpl->printToStdout();
123 break;
124 }
125
126 // E.G personal desktop mode needs $tpl->show();
127 $this->__buildFooter();
128 }
129
130 public function __setCmdClass(string $a_class): void
131 {
135 if (
136 strtolower($this->ctrl->getCmdClass()) !== strtolower($a_class) &&
137 strtolower($this->ctrl->getNextClass()) !== strtolower($a_class)
138 ) {
139 $this->ctrl->redirectByClass($a_class);
140 }
141 }
142
143 public function __getNextClass(): string
144 {
145 // #9857
147 return '';
148 }
149
150 if (strlen($next_class = $this->ctrl->getNextClass())) {
151 if ($this->getMode() == self::LP_CONTEXT_PERSONAL_DESKTOP) {
152 ilSession::set('il_lp_history', $next_class);
153 }
154 return $next_class;
155 }
156 switch ($this->getMode()) {
158 $cmd = $this->ctrl->getCmd();
159 if (in_array(
160 $cmd,
161 array("editManual", "updatemanual", "showtlt")
162 )) {
163 return "";
164 }
165
166 // #12771
169 );
170 if (!$olp->isActive()) {
171 if (!($olp instanceof ilPluginLP) &&
173 'edit_learning_progress',
174 $this->getRefId()
175 )) {
176 return 'illplistofsettingsgui';
177 } else {
178 return '';
179 }
180 }
181
182 if (!$this->anonymized &&
184 'read_learning_progress',
185 $this->getRefId()
186 )) {
187 return 'illplistofobjectsgui';
188 }
189 if (
191 'edit_learning_progress',
192 $this->getRefId()
193 )) {
194 return 'illplistofsettingsgui';
195 }
196 return 'illplistofprogressgui';
197
199
202 );
203
204 if ($has_edit || $has_personal) {
205 // default (#10928)
206 $tgt = null;
207 if ($has_personal) {
208 $tgt = 'illplistofprogressgui';
209 } elseif ($has_edit) {
210 $tgt = 'illplistofobjectsgui';
211 }
212
213 // validate session
214 switch (ilSession::get('il_lp_history')) {
215 case 'illplistofobjectsgui':
216 if (!$has_edit) {
217 ilSession::clear('il_lp_history');
218 }
219 break;
220
221 case 'illplistofprogressgui':
222 if (!$has_personal) {
223 ilSession::clear('il_lp_history');
224 }
225 break;
226 }
227
228 if (ilSession::get('il_lp_history')) {
229 return ilSession::get('il_lp_history');
230 } elseif ($tgt) {
231 return $tgt;
232 }
233 }
234
235 // should not happen
236 ilUtil::redirect("ilias.php?baseClass=ilDashboardGUI");
237
238 // no break
242 return 'illplistofprogressgui';
243 }
244 break;
245 }
246 return '';
247 }
248
252 protected function editManual(): void
253 {
257 );
258 if ($olp->getCurrentMode(
260 $form = $this->initCollectionManualForm();
261 $this->tpl->setContent($form->getHTML());
262 }
263 }
264 }
265
267 {
268 $form = new ilPropertyFormGUI();
269 $form->setFormAction($this->ctrl->getFormAction($this, "updatemanual"));
270 $form->setTitle($this->lng->txt("learning_progress"));
271 $form->setDescription(
272 $this->lng->txt("trac_collection_manual_learner_info")
273 );
274
275 $coll_items = array();
276
277 $olp = ilObjectLP::getInstance($this->getObjId());
278 $collection = $olp->getCollectionInstance();
279 $subitem_info = '';
280 $subitem_title = '';
281 $possible_items = [];
282 if ($collection) {
283 $coll_items = $collection->getItems();
284 $possible_items = $collection->getPossibleItems(
285 $this->getRefId()
286 ); // for titles
287
288 switch (ilObject::_lookupType($this->getObjId())) {
289 case "lm":
290 $subitem_title = $this->lng->txt("objs_st");
291 $subitem_info = $this->lng->txt(
292 "trac_collection_manual_learner_lm_info"
293 );
294 break;
295 }
296 }
297
299 $this->getObjId(),
301 );
302 $lp_data = $class::_getObjectStatus($this->getObjId(), $this->usr_id);
303
305
306 $grp = new ilCheckboxGroupInputGUI($subitem_title, "sids");
307 $grp->setInfo($subitem_info);
308 $form->addItem($grp);
309
310 // #14994 - using possible items for proper sorting
311
312 $completed = array();
313 foreach (array_keys($possible_items) as $item_id) {
314 if (!in_array($item_id, $coll_items)) {
315 continue;
316 }
317
318 $info = null;
320
321 if (isset($lp_data[$item_id])) {
322 $changed = new ilDateTime($lp_data[$item_id][1], IL_CAL_UNIX);
323 $info = $this->lng->txt(
324 "trac_collection_manual_learner_changed_ts"
325 ) . ": " .
327
328 if ($lp_data[$item_id][0]) {
330 $completed[] = $item_id;
331 }
332 }
333
334 $icon = $icons->renderIconForStatus($status);
335
336 $opt = new ilCheckboxOption(
337 $icon . " " . $possible_items[$item_id]["title"],
338 $item_id
339 );
340 if ($info) {
341 $opt->setInfo($info);
342 }
343 $grp->addOption($opt);
344 }
345
346 if ($completed) {
347 $grp->setValue($completed);
348 }
349
350 $form->addCommandButton("updatemanual", $this->lng->txt("save"));
351
352 return $form;
353 }
354
355 protected function updateManual(): void
356 {
360 );
361 if ($olp->getCurrentMode(
363 $form = $this->initCollectionManualForm();
364 if ($form->checkInput()) {
366 $this->getObjId(),
368 );
369 $class::_setObjectStatus(
370 $this->getObjId(),
371 $this->usr_id,
372 $form->getInput("sids")
373 );
374
375 $this->tpl->setOnScreenMessage(
376 'success',
377 $this->lng->txt(
378 "settings_saved"
379 ),
380 true
381 );
382 }
383
384 $this->ctrl->redirect($this, "editManual");
385 }
386 }
387 }
388
389 protected function showtlt()
390 {
391 $form = new ilPropertyFormGUI();
392 $form->setFormAction($this->ctrl->getFormAction($this, "showtlt"));
393 $form->setTitle($this->lng->txt("learning_progress"));
394 $form->setDescription(
395 $this->lng->txt("trac_collection_tlt_learner_info")
396 );
397
398 $coll_items = array();
399
400 $olp = ilObjectLP::getInstance($this->getObjId());
401 $collection = $olp->getCollectionInstance();
402 $possible_items = [];
403 if ($collection) {
404 $coll_items = $collection->getItems();
405 $possible_items = $collection->getPossibleItems(
406 $this->getRefId()
407 ); // for titles
408 }
409
411 $this->getObjId(),
413 );
414 $info = $class::_getStatusInfo($this->getObjId(), true);
415
417
418 foreach ($coll_items as $item_id) {
419 // #16599 - deleted items should not be displayed
420 if (!array_key_exists($item_id, $possible_items)) {
421 continue;
422 }
423
424 $field = new ilCustomInputGUI($possible_items[$item_id]["title"]);
425
426 // lp status
428 if (isset($info["completed"][$item_id]) &&
429 in_array($this->user->getId(), $info["completed"][$item_id])) {
431 } elseif (isset($info["in_progress"][$item_id]) &&
432 in_array(
433 $this->user->getId(),
434 $info["in_progress"][$item_id]
435 )) {
437 }
438 $field->setHtml($icons->renderIconForStatus($status));
439
440 // stats
441 $spent = 0;
442 if (isset($info["tlt_users"][$item_id][$this->user->getId()])) {
443 $spent = $info["tlt_users"][$item_id][$this->user->getId()];
444 }
445 $needed = $info["tlt"][$item_id];
446 if ($needed) {
447 $field->setInfo(
448 sprintf(
449 $this->lng->txt("trac_collection_tlt_learner_subitem"),
452 min(100, round(abs($spent) / $needed * 100))
453 )
454 );
455 }
456
457 $form->addItem($field);
458 }
459
460 $this->tpl->setContent($form->getHTML());
461 }
462}
const IL_CAL_UNIX
This class represents a property in a property form.
This class represents an option in a checkbox group.
This class represents a custom property in a property form.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
@classDescription Date and time handling
Class ilLPListOfSettingsGUI.
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 checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
Class ilObjUserTrackingGUI.
editManual()
Show progress screen for "edit manual".
static getInstance(int $obj_id)
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
This class represents a property form user interface.
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
static redirect(string $a_script)
$info
Definition: entry_point.php:21