ILIAS  release_8 Revision v8.24
class.ilObjUserTrackingGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
4/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
5
15{
18
19 public function __construct(
20 $a_data,
21 int $a_id,
22 bool $a_call_by_reference,
24 ) {
25 global $DIC;
26
27 $this->error = $DIC['ilErr'];
28 $this->objectDefinition = $DIC['objDefinition'];
29
30 $this->type = "trac";
31 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
32 $this->lng->loadLanguageModule('trac');
33 }
34
35 public function executeCommand(): void
36 {
37 $next_class = $this->ctrl->getNextClass();
38 $this->ctrl->setReturn($this, "show");
39 $this->prepareOutput();
40
41 switch ($next_class) {
42 case 'ilpermissiongui':
43 $perm_gui = new ilPermissionGUI($this);
44 $this->ctrl->forwardCommand($perm_gui);
45 break;
46
47 case 'illearningprogressgui':
48 $this->tabs_gui->setTabActive('learning_progress');
49 $lp_gui = new ilLearningProgressGUI(
51 );
52 $this->ctrl->forwardCommand($lp_gui);
53 break;
54
55 case 'illpobjectstatisticsgui':
56 $this->tabs_gui->activateTab('statistics');
57 $os_gui = new ilLPObjectStatisticsGUI(
59 );
60 $this->ctrl->forwardCommand($os_gui);
61 break;
62
63 case 'ilsessionstatisticsgui':
64 $this->tabs_gui->setTabActive('session_statistics');
65 $sess_gui = new ilSessionStatisticsGUI();
66 $this->ctrl->forwardCommand($sess_gui);
67 break;
68
69 default:
70 $cmd = $this->ctrl->getCmd();
71 if ($cmd == "view" || $cmd == "") {
72 $cmd = "settings";
73 }
74 $cmd .= "Object";
75 $this->$cmd();
76 break;
77 }
78 }
79
80 public function getAdminTabs(): void
81 {
82 $this->getTabs();
83 }
84
85 protected function getTabs(): void
86 {
87 $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
88
89 $this->tabs_gui->addTarget(
90 "settings",
91 $this->ctrl->getLinkTarget($this, "settings"),
92 "settings",
93 get_class($this)
94 );
95
96 if ($this->rbac_system->checkAccess("visible,read", $this->ref_id)) {
98 $this->tabs_gui->addTarget(
99 "statistics",
100 $this->ctrl->getLinkTargetByClass(
101 "illpobjectstatisticsgui",
102 "access"
103 ),
104 "",
105 "illpobjectstatisticsgui"
106 );
107 }
108
110 $this->tabs_gui->addTarget(
111 "learning_progress",
112 $this->ctrl->getLinkTargetByClass(
113 "illearningprogressgui",
114 "show"
115 ),
116 "",
117 "illearningprogressgui"
118 );
119 }
120
121 // session statistics
123 $this->tabs_gui->addTarget(
124 "session_statistics",
125 $this->ctrl->getLinkTargetByClass(
126 "ilsessionstatisticsgui",
127 ""
128 ),
129 "",
130 "ilsessionstatisticsgui"
131 );
132 }
133 }
134
135 if ($this->checkPermissionBool("edit_permission")) {
136 $this->tabs_gui->addTarget(
137 "perm_settings",
138 $this->ctrl->getLinkTargetByClass(
139 array(get_class($this), 'ilpermissiongui'),
140 "perm"
141 ),
142 array("perm", "info", "owner"),
143 'ilpermissiongui'
144 );
145 }
146 }
147
148 public function settingsObject(?ilPropertyFormGUI $a_form = null): void
149 {
150 if (!$this->rbac_system->checkAccess(
151 "visible,read",
152 $this->object->getRefId()
153 )) {
154 $this->error->raiseError(
155 $this->lng->txt("no_permission"),
156 $this->error->WARNING
157 );
158 }
159
160 $this->tabs_gui->addSubTab(
161 'lp_settings',
162 $this->lng->txt('settings'),
163 $this->ctrl->getLinkTarget($this, 'settings')
164 );
165
167 $this->tabs_gui->addSubTab(
168 'lpdef',
169 $this->lng->txt('trac_defaults'),
170 $this->ctrl->getLinkTarget($this, 'editLPDefaults')
171 );
172 }
173
174 $this->tabs_gui->setTabActive('settings');
175 $this->tabs_gui->setSubTabActive('lp_settings');
176
177 if (!$a_form) {
178 $a_form = $this->initSettingsForm();
179 }
180
181 $this->tpl->setContent($a_form->getHTML());
182 }
183
185 {
186 $form = new ilPropertyFormGUI();
187 $form->setFormAction($this->ctrl->getFormAction($this));
188 $form->setTitle($this->lng->txt('tracking_settings'));
189
190 $activate = new ilCheckboxGroupInputGUI(
191 $this->lng->txt('activate_tracking')
192 );
193 $form->addItem($activate);
194
195 // learning progress
196 $lp = new ilCheckboxInputGUI(
197 $this->lng->txt('trac_learning_progress'),
198 'learning_progress_tracking'
199 );
200 if ($this->object->enabledLearningProgress()) {
201 $lp->setChecked(true);
202 }
203 $activate->addSubItem($lp);
204
205 // lp settings
206
207 $learner = new ilCheckboxInputGUI(
208 $this->lng->txt('trac_lp_learner_access'),
209 'lp_learner'
210 );
211 $learner->setInfo($this->lng->txt('trac_lp_learner_access_info'));
212 $learner->setChecked($this->object->hasLearningProgressLearner());
213 $lp->addSubItem($learner);
214
215 // extended data
216
217 $extdata = new ilCheckboxGroupInputGUI(
218 $this->lng->txt('trac_learning_progress_settings_info'),
219 'lp_extdata'
220 );
221 $extdata->addOption(
223 $this->lng->txt('trac_first_and_last_access'),
224 'lp_access'
225 )
226 );
227 $extdata->addOption(
228 new ilCheckboxOption($this->lng->txt('trac_read_count'), 'lp_count')
229 );
230 $extdata->addOption(
232 $this->lng->txt('trac_spent_seconds'),
233 'lp_spent'
234 )
235 );
236 $lp->addSubItem($extdata);
237
238 $ext_value = array();
239 if ($this->object->hasExtendedData(
241 )) {
242 $ext_value[] = 'lp_access';
243 }
244 if ($this->object->hasExtendedData(
246 )) {
247 $ext_value[] = 'lp_count';
248 }
249 if ($this->object->hasExtendedData(
251 )) {
252 $ext_value[] = 'lp_spent';
253 }
254 $extdata->setValue($ext_value);
255
256 $listgui = new ilCheckboxInputGUI(
257 $this->lng->txt('trac_lp_list_gui'),
258 'lp_list'
259 );
260 $listgui->setInfo($this->lng->txt('trac_lp_list_gui_info'));
261 $listgui->setChecked($this->object->hasLearningProgressListGUI());
262 $lp->addSubItem($listgui);
263
264 // object statistics
265 $objstat = new ilCheckboxInputGUI(
266 $this->lng->txt('trac_object_statistics'),
267 'object_statistics'
268 );
269 if ($this->object->enabledObjectStatistics()) {
270 $objstat->setChecked(true);
271 }
272 $activate->addSubItem($objstat);
273
274 // session statistics
275 $sessstat = new ilCheckboxInputGUI(
276 $this->lng->txt('session_statistics'),
277 'session_statistics'
278 );
279 if ($this->object->enabledSessionStatistics()) {
280 $sessstat->setChecked(true);
281 }
282 $activate->addSubItem($sessstat);
283
284 // Anonymized
286 $this->lng->txt('trac_anonymized'),
287 'user_related'
288 );
289 $user->setInfo($this->lng->txt('trac_anonymized_info'));
290 $user->setChecked(!$this->object->enabledUserRelatedData());
291 $form->addItem($user);
292
293 // Max time gap
295 $this->lng->txt('trac_valid_request'),
296 'valid_request'
297 );
298 $valid->setMaxLength(4);
299 $valid->setSize(4);
300 $valid->setSuffix($this->lng->txt('seconds'));
301 $valid->setInfo($this->lng->txt('info_valid_request'));
302 $valid->setValue((string) $this->object->getValidTimeSpan());
303 $valid->setMinValue(1);
304 $valid->setMaxValue(9999);
305 $valid->setRequired(true);
306 $form->addItem($valid);
307
310 $form,
311 $this
312 );
313
314 // #12259
315 if ($this->checkPermissionBool("write")) {
316 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
317 } else {
318 $lp->setDisabled(true);
319 $learner->setDisabled(true);
320 $extdata->setDisabled(true);
321 $listgui->setDisabled(true);
322 $objstat->setDisabled(true);
323 $user->setDisabled(true);
324 $valid->setDisabled(true);
325 }
326
327 return $form;
328 }
329
330 public function saveSettingsObject(): void
331 {
332 $this->checkPermission('write');
333
334 $form = $this->initSettingsForm();
335 if ($form->checkInput()) {
336 $lp_active = $form->getInput('learning_progress_tracking');
337
338 $this->object->enableLearningProgress((bool) $lp_active);
339
340 if ($lp_active) {
341 $ext_data = (array) $form->getInput("lp_extdata");
342 $code = 0;
343 if (in_array('lp_access', $ext_data)) {
345 }
346 if (in_array('lp_count', $ext_data)) {
348 }
349 if (in_array('lp_spent', $ext_data)) {
351 }
352 $this->object->setExtendedData($code);
353 }
354
355 $this->object->enableChangeEventTracking(
356 (bool) $form->getInput('change_event_tracking')
357 );
358 $this->object->enableObjectStatistics(
359 (bool) $form->getInput('object_statistics')
360 );
361 $this->object->enableUserRelatedData(
362 !$form->getInput('user_related')
363 );
364 $this->object->setValidTimeSpan(
365 (int) $form->getInput('valid_request')
366 );
367 // $this->object->setLearningProgressDesktop($form->getInput('lp_desktop'));
368 $this->object->setLearningProgressLearner(
369 (bool) $form->getInput('lp_learner')
370 );
371 $this->object->enableSessionStatistics(
372 (bool) $form->getInput('session_statistics')
373 );
374 $this->object->setLearningProgressListGUI(
375 (bool) $form->getInput('lp_list')
376 );
377 $this->object->updateSettings();
378
379 $this->tpl->setOnScreenMessage(
380 'success',
381 $this->lng->txt("msg_obj_modified"),
382 true
383 );
384 $this->ctrl->redirect($this, "settings");
385 }
386 $form->setValuesByPost();
387 $this->settingsObject($form);
388 }
389
390 protected function editLPDefaultsObject(
391 ?ilPropertyFormGUI $a_form = null
392 ): void {
393 $this->checkPermission('read');
394
395 $this->tabs_gui->addSubTab(
396 'lp_settings',
397 $this->lng->txt('settings'),
398 $this->ctrl->getLinkTarget($this, 'settings')
399 );
400
401 $this->tabs_gui->addSubTab(
402 'lpdef',
403 $this->lng->txt('trac_defaults'),
404 $this->ctrl->getLinkTarget($this, 'editLPDefaults')
405 );
406
407 $this->tabs_gui->setTabActive('settings');
408 $this->tabs_gui->setSubTabActive('lpdef');
409
410 if (!$a_form) {
411 $a_form = $this->initLPDefaultsForm();
412 }
413
414 $this->tpl->setContent($a_form->getHTML());
415 }
416
418 {
419 $form = new ilPropertyFormGUI();
420 $form->setFormAction($this->ctrl->getFormAction($this));
421 $form->setTitle($this->lng->txt('trac_defaults'));
422 $form->setDescription($this->lng->txt('trac_defaults_info'));
423
424 $types = array();
425 foreach ($this->objectDefinition->getAllRepositoryTypes() as $type) {
427 $types[$type] = array(
428 "type" => $type,
429 "caption" => $this->lng->txt("obj_" . $type)
430 );
431 }
432 }
433 $types = ilArrayUtil::sortArray($types, "caption", "asc");
434 foreach ($types as $item) {
435 $class = ilObjectLP::getTypeClass($item["type"]);
436 $modes = $class::getDefaultModes(
438 );
439 if (sizeof($modes) > 1) {
440 $def_type = new ilSelectInputGUI(
441 $item["caption"],
442 "def_" . $item["type"]
443 );
444 $form->addItem($def_type);
445
446 $def_type->setRequired(true);
447 $def_type->setValue(ilObjectLP::getTypeDefault($item["type"]));
448
449 $options = array();
450 foreach ($modes as $mode) {
451 $caption = ($mode == ilLPObjSettings::LP_MODE_DEACTIVATED)
452 ? $this->lng->txt("trac_defaults_inactive")
454 $options[$mode] = $caption;
455 }
456 $def_type->setOptions($options);
457 }
458 }
459
460 if ($this->checkPermissionBool("write")) {
461 $form->addCommandButton('saveLPDefaults', $this->lng->txt('save'));
462 } else {
463 foreach ($types as $item) {
464 $form->getItemByPostVar("def_" . $item["type"])->setDisabled(
465 true
466 );
467 }
468 }
469 return $form;
470 }
471
472 protected function saveLPDefaultsObject(): void
473 {
474 $this->checkPermission('write');
475
476 $form = $this->initLPDefaultsForm();
477 if ($form->checkInput()) {
478 $res = array();
479 foreach ($this->objectDefinition->getAllRepositoryTypes(
480 ) as $type) {
482 $mode = $form->getInput("def_" . $type);
483 $res[$type] = $mode
485 }
486 }
487
489
490 $this->tpl->setOnScreenMessage(
491 'success',
492 $this->lng->txt("msg_obj_modified"),
493 true
494 );
495 $this->ctrl->redirect($this, "editLPDefaults");
496 }
497
498 $form->setValuesByPost();
499 $this->editLPDefaultsObject($form);
500 }
501
502 public function addToExternalSettingsForm(int $a_form_id): array
503 {
504 switch ($a_form_id) {
506 $fields = array();
507 return array('obj_trac' => array('editLPDefaults', $fields));
508 }
509 return [];
510 }
511}
error(string $a_errmsg)
return true
static addFieldsToForm(int $a_form_id, ilPropertyFormGUI $a_form, ilObjectGUI $a_parent_gui)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Error Handling & global info handling uses PEAR error class.
static _mode2Text(int $a_mode)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a number property in a property form.
__construct( $a_data, int $a_id, bool $a_call_by_reference, bool $prepare_output)
settingsObject(?ilPropertyFormGUI $a_form=null)
ilObjectDefinition $objectDefinition
editLPDefaultsObject(?ilPropertyFormGUI $a_form=null)
getTabs()
@abstract overwrite in derived GUI class of your object type
getAdminTabs()
administration tabs show only permissions and trash folder
parses the objects.xml it handles the xml-description of all ilias objects
Class ilObjectGUI Basic methods of all Output classes.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
static saveTypeDefaults(array $data)
static getTypeDefault(string $type)
static isSupportedObjectType(string $type)
static getTypeClass(string $type)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
This class represents a selection list property in a property form.
$valid
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type