ILIAS  release_8 Revision v8.24
class.ilLPCollectionSettingsTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
11{
12 private int $node_id;
13 private int $mode;
14
16
17 public function __construct(
18 ?object $a_parent_obj,
19 string $a_parent_cmd,
20 int $a_node_id,
21 int $a_mode
22 ) {
23 global $DIC;
24
25 $this->obj_definition = $DIC["objDefinition"];
26 $this->node_id = $a_node_id;
27 $this->mode = $a_mode;
28
29 $this->setId('lpobjs_' . $this->getNode());
30 parent::__construct($a_parent_obj, $a_parent_cmd);
31
32 $this->setShowRowsSelector(false);
33 }
34
35 public function getNode(): int
36 {
37 return $this->node_id;
38 }
39
40 public function getMode(): int
41 {
42 return $this->mode;
43 }
44
48 public function parse(ilLPCollection $a_collection): void
49 {
50 $this->setData($a_collection->getTableGUIData($this->getNode()));
51 $this->initTable();
52
53 // grouping actions
57 )) {
58 $this->addMultiCommand(
59 'releaseMaterials',
60 $this->lng->txt('trac_release_materials')
61 );
62
63 foreach ($this->row_data as $item) {
64 if ($item["grouped"]) {
65 $this->addCommandButton(
66 'saveObligatoryMaterials',
67 $this->lng->txt(
68 'trac_group_materials_save'
69 )
70 );
71 break;
72 }
73 }
74 }
75 }
76
77 protected function fillRow(array $a_set): void
78 {
79 $this->tpl->setCurrentBlock('item_row');
80 $this->tpl->setVariable('ITEM_ID', $a_set['id']);
81 $this->tpl->setVariable('COLL_TITLE', $a_set['title'] ?? "");
82 $this->tpl->setVariable('COLL_DESC', $a_set['description'] ?? "");
83
84 if ($this->obj_definition->isPluginTypeName($a_set["type"])) {
86 $a_set['type'],
87 "obj_" . $a_set['type']
88 );
89 } else {
90 $alt = $this->lng->txt('obj_' . $a_set['type']);
91 }
92 $this->tpl->setVariable('ALT_IMG', $alt);
93 $this->tpl->setVariable(
94 'TYPE_IMG',
96 (int) ($a_set['obj_id'] ?? 0),
97 'tiny',
98 $a_set['type']
99 )
100 );
101
102 if (
105 if ($a_set['ref_id']) {
106 $this->tpl->setVariable(
107 'COLL_LINK',
109 $a_set['ref_id'],
110 $a_set['type']
111 )
112 );
113 $this->tpl->setVariable(
114 'COLL_FRAME',
116 'MainContent'
117 )
118 );
119
120 $path = new ilPathGUI();
121 $this->tpl->setVariable(
122 'COLL_PATH',
123 $this->lng->txt('path') . ': ' . $path->getPath(
124 $this->getNode(),
125 $a_set['ref_id']
126 )
127 );
128
129 $mode_suffix = '';
130 if (
131 ($a_set['grouped'] ?? false) ||
132 ($a_set['group_item'] ?? null)) {
133 // #14941
134 $mode_suffix = '_INLINE';
135
136 if (!($a_set['group_item'] ?? false)) {
137 $this->tpl->setVariable("COLL_MODE", "");
138 }
139 }
141 'edit_learning_progress',
142 (int) $a_set['ref_id']
143 )) {
144 $gui_class = "ilObj" . $this->obj_definition->getClassName(
145 $a_set['type']
146 ) . "GUI";
147 $this->ctrl->setParameterByClass(
148 ilLearningProgressGUI::class,
149 'ref_id',
150 $a_set['ref_id']
151 );
152 if ('sahs' === $a_set['type']) {
153 $obj_id = ilObject::_lookupObjectId((int) $a_set['ref_id']);
155 $obj_id
156 )) {
157 case "scorm2004":
158 $gui_class = ilSAHSEditGUI::class;
159 $scorm_class = ilObjSCORM2004LearningModuleGUI::class;
160 break;
161
162 case "scorm":
163 $gui_class = ilSAHSEditGUI::class;
164 $scorm_class = ilObjSCORMLearningModuleGUI::class;
165 break;
166
167 default:
168 $scorm_class = '';
169 break;
170 }
171
172 $lp_settings_link = $this->ctrl->getLinkTargetByClass(
173 [
174 $gui_class,
175 $scorm_class,
176 ilLearningProgressGUI::class,
177 ilLPListOfSettingsGUI::class,
178 ]
179 );
180 } elseif ('lm' === $a_set['type']) {
181 $lp_settings_link = $this->ctrl->getLinkTargetByClass(
182 [
183 ilLMEditorGUI::class,
184 ilObjLearningModuleGUI::class,
185 ilLearningProgressGUI::class,
186 ]
187 );
188 } else {
189 $lp_settings_link = $this->ctrl->getLinkTargetByClass(
190 [
191 ilRepositoryGUI::class,
192 $gui_class,
193 ilLearningProgressGUI::class,
194 ]
195 );
196 }
197
198 $this->ctrl->clearParameterByClass(
199 ilLearningProgressGUI::class,
200 'ref_id'
201 );
202
203 $a_set["mode"] = '<a href="' . $lp_settings_link . '">' . $a_set['mode'] . '</a>'; // :TODO: il_ItemAlertProperty?
204 }
205
206 $mode = $a_set['mode_id'];
208 $this->tpl->setVariable(
209 "COLL_MODE" . $mode_suffix,
210 $a_set['mode']
211 );
212 } else {
213 $this->tpl->setVariable("COLL_MODE" . $mode_suffix, "");
214 $this->tpl->setVariable(
215 "COLL_MODE_DEACTIVATED" . $mode_suffix,
216 $a_set['mode']
217 );
218 }
219 if ($a_set["anonymized"]) {
220 $this->tpl->setVariable(
221 "ANONYMIZED" . $mode_suffix,
222 $this->lng->txt(
223 'trac_anonymized_info_short'
224 )
225 );
226 }
227
228 if ($mode_suffix) {
229 $this->tpl->setVariable(
230 "COLL_MODE_LABEL",
231 $this->lng->txt("trac_mode")
232 );
233 }
234 }
235 } else {
236 $this->tpl->setVariable('COLL_LINK', $a_set['url']);
237
239 // handle tlt settings
240 $this->tpl->setCurrentBlock("tlt");
241 $this->tpl->setVariable(
242 "TXT_MONTH",
243 $this->lng->txt('md_months')
244 );
245 $this->tpl->setVariable("TXT_DAYS", $this->lng->txt('md_days'));
246 $this->tpl->setVariable("TXT_TIME", $this->lng->txt('md_time'));
247 $this->tpl->setVariable("TLT_HINT", '(hh:mm)');
248
249 // seconds to units
250 $mon = floor($a_set["tlt"] / (60 * 60 * 24 * 30));
251 $tlt = $a_set["tlt"] % (60 * 60 * 24 * 30);
252 $day = floor($tlt / (60 * 60 * 24));
253 $tlt = $tlt % (60 * 60 * 24);
254 $hr = floor($tlt / (60 * 60));
255 $tlt = $tlt % (60 * 60);
256 $min = floor($tlt / 60);
257
258 $options = array();
259 for ($i = 0; $i <= 24; $i++) {
260 $options[$i] = sprintf('%02d', $i);
261 }
262 $this->tpl->setVariable(
263 "SEL_MONTHS",
265 $mon,
266 'tlt[' . $a_set['id'] . '][mo]',
267 $options,
268 false,
269 true
270 )
271 );
272
273 for ($i = 0; $i <= 31; $i++) {
274 $options[$i] = sprintf('%02d', $i);
275 }
276 $this->tpl->setVariable(
277 "SEL_DAYS",
279 $day,
280 'tlt[' . $a_set['id'] . '][d]',
281 $options,
282 false,
283 true
284 )
285 );
286
287 $this->tpl->setVariable(
288 "SEL_TLT",
290 'tlt[' . $a_set['id'] . ']',
291 true,
292 (int) $hr,
293 (int) $min,
294 0,
295 false
296 )
297 );
298
299 $this->tpl->parseCurrentBlock();
300 }
301 }
302
303 // Assigned ?
304 $this->tpl->setVariable(
305 "ASSIGNED_IMG_OK",
306 $a_set['status']
307 ? ilUtil::getImagePath('icon_ok.svg')
308 : ilUtil::getImagePath('icon_not_ok.svg')
309 );
310 $this->tpl->setVariable(
311 "ASSIGNED_STATUS",
312 $a_set['status']
313 ? $this->lng->txt('trac_assigned')
314 : $this->lng->txt('trac_not_assigned')
315 );
316 $this->tpl->parseCurrentBlock();
317
318 // Parse grouped items
319 if (isset($a_set['grouped'])) {
320 foreach ((array) $a_set['grouped'] as $item) {
321 $item['group_item'] = true;
322 $this->fillRow($item);
323 }
324 }
325
326 // show num obligatory info
327 if (
328 is_array($a_set) &&
329 array_key_exists('grouped', $a_set) &&
330 count($a_set['grouped'])
331 ) {
332 $this->tpl->setCurrentBlock('num_passed_items');
333 $this->tpl->setVariable(
334 'MIN_PASSED_TXT',
335 $this->lng->txt('trac_min_passed')
336 );
337 $this->tpl->setVariable('NUM_OBLIGATORY', $a_set['num_obligatory']);
338 $this->tpl->setVariable('GRP_ID', $a_set['grouping_id']);
339 $this->tpl->parseCurrentBlock();
340 }
341 }
342
343 protected function initTable(): void
344 {
345 $this->setFormAction(
346 $this->ctrl->getFormAction($this->getParentObject())
347 );
348 switch ($this->getMode()) {
351 $this->setRowTemplate(
352 'tpl.lp_collection_row.html',
353 'Services/Tracking'
354 );
355 $this->setTitle($this->lng->txt('trac_lp_determination'));
356 $this->setDescription(
357 $this->lng->txt('trac_lp_determination_info_crs')
358 );
359 break;
360
362 $this->setRowTemplate(
363 'tpl.lp_collection_row.html',
364 'Services/Tracking'
365 );
366 $this->setTitle($this->lng->txt('trac_lp_determination_tutor'));
367 $this->setDescription(
368 $this->lng->txt('trac_lp_determination_info_crs_tutor')
369 );
370 break;
371
373 $this->setRowTemplate(
374 'tpl.lp_collection_scorm_row.html',
375 'Services/Tracking'
376 );
377 $this->setTitle($this->lng->txt('trac_lp_determination'));
378 $this->setDescription(
379 $this->lng->txt('trac_lp_determination_info_sco')
380 );
381 break;
382
384 $this->setRowTemplate(
385 'tpl.lp_collection_subitem_row.html',
386 'Services/Tracking'
387 );
388 $this->setTitle($this->lng->txt('trac_lp_determination'));
389 $this->setDescription(
390 $this->lng->txt('trac_lp_determination_info_crs')
391 );
392 $this->lng->loadLanguageModule("meta");
393
394 $this->addCommandButton('updateTLT', $this->lng->txt('save'));
395 break;
396
398 $this->setRowTemplate(
399 'tpl.lp_collection_subitem_row.html',
400 'Services/Tracking'
401 );
402 $this->setTitle($this->lng->txt('trac_lp_determination'));
403 $this->setDescription(
404 $this->lng->txt('trac_lp_determination_info_mob')
405 );
406 break;
407 }
408
409 $this->addColumn('', '', '1px');
410 $this->addColumn($this->lng->txt('item'), 'title', '50%');
411
412 if ($this->getMode() != ilLPObjSettings::LP_MODE_SCORM &&
416 $this->addColumn($this->lng->txt('trac_mode'), 'mode');
417 } elseif ($this->getMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) {
418 $this->addColumn(
419 $this->lng->txt('meta_typical_learning_time'),
420 'tlt'
421 );
422 }
423
425 $this->addMultiCommand(
426 'assign',
427 $this->lng->txt('trac_collection_assign')
428 );
429 $this->addMultiCommand(
430 'deassign',
431 $this->lng->txt('trac_collection_deassign')
432 );
433 $this->addColumn(
434 $this->lng->txt('trac_determines_learning_progress'),
435 'status'
436 );
437 } else {
438 $this->addMultiCommand(
439 'assign',
440 $this->lng->txt('trac_manual_display')
441 );
442 $this->addMultiCommand(
443 'deassign',
444 $this->lng->txt('trac_manual_no_display')
445 );
446 $this->addColumn(
447 $this->lng->txt('trac_manual_is_displayed'),
448 'status'
449 );
450 }
451
452 $this->enable('select_all');
453 $this->setSelectAllCheckbox('item_ids');
454
456 $this->addMultiCommand(
457 'groupMaterials',
458 $this->lng->txt('trac_group_materials')
459 );
460 }
461 }
462}
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)
Creates a path for a start and endnode.
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 $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: feed.php:28
$path
Definition: ltiservices.php:32
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc