ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLearningProgressGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
5
18{
22 public function executeCommand()
23 {
24 global $DIC;
25
26 $ilHelp = $DIC['ilHelp'];
27 $ilAccess = $DIC['ilAccess'];
28
29 $this->ctrl->setReturn($this, "");
30
31 // E.g personal desktop mode needs locator header icon ...
32 $this->__buildHeader();
33 switch ($this->__getNextClass()) {
34 case 'illplistofprogressgui':
35 include_once 'Services/Tracking/classes/repository_statistics/class.ilLPListOfProgressGUI.php';
36
37 $ilHelp->setScreenIdComponent("lp_" . ilObject::_lookupType($this->getRefId(), true));
38
39 $this->__setSubTabs(self::LP_ACTIVE_PROGRESS);
40 $this->__setCmdClass('illplistofprogressgui');
41 $lop_gui = new ilLPListOfProgressGUI($this->getMode(), $this->getRefId(), $this->getUserId());
42 $this->ctrl->forwardCommand($lop_gui);
43 break;
44
45 case 'illplistofobjectsgui':
46 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
47 if ($this->getRefId() &&
48 !ilLearningProgressAccess::checkPermission('read_learning_progress', $this->getRefId())) {
49 return;
50 }
51
52 include_once 'Services/Tracking/classes/repository_statistics/class.ilLPListOfObjectsGUI.php';
53 if (stristr($this->ctrl->getCmd(), "matrix")) {
54 $this->__setSubTabs(self::LP_ACTIVE_MATRIX);
55 } elseif (stristr($this->ctrl->getCmd(), "summary")) {
56 $this->__setSubTabs(self::LP_ACTIVE_SUMMARY);
57 } else {
58 $this->__setSubTabs(self::LP_ACTIVE_OBJECTS);
59 }
60 $loo_gui = new ilLPListOfObjectsGUI($this->getMode(), $this->getRefId());
61 $this->__setCmdClass('illplistofobjectsgui');
62 $this->ctrl->forwardCommand($loo_gui);
63 break;
64
65 case 'illplistofsettingsgui':
66 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
67 if ($this->getRefId() &&
68 !ilLearningProgressAccess::checkPermission('edit_learning_progress', $this->getRefId())) {
69 return;
70 }
71
72 include_once 'Services/Tracking/classes/repository_statistics/class.ilLPListOfSettingsGUI.php';
73
74 $this->__setSubTabs(self::LP_ACTIVE_SETTINGS);
75 $los_gui = new ilLPListOfSettingsGUI($this->getMode(), $this->getRefId());
76 $this->__setCmdClass('illplistofsettingsgui');
77 $this->ctrl->forwardCommand($los_gui);
78 break;
79
80 case 'illpobjectstatisticsgui':
81 include_once 'Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsGUI.php';
82 if (stristr($this->ctrl->getCmd(), "access")) {
83 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATACCESS);
84 } elseif (stristr($this->ctrl->getCmd(), "types")) {
85 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATTYPES);
86 } elseif (stristr($this->ctrl->getCmd(), "daily")) {
87 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATDAILY);
88 } else {
89 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATADMIN);
90 }
91 $this->__setCmdClass('illpobjectstatisticsgui');
92 $ost_gui = new ilLPObjectStatisticsGUI($this->getMode(), $this->getRefId());
93 $this->ctrl->forwardCommand($ost_gui);
94 break;
95
96 default:
97 $cmd = $this->ctrl->getCmd();
98 if (!$cmd) {
99 return;
100 }
101 $this->$cmd();
102 $this->tpl->printToStdout();
103 break;
104 }
105
106 // E.G personal desktop mode needs $tpl->show();
107 $this->__buildFooter();
108
109
110 return true;
111 }
112
113 public function __setCmdClass($a_class)
114 {
115 // If cmd class == 'illearningprogressgui' the cmd class is set to the the new forwarded class
116 // otherwise e.g illplistofprogressgui tries to forward (back) to illearningprogressgui.
117
118 if ($this->ctrl->getCmdClass() == strtolower(get_class($this))) {
119 $this->ctrl->setCmdClass(strtolower($a_class));
120 }
121 return true;
122 }
123
124 public function __getNextClass()
125 {
126 global $DIC;
127
128 $ilAccess = $DIC['ilAccess'];
129 $ilUser = $DIC['ilUser'];
130
131 // #9857
133 return;
134 }
135
136 if (strlen($next_class = $this->ctrl->getNextClass())) {
137 if ($this->getMode() == self::LP_CONTEXT_PERSONAL_DESKTOP) {
138 $_SESSION['il_lp_history'] = $next_class;
139 }
140 return $next_class;
141 }
142 switch ($this->getMode()) {
144 return 'illplistofobjectsgui';
145
147 $cmd = $this->ctrl->getCmd();
148 if (in_array($cmd, array("editManual", "updatemanual", "showtlt"))) {
149 return "";
150 }
151
152 // #12771
153 include_once './Services/Object/classes/class.ilObjectLP.php';
155 if (!$olp->isActive()) {
156 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
157 if (!($olp instanceof ilPluginLP) &&
158 ilLearningProgressAccess::checkPermission('edit_learning_progress', $this->getRefId())) {
159 return 'illplistofsettingsgui';
160 } else {
161 return '';
162 }
163 }
164
165 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
166 if (!$this->anonymized &&
167 ilLearningProgressAccess::checkPermission('read_learning_progress', $this->getRefId())) {
168 return 'illplistofobjectsgui';
169 }
170 if (
171 ilLearningProgressAccess::checkPermission('edit_learning_progress', $this->getRefId())) {
172 return 'illplistofsettingsgui';
173 }
174 return 'illplistofprogressgui';
175
177
178 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
181
182 if ($has_edit || $has_personal) {
183 // default (#10928)
184 $tgt = null;
185 if ($has_personal) {
186 $tgt = 'illplistofprogressgui';
187 } elseif ($has_edit) {
188 $tgt = 'illplistofobjectsgui';
189 }
190
191 // validate session
192 switch ($_SESSION['il_lp_history']) {
193 case 'illplistofobjectsgui':
194 if (!$has_edit) {
195 $_SESSION['il_lp_history'] = null;
196 }
197 break;
198
199 case 'illplistofprogressgui':
200 if (!$has_personal) {
201 $_SESSION['il_lp_history'] = null;
202 }
203 break;
204 }
205
206 if ($_SESSION['il_lp_history']) {
207 return $_SESSION['il_lp_history'];
208 } elseif ($tgt) {
209 return $tgt;
210 }
211 }
212
213 // should not happen
214 ilUtil::redirect("ilias.php?baseClass=ilDashboardGUI");
215
216 // no break
220 return 'illplistofprogressgui';
221 }
222 break;
223 }
224 }
225
230 protected function editManual()
231 {
232 global $DIC;
233
234 $tpl = $DIC['tpl'];
235
238 if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL) {
239 $form = $this->initCollectionManualForm();
240 $tpl->setContent($form->getHTML());
241 }
242 }
243 }
244
245 protected function initCollectionManualForm()
246 {
247 global $DIC;
248
249 $lng = $DIC['lng'];
250 $ilCtrl = $DIC['ilCtrl'];
251
252 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
253 $form = new ilPropertyFormGUI();
254 $form->setFormAction($ilCtrl->getFormAction($this, "updatemanual"));
255 $form->setTitle($lng->txt("learning_progress"));
256 $form->setDescription($lng->txt("trac_collection_manual_learner_info"));
257
258 $coll_items = array();
259
260 include_once './Services/Object/classes/class.ilObjectLP.php';
261 $olp = ilObjectLP::getInstance($this->getObjId());
262 $collection = $olp->getCollectionInstance();
263 if ($collection) {
264 $coll_items = $collection->getItems();
265 $possible_items = $collection->getPossibleItems($this->getRefId()); // for titles
266
267 switch (ilObject::_lookupType($this->getObjId())) {
268 case "lm":
269 $subitem_title = $lng->txt("objs_st");
270 $subitem_info = $lng->txt("trac_collection_manual_learner_lm_info");
271 break;
272 }
273 }
274
275 include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
277 $lp_data = $class::_getObjectStatus($this->getObjId(), $this->usr_id);
278
280
281 $grp = new ilCheckboxGroupInputGUI($subitem_title, "sids");
282 $grp->setInfo($subitem_info);
283 $form->addItem($grp);
284
285 // #14994 - using possible items for proper sorting
286
287 $completed = array();
288 foreach (array_keys($possible_items) as $item_id) {
289 if (!in_array($item_id, $coll_items)) {
290 continue;
291 }
292
293 $info = null;
295
296 if (isset($lp_data[$item_id])) {
297 $changed = new ilDateTime($lp_data[$item_id][1], IL_CAL_UNIX);
298 $info = $lng->txt("trac_collection_manual_learner_changed_ts") . ": " .
300
301 if ($lp_data[$item_id][0]) {
303 $completed[] = $item_id;
304 }
305 }
306
307 $icon = $icons->renderIconForStatus($status);
308
309 $opt = new ilCheckboxOption(
310 $icon . " " . $possible_items[$item_id]["title"],
311 $item_id
312 );
313
314 if ($info) {
315 $opt->setInfo($info);
316 }
317 $grp->addOption($opt);
318 }
319
320 if ($completed) {
321 $grp->setValue($completed);
322 }
323
324 $form->addCommandButton("updatemanual", $lng->txt("save"));
325
326 return $form;
327 }
328
329 protected function updateManual()
330 {
331 global $DIC;
332
333 $ilCtrl = $DIC['ilCtrl'];
334 $lng = $DIC['lng'];
335
336 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
338 include_once './Services/Object/classes/class.ilObjectLP.php';
340 if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL) {
341 $form = $this->initCollectionManualForm();
342 if ($form->checkInput()) {
343 include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
345 $class::_setObjectStatus($this->getObjId(), $this->usr_id, $form->getInput("sids"));
346
347 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
348 }
349
350 $ilCtrl->redirect($this, "editManual");
351 }
352 }
353 }
354
355 protected function showtlt()
356 {
357 global $DIC;
358
359 $lng = $DIC['lng'];
360 $ilCtrl = $DIC['ilCtrl'];
361 $tpl = $DIC['tpl'];
362 $ilUser = $DIC['ilUser'];
363
364 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
365 $form = new ilPropertyFormGUI();
366 $form->setFormAction($ilCtrl->getFormAction($this, "showtlt"));
367 $form->setTitle($lng->txt("learning_progress"));
368 $form->setDescription($lng->txt("trac_collection_tlt_learner_info"));
369
370 $coll_items = array();
371
372 include_once './Services/Object/classes/class.ilObjectLP.php';
373 $olp = ilObjectLP::getInstance($this->getObjId());
374 $collection = $olp->getCollectionInstance();
375 if ($collection) {
376 $coll_items = $collection->getItems();
377 $possible_items = $collection->getPossibleItems($this->getRefId()); // for titles
378 }
379
380 include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
382 $info = $class::_getStatusInfo($this->getObjId(), true);
383
385
386 foreach ($coll_items as $item_id) {
387 // #16599 - deleted items should not be displayed
388 if (!array_key_exists($item_id, $possible_items)) {
389 continue;
390 }
391
392 $field = new ilCustomInputGUI($possible_items[$item_id]["title"]);
393
394 // lp status
396 if (isset($info["completed"][$item_id]) &&
397 in_array($ilUser->getId(), $info["completed"][$item_id])) {
399 } elseif (isset($info["in_progress"][$item_id]) &&
400 in_array($ilUser->getId(), $info["in_progress"][$item_id])) {
402 }
403
404 $field->setHtml($icons->renderIconForStatus($status));
405
406 // stats
407 $spent = 0;
408 if (isset($info["tlt_users"][$item_id][$ilUser->getId()])) {
409 $spent = $info["tlt_users"][$item_id][$ilUser->getId()];
410 }
411 $needed = $info["tlt"][$item_id];
412 if ($needed) {
413 $field->setInfo(sprintf(
414 $lng->txt("trac_collection_tlt_learner_subitem"),
417 min(100, round(abs($spent) / $needed * 100))
418 ));
419 }
420
421 $form->addItem($field);
422 }
423
424 $tpl->setContent($form->getHTML());
425 }
426}
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
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 secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
Class ilLPListOfSettingsGUI.
static _getClassById($a_obj_id, $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($a_permission, $a_ref_id, $a_user_id=null)
wrapper for rbac access checks
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
Class ilObjUserTrackingGUI.
editManual()
Show progress screen for "edit manual" @global type $tpl.
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
static getInstance($a_obj_id)
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
This class represents a property form user interface.
static redirect($a_script)
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18