ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPCollectionSettingsTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 private int $node_id;
29 private int $mode;
30
32
33 public function __construct(
34 ?object $a_parent_obj,
35 string $a_parent_cmd,
36 int $a_node_id,
37 int $a_mode
38 ) {
39 global $DIC;
40
41 $this->obj_definition = $DIC["objDefinition"];
42 $this->node_id = $a_node_id;
43 $this->mode = $a_mode;
44
45 $this->setId('lpobjs_' . $this->getNode());
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47
48 $this->setShowRowsSelector(false);
49 }
50
51 public function getNode(): int
52 {
53 return $this->node_id;
54 }
55
56 public function getMode(): int
57 {
58 return $this->mode;
59 }
60
64 public function parse(ilLPCollection $a_collection): void
65 {
66 $this->setData($a_collection->getTableGUIData($this->getNode()));
67 $this->initTable();
68
69 // grouping actions
73 )) {
74 $this->addMultiCommand(
75 'releaseMaterials',
76 $this->lng->txt('trac_release_materials')
77 );
78
79 foreach ($this->row_data as $item) {
80 if ($item["grouped"]) {
81 $this->addCommandButton(
82 'saveObligatoryMaterials',
83 $this->lng->txt(
84 'trac_group_materials_save'
85 )
86 );
87 break;
88 }
89 }
90 }
91 }
92
93 protected function fillRow(array $a_set): void
94 {
95 $this->tpl->setCurrentBlock('item_row');
96 $this->tpl->setVariable('ITEM_ID', $a_set['id']);
97 $this->tpl->setVariable('COLL_TITLE', $a_set['title'] ?? "");
98 $this->tpl->setVariable('COLL_DESC', $a_set['description'] ?? "");
99
100 if ($this->obj_definition->isPluginTypeName($a_set["type"])) {
102 $a_set['type'],
103 "obj_" . $a_set['type']
104 );
105 } else {
106 $alt = $this->lng->txt('obj_' . $a_set['type']);
107 }
108 $this->tpl->setVariable('ALT_IMG', $alt);
109 $this->tpl->setVariable(
110 'TYPE_IMG',
112 (int) ($a_set['obj_id'] ?? 0),
113 'tiny',
114 $a_set['type']
115 )
116 );
117
118 if (
121 if ($a_set['ref_id']) {
122 $this->tpl->setVariable(
123 'COLL_LINK',
124 ilLink::_getLink(
125 $a_set['ref_id'],
126 $a_set['type']
127 )
128 );
129 $this->tpl->setVariable(
130 'COLL_FRAME',
132 'MainContent'
133 )
134 );
135
136 $path = new ilPathGUI();
137 $this->tpl->setVariable(
138 'COLL_PATH',
139 $this->lng->txt('path') . ': ' . $path->getPath(
140 $this->getNode(),
141 $a_set['ref_id']
142 )
143 );
144
145 $mode_suffix = '';
146 if (
147 ($a_set['grouped'] ?? false) ||
148 ($a_set['group_item'] ?? null)) {
149 // #14941
150 $mode_suffix = '_INLINE';
151
152 if (!($a_set['group_item'] ?? false)) {
153 $this->tpl->setVariable("COLL_MODE", "");
154 }
155 }
157 'edit_learning_progress',
158 (int) $a_set['ref_id']
159 )) {
160 $gui_class = "ilObj" . $this->obj_definition->getClassName(
161 $a_set['type']
162 ) . "GUI";
163 $this->ctrl->setParameterByClass(
164 ilLearningProgressGUI::class,
165 'ref_id',
166 $a_set['ref_id']
167 );
168 if ('sahs' === $a_set['type']) {
169 $obj_id = ilObject::_lookupObjectId((int) $a_set['ref_id']);
171 $obj_id
172 )) {
173 case "scorm2004":
174 $gui_class = ilSAHSEditGUI::class;
175 $scorm_class = ilObjSCORM2004LearningModuleGUI::class;
176 break;
177
178 case "scorm":
179 $gui_class = ilSAHSEditGUI::class;
180 $scorm_class = ilObjSCORMLearningModuleGUI::class;
181 break;
182
183 default:
184 $scorm_class = '';
185 break;
186 }
187
188 $lp_settings_link = $this->ctrl->getLinkTargetByClass(
189 [
190 $gui_class,
191 $scorm_class,
192 ilLearningProgressGUI::class,
193 ilLPListOfSettingsGUI::class,
194 ]
195 );
196 } elseif ('lm' === $a_set['type']) {
197 $lp_settings_link = $this->ctrl->getLinkTargetByClass(
198 [
199 ilLMEditorGUI::class,
200 ilObjLearningModuleGUI::class,
201 ilLearningProgressGUI::class,
202 ]
203 );
204 } else {
205 $lp_settings_link = $this->ctrl->getLinkTargetByClass(
206 [
207 ilRepositoryGUI::class,
208 $gui_class,
209 ilLearningProgressGUI::class,
210 ]
211 );
212 }
213
214 $this->ctrl->clearParameterByClass(
215 ilLearningProgressGUI::class,
216 'ref_id'
217 );
218
219 $a_set["mode"] = '<a href="' . $lp_settings_link . '">' . $a_set['mode'] . '</a>'; // :TODO: il_ItemAlertProperty?
220 }
221
222 $mode = $a_set['mode_id'];
224 $this->tpl->setVariable(
225 "COLL_MODE" . $mode_suffix,
226 $a_set['mode']
227 );
228 } else {
229 $this->tpl->setVariable("COLL_MODE" . $mode_suffix, "");
230 $this->tpl->setVariable(
231 "COLL_MODE_DEACTIVATED" . $mode_suffix,
232 $a_set['mode']
233 );
234 }
235 if ($a_set["anonymized"]) {
236 $this->tpl->setVariable(
237 "ANONYMIZED" . $mode_suffix,
238 $this->lng->txt(
239 'trac_anonymized_info_short'
240 )
241 );
242 }
243
244 if ($mode_suffix) {
245 $this->tpl->setVariable(
246 "COLL_MODE_LABEL",
247 $this->lng->txt("trac_mode")
248 );
249 }
250 }
251 } else {
252 $this->tpl->setVariable('COLL_LINK', $a_set['url']);
253
255 // handle tlt settings
256 $this->tpl->setCurrentBlock("tlt");
257 $this->tpl->setVariable(
258 "TXT_MONTH",
259 $this->lng->txt('md_months')
260 );
261 $this->tpl->setVariable("TXT_DAYS", $this->lng->txt('md_days'));
262 $this->tpl->setVariable("TXT_TIME", $this->lng->txt('md_time'));
263 $this->tpl->setVariable("TLT_HINT", '(hh:mm)');
264
265 // seconds to units
266 $mon = floor($a_set["tlt"] / (60 * 60 * 24 * 30));
267 $tlt = $a_set["tlt"] % (60 * 60 * 24 * 30);
268 $day = floor($tlt / (60 * 60 * 24));
269 $tlt = $tlt % (60 * 60 * 24);
270 $hr = floor($tlt / (60 * 60));
271 $tlt = $tlt % (60 * 60);
272 $min = floor($tlt / 60);
273
274 $options = array();
275 for ($i = 0; $i <= 24; $i++) {
276 $options[$i] = sprintf('%02d', $i);
277 }
278 $this->tpl->setVariable(
279 "SEL_MONTHS",
281 $mon,
282 'tlt[' . $a_set['id'] . '][mo]',
283 $options,
284 false,
285 true
286 )
287 );
288
289 for ($i = 0; $i <= 31; $i++) {
290 $options[$i] = sprintf('%02d', $i);
291 }
292 $this->tpl->setVariable(
293 "SEL_DAYS",
295 $day,
296 'tlt[' . $a_set['id'] . '][d]',
297 $options,
298 false,
299 true
300 )
301 );
302
303 $this->tpl->setVariable(
304 "SEL_TLT",
306 'tlt[' . $a_set['id'] . ']',
307 true,
308 (int) $hr,
309 (int) $min,
310 0,
311 false
312 )
313 );
314
315 $this->tpl->parseCurrentBlock();
316 }
317 }
318
319 // Assigned ?
320 $this->tpl->setVariable(
321 "ASSIGNED_IMG_OK",
322 $a_set['status']
323 ? ilUtil::getImagePath('standard/icon_ok.svg')
324 : ilUtil::getImagePath('standard/icon_not_ok.svg')
325 );
326 $this->tpl->setVariable(
327 "ASSIGNED_STATUS",
328 $a_set['status']
329 ? $this->lng->txt('trac_assigned')
330 : $this->lng->txt('trac_not_assigned')
331 );
332 $this->tpl->parseCurrentBlock();
333
334 // Parse grouped items
335 if (isset($a_set['grouped'])) {
336 foreach ((array) $a_set['grouped'] as $item) {
337 $item['group_item'] = true;
338 $this->fillRow($item);
339 }
340 }
341
342 // show num obligatory info
343 if (
344 is_array($a_set) &&
345 array_key_exists('grouped', $a_set) &&
346 count($a_set['grouped'])
347 ) {
348 $this->tpl->setCurrentBlock('num_passed_items');
349 $this->tpl->setVariable(
350 'MIN_PASSED_TXT',
351 $this->lng->txt('trac_min_passed')
352 );
353 $this->tpl->setVariable('NUM_OBLIGATORY', $a_set['num_obligatory']);
354 $this->tpl->setVariable('GRP_ID', $a_set['grouping_id']);
355 $this->tpl->parseCurrentBlock();
356 }
357 }
358
359 protected function initTable(): void
360 {
361 $this->setFormAction(
362 $this->ctrl->getFormAction($this->getParentObject())
363 );
364 switch ($this->getMode()) {
367 $this->setRowTemplate(
368 'tpl.lp_collection_row.html',
369 'components/ILIAS/Tracking'
370 );
371 $this->setTitle($this->lng->txt('trac_lp_determination'));
372 $this->setDescription(
373 $this->lng->txt('trac_lp_determination_info_crs')
374 );
375 break;
376
378 $this->setRowTemplate(
379 'tpl.lp_collection_row.html',
380 'components/ILIAS/Tracking'
381 );
382 $this->setTitle($this->lng->txt('trac_lp_determination_tutor'));
383 $this->setDescription(
384 $this->lng->txt('trac_lp_determination_info_crs_tutor')
385 );
386 break;
387
389 $this->setRowTemplate(
390 'tpl.lp_collection_scorm_row.html',
391 'components/ILIAS/Tracking'
392 );
393 $this->setTitle($this->lng->txt('trac_lp_determination'));
394 $this->setDescription(
395 $this->lng->txt('trac_lp_determination_info_sco')
396 );
397 break;
398
400 $this->setRowTemplate(
401 'tpl.lp_collection_subitem_row.html',
402 'components/ILIAS/Tracking'
403 );
404 $this->setTitle($this->lng->txt('trac_lp_determination'));
405 $this->setDescription(
406 $this->lng->txt('trac_lp_determination_info_crs')
407 );
408 $this->lng->loadLanguageModule("meta");
409
410 $this->addCommandButton('updateTLT', $this->lng->txt('save'));
411 break;
412
414 $this->setRowTemplate(
415 'tpl.lp_collection_subitem_row.html',
416 'components/ILIAS/Tracking'
417 );
418 $this->setTitle($this->lng->txt('trac_lp_determination'));
419 $this->setDescription(
420 $this->lng->txt('trac_lp_determination_info_mob')
421 );
422 break;
423 }
424
425 $this->addColumn('', '', '1px');
426 $this->addColumn($this->lng->txt('item'), 'title', '50%');
427
428 if ($this->getMode() != ilLPObjSettings::LP_MODE_SCORM &&
432 $this->addColumn($this->lng->txt('trac_mode'), 'mode');
433 } elseif ($this->getMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) {
434 $this->addColumn(
435 $this->lng->txt('meta_typical_learning_time'),
436 'tlt'
437 );
438 }
439
441 $this->addMultiCommand(
442 'assign',
443 $this->lng->txt('trac_collection_assign')
444 );
445 $this->addMultiCommand(
446 'deassign',
447 $this->lng->txt('trac_collection_deassign')
448 );
449 $this->addColumn(
450 $this->lng->txt('trac_determines_learning_progress'),
451 'status'
452 );
453 } else {
454 $this->addMultiCommand(
455 'assign',
456 $this->lng->txt('trac_manual_display')
457 );
458 $this->addMultiCommand(
459 'deassign',
460 $this->lng->txt('trac_manual_no_display')
461 );
462 $this->addColumn(
463 $this->lng->txt('trac_manual_is_displayed'),
464 'status'
465 );
466 }
467
468 $this->enable('select_all');
469 $this->setSelectAllCheckbox('item_ids');
470
472 $this->addMultiCommand(
473 'groupMaterials',
474 $this->lng->txt('trac_group_materials')
475 );
476 }
477 }
478}
static _getFrame(string $a_class)
__construct(?object $a_parent_obj, string $a_parent_cmd, int $a_node_id, int $a_mode)
parse(ilLPCollection $a_collection)
Read and parse items.
fillRow(array $a_set)
Standard Version of Fill Row.
LP collection base class.
static checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
static makeTimeSelect(string $prefix, bool $short=true, int $hour=0, int $minute=0, int $second=0, bool $a_use_default=true, array $a_further_options=[])
Creates a combination of HTML selects for time inputs.
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
static _lookupSubType(int $a_obj_id)
lookup subtype id (scorm, )
parses the objects.xml it handles the xml-description of all ilias objects
static lookupTxtById(string $plugin_id, string $lang_var)
static _lookupObjectId(int $ref_id)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setDescription(string $a_val)
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
enable(string $a_module_name)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26