ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
19 function ilLearningProgressGUI($a_mode,$a_ref_id = 0,$a_user_id = 0)
20 {
21 parent::ilLearningProgressBaseGUI($a_mode,$a_ref_id,$a_user_id);
22 }
23
27 function &executeCommand()
28 {
29 global $ilBench, $ilHelp, $ilAccess;
30
31 $ilBench->start('LearningProgress','0000_Start');
32
33 $this->ctrl->setReturn($this, "");
34
35 // E.g personal desktop mode needs locator header icon ...
36 $this->__buildHeader();
37 switch($this->__getNextClass())
38 {
39 case 'illplistofprogressgui':
40 include_once 'Services/Tracking/classes/repository_statistics/class.ilLPListOfProgressGUI.php';
41
42 $ilHelp->setScreenIdComponent("lp");
43
44 $this->__setSubTabs(self::LP_ACTIVE_PROGRESS);
45 $this->__setCmdClass('illplistofprogressgui');
46 $lop_gui = new ilLPListOfProgressGUI($this->getMode(),$this->getRefId(),$this->getUserId());
47 $this->ctrl->forwardCommand($lop_gui);
48 break;
49
50 case 'illplistofobjectsgui':
51 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
52 if($this->getRefId() &&
53 !ilLearningProgressAccess::checkPermission('read_learning_progress', $this->getRefId()))
54 {
55 return;
56 }
57
58 include_once 'Services/Tracking/classes/repository_statistics/class.ilLPListOfObjectsGUI.php';
59 if(stristr($this->ctrl->getCmd(), "matrix"))
60 {
61 $this->__setSubTabs(self::LP_ACTIVE_MATRIX);
62 }
63 else if(stristr($this->ctrl->getCmd(), "summary"))
64 {
65 $this->__setSubTabs(self::LP_ACTIVE_SUMMARY);
66 }
67 else
68 {
69 $this->__setSubTabs(self::LP_ACTIVE_OBJECTS);
70 }
71 $loo_gui = new ilLPListOfObjectsGUI($this->getMode(),$this->getRefId());
72 $this->__setCmdClass('illplistofobjectsgui');
73 $this->ctrl->forwardCommand($loo_gui);
74 break;
75
76 case 'illplistofsettingsgui':
77 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
78 if($this->getRefId() &&
79 !ilLearningProgressAccess::checkPermission('edit_learning_progress', $this->getRefId()))
80 {
81 return;
82 }
83
84 include_once 'Services/Tracking/classes/repository_statistics/class.ilLPListOfSettingsGUI.php';
85
86 $this->__setSubTabs(self::LP_ACTIVE_SETTINGS);
87 $los_gui = new ilLPListOfSettingsGUI($this->getMode(),$this->getRefId());
88 $this->__setCmdClass('illplistofsettingsgui');
89 $this->ctrl->forwardCommand($los_gui);
90 break;
91
92 case 'illpobjectstatisticsgui':
93 include_once 'Services/Tracking/classes/object_statistics/class.ilLPObjectStatisticsGUI.php';
94 if(stristr($this->ctrl->getCmd(), "access"))
95 {
96 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATACCESS);
97 }
98 else if(stristr($this->ctrl->getCmd(), "types"))
99 {
100 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATTYPES);
101 }
102 else if(stristr($this->ctrl->getCmd(), "daily"))
103 {
104 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATDAILY);
105 }
106 else
107 {
108 $this->__setSubTabs(self::LP_ACTIVE_OBJSTATADMIN);
109 }
110 $this->__setCmdClass('illpobjectstatisticsgui');
111 $ost_gui = new ilLPObjectStatisticsGUI($this->getMode(),$this->getRefId());
112 $this->ctrl->forwardCommand($ost_gui);
113 break;
114
115 default:
116 $cmd = $this->ctrl->getCmd();
117 $this->$cmd();
118 $this->tpl->show(true);
119 break;
120 }
121
122 // E.G personal desktop mode needs $tpl->show();
123 $this->__buildFooter();
124
125
126 $ilBench->stop('LearningProgress','0000_Start');
127
128 return true;
129 }
130
131 function __setCmdClass($a_class)
132 {
133 // If cmd class == 'illearningprogressgui' the cmd class is set to the the new forwarded class
134 // otherwise e.g illplistofprogressgui tries to forward (back) to illearningprogressgui.
135
136 if($this->ctrl->getCmdClass() == strtolower(get_class($this)))
137 {
138 $this->ctrl->setCmdClass(strtolower($a_class));
139 }
140 return true;
141 }
142
143 function __getNextClass()
144 {
145 global $ilAccess, $ilUser;
146
147 // #9857
149 {
150 return;
151 }
152
153 if(strlen($next_class = $this->ctrl->getNextClass()))
154 {
155 if($this->getMode() == self::LP_CONTEXT_PERSONAL_DESKTOP)
156 {
157 $_SESSION['il_lp_history'] = $next_class;
158 }
159 return $next_class;
160 }
161 switch($this->getMode())
162 {
164 return 'illplistofobjectsgui';
165
167 $cmd = $this->ctrl->getCmd();
168 if(in_array($cmd, array("editmanual", "updatemanual", "showtlt")))
169 {
170 return "";
171 }
172
173 // #12771
174 include_once './Services/Object/classes/class.ilObjectLP.php';
176 if(!$olp->isActive())
177 {
178 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
179 if(!($olp instanceof ilPluginLP) &&
180 ilLearningProgressAccess::checkPermission('edit_learning_progress', $this->getRefId()))
181 {
182 return 'illplistofsettingsgui';
183 }
184 else
185 {
186 return '';
187 }
188 }
189
190 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
191 if(!$this->anonymized &&
192 ilLearningProgressAccess::checkPermission('read_learning_progress', $this->getRefId()))
193 {
194 return 'illplistofobjectsgui';
195 }
196 if(
197 ilLearningProgressAccess::checkPermission('edit_learning_progress', $this->getRefId()))
198 {
199 return 'illplistofsettingsgui';
200 }
201 return 'illplistofprogressgui';
202
204
205 include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
208
209 if($has_edit || $has_personal)
210 {
211 // default (#10928)
212 $tgt = null;
213 if($has_personal)
214 {
215 $tgt = 'illplistofprogressgui';
216 }
217 else if($has_edit)
218 {
219 $tgt = 'illplistofobjectsgui';
220 }
221
222 // validate session
223 switch($_SESSION['il_lp_history'])
224 {
225 case 'illplistofobjectsgui':
226 if(!$has_edit)
227 {
228 $_SESSION['il_lp_history'] = null;
229 }
230 break;
231
232 case 'illplistofprogressgui':
233 if(!$has_personal)
234 {
235 $_SESSION['il_lp_history'] = null;
236 }
237 break;
238 }
239
240 if($_SESSION['il_lp_history'])
241 {
242 return $_SESSION['il_lp_history'];
243 }
244 else if($tgt)
245 {
246 return $tgt;
247 }
248 }
249
250 // should not happen
251 ilUtil::redirect("ilias.php?baseClass=ilPersonalDesktopGUI");
252
256 {
257 return 'illplistofprogressgui';
258 }
259 break;
260 }
261 }
262
263 protected function editManual()
264 {
265 global $tpl;
266
267 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
269 {
270 include_once './Services/Object/classes/class.ilObjectLP.php';
272 if($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL)
273 {
274 $form = $this->initCollectionManualForm();
275 $tpl->setContent($form->getHTML());
276 }
277 }
278 }
279
280 protected function initCollectionManualForm()
281 {
282 global $lng, $ilCtrl;
283
284 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
285 $form = new ilPropertyFormGUI();
286 $form->setFormAction($ilCtrl->getFormAction($this, "updatemanual"));
287 $form->setTitle($lng->txt("learning_progress"));
288 $form->setDescription($lng->txt("trac_collection_manual_learner_info"));
289
290 $coll_items = array();
291
292 include_once './Services/Object/classes/class.ilObjectLP.php';
293 $olp = ilObjectLP::getInstance($this->getObjId());
294 $collection = $olp->getCollectionInstance();
295 if($collection)
296 {
297 $coll_items = $collection->getItems();
298 $possible_items = $collection->getPossibleItems($this->getRefId()); // for titles
299
300 switch(ilObject::_lookupType($this->getObjId()))
301 {
302 case "lm":
303 $subitem_title = $lng->txt("objs_st");
304 $subitem_info = $lng->txt("trac_collection_manual_learner_lm_info");
305 break;
306 }
307 }
308
309 include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
311 $lp_data = $class::_getObjectStatus($this->getObjId(), $this->usr_id);
312
313 $grp = new ilCheckboxGroupInputGUI($subitem_title, "sids");
314 $grp->setInfo($subitem_info);
315 $form->addItem($grp);
316
317 // #14994 - using possible items for proper sorting
318
319 $completed = array();
320 foreach(array_keys($possible_items) as $item_id)
321 {
322 if(!in_array($item_id, $coll_items))
323 {
324 continue;
325 }
326
327 $info = null;
329
330 if(isset($lp_data[$item_id]))
331 {
332 $changed = new ilDateTime($lp_data[$item_id][1], IL_CAL_UNIX);
333 $info = $lng->txt("trac_collection_manual_learner_changed_ts").": ".
335
336 if($lp_data[$item_id][0])
337 {
339 $completed[] = $item_id;
340 }
341 }
342
345 $icon = ilUtil::img($path, $text);
346
347 $opt = new ilCheckboxOption($icon." ".$possible_items[$item_id]["title"], $item_id);
348 if($info)
349 {
350 $opt->setInfo($info);
351 }
352 $grp->addOption($opt);
353 }
354
355 if($completed)
356 {
357 $grp->setValue($completed);
358 }
359
360 $form->addCommandButton("updatemanual", $lng->txt("save"));
361
362 return $form;
363 }
364
365 protected function updateManual()
366 {
367 global $ilCtrl, $lng;
368
369 include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
371 {
372 include_once './Services/Object/classes/class.ilObjectLP.php';
374 if($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL)
375 {
376 $form = $this->initCollectionManualForm();
377 if($form->checkInput())
378 {
379 include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
381 $class::_setObjectStatus($this->getObjId(), $this->usr_id, $form->getInput("sids"));
382
383 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
384 }
385
386 $ilCtrl->redirect($this, "editmanual");
387 }
388 }
389 }
390
391 protected function showtlt()
392 {
393 global $lng, $ilCtrl, $tpl, $ilUser;
394
395 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
396 $form = new ilPropertyFormGUI();
397 $form->setFormAction($ilCtrl->getFormAction($this, "showtlt"));
398 $form->setTitle($lng->txt("learning_progress"));
399 $form->setDescription($lng->txt("trac_collection_tlt_learner_info"));
400
401 $coll_items = array();
402
403 include_once './Services/Object/classes/class.ilObjectLP.php';
404 $olp = ilObjectLP::getInstance($this->getObjId());
405 $collection = $olp->getCollectionInstance();
406 if($collection)
407 {
408 $coll_items = $collection->getItems();
409 $possible_items = $collection->getPossibleItems($this->getRefId()); // for titles
410 }
411
412 include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
414 $info = $class::_getStatusInfo($this->getObjId(), true);
415
416 foreach($coll_items as $item_id)
417 {
418 // #16599 - deleted items should not be displayed
419 if(!array_key_exists($item_id, $possible_items))
420 {
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($ilUser->getId(), $info["completed"][$item_id]))
430 {
432 }
433 else if(isset($info["in_progress"][$item_id]) &&
434 in_array($ilUser->getId(), $info["in_progress"][$item_id]))
435 {
437 }
440 $field->setHtml(ilUtil::img($path, $text));
441
442 // stats
443 $spent = 0;
444 if(isset($info["tlt_users"][$item_id][$ilUser->getId()]))
445 {
446 $spent = $info["tlt_users"][$item_id][$ilUser->getId()];
447 }
448 $needed = $info["tlt"][$item_id];
449 if($needed)
450 {
451 $field->setInfo(sprintf($lng->txt("trac_collection_tlt_learner_subitem"),
454 min(100, round(abs($spent)/$needed*100))));
455 }
456
457 $form->addItem($field);
458 }
459
460 $tpl->setContent($form->getHTML());
461 }
462}
463?>
$_SESSION["AccountId"]
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)
Format a date @access public.
@classDescription Date and time handling
_secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
Class ilLPListOfSettingsGUI.
_getClassById($a_obj_id, $a_mode=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
_getImagePathForStatus($a_status)
Get image path for status.
_getStatusText($a_status, $a_lng=null)
Get status alt text.
Class ilObjUserTrackingGUI.
ilLearningProgressGUI($a_mode, $a_ref_id=0, $a_user_id=0)
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
http redirect to other script
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
$text
$info
Definition: example_052.php:80
global $ilBench
Definition: ilias.php:18
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
$path
Definition: index.php:22
global $ilUser
Definition: imgupload.php:15