ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBasicSkillGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use ILIAS\UI;
23use ILIAS\Data;
24use Psr\Http\Message\ServerRequestInterface;
28
36{
37 protected ilCtrl $ctrl;
39 protected ilTabsGUI $tabs;
40 protected ilHelpGUI $help;
42 protected ilLanguage $lng;
43 protected Data\Factory $df;
44 protected ServerRequestInterface $request;
47
48 protected int $tref_id = 0;
49 protected int $requested_level_id = 0;
50 protected int $requested_root_id = 0;
51
55 protected array $requested_level_order = [];
56
60 protected array $requested_level_ids = [];
61
65 protected array $requested_resource_ids = [];
66
70 protected array $requested_suggested = [];
71
75 protected array $requested_trigger = [];
76
77 protected string $requested_table_action = "";
78
82 protected array $requested_table_rep_ref_ids = [];
83
84 public function __construct(Node\SkillTreeNodeManager $node_manager, int $a_node_id = 0)
85 {
86 global $DIC;
87
88 $this->ctrl = $DIC->ctrl();
89 $this->tpl = $DIC["tpl"];
90 $this->tabs = $DIC->tabs();
91 $this->help = $DIC["ilHelp"];
92 $this->toolbar = $DIC->toolbar();
93 $this->lng = $DIC->language();
94 $this->df = new \ILIAS\Data\Factory();
95 $this->request = $DIC->http()->request();
96 $this->query = $DIC->http()->wrapper()->query();
97 $ilCtrl = $DIC->ctrl();
98 $this->resource_manager = $DIC->skills()->internal()->manager()->getResourceManager();
99
100 $ilCtrl->saveParameter($this, array("node_id", "level_id"));
101 $this->base_skill_id = $a_node_id;
102
103 parent::__construct($node_manager, $a_node_id);
104
105 $this->requested_level_id = $this->admin_gui_request->getLevelId();
106 $this->requested_root_id = $this->admin_gui_request->getRootId();
107 $this->requested_level_order = $this->admin_gui_request->getOrder();
108 $this->requested_level_ids = $this->admin_gui_request->getLevelIds();
109 $this->requested_resource_ids = $this->admin_gui_request->getResourceIds();
110 $this->requested_suggested = $this->admin_gui_request->getSuggested();
111 $this->requested_trigger = $this->admin_gui_request->getTrigger();
112 $this->requested_table_action = $this->admin_gui_request->getTableLevelResourcesAction();
113 $this->requested_table_rep_ref_ids = $this->admin_gui_request->getTableRepoRefIds();
114 }
115
116 public function getType(): string
117 {
118 return "skll";
119 }
120
121 public function executeCommand(): void
122 {
123 $ilCtrl = $this->ctrl;
124 $ilTabs = $this->tabs;
126
127 //$tpl->getStandardTemplate();
128
129 $next_class = $ilCtrl->getNextClass($this);
130 $cmd = $ilCtrl->getCmd();
131 switch ($next_class) {
132 default:
133 $ret = $this->$cmd();
134 break;
135 }
136 }
137
138 public function showProperties(): void
139 {
141
142 $this->setTabs();
143
144 $tpl->setContent("Properties");
145 }
146
147 public function saveItem(): void
148 {
149 if (!$this->tree_access_manager->hasManageCompetencesPermission()) {
150 return;
151 }
152
153 $it = new ilBasicSkill();
154 $it->setTitle($this->form->getInput("title"));
155 $it->setDescription($this->form->getInput("description"));
156 $it->setStatus((int) $this->form->getInput("status"));
157 $it->setSelfEvaluation((bool) $this->form->getInput("self_eval"));
158 $it->create();
159 $this->skill_tree_node_manager->putIntoTree($it, $this->requested_node_id, ilTree::POS_LAST_NODE);
160 $this->node_object = $it;
161 }
162
163 public function afterSave(): void
164 {
165 $ilCtrl = $this->ctrl;
166
167 $ilCtrl->setParameterByClass(
168 "ilbasicskillgui",
169 "node_id",
170 $this->node_object->getId()
171 );
172 $ilCtrl->redirectByClass("ilbasicskillgui", "edit");
173 }
174
175 public function updateItem(): void
176 {
177 if (!$this->tree_access_manager->hasManageCompetencesPermission() && $this->getType() == "skll"
178 || !$this->tree_access_manager->hasManageCompetenceTemplatesPermission() && $this->getType() == "sktp") {
179 return;
180 }
181
182 $this->node_object->setTitle($this->form->getInput("title"));
183 $this->node_object->setDescription($this->form->getInput("description"));
184 $this->node_object->setSelfEvaluation((bool) $this->form->getInput("self_eval"));
185 $this->node_object->setStatus((int) $this->form->getInput("status"));
186 $this->node_object->update();
187 }
188
189 public function edit(): void
190 {
192 $ilToolbar = $this->toolbar;
194 $ilCtrl = $this->ctrl;
195
196 $this->setTabs("levels");
197
198 if ($this->isInUse()) {
199 $this->tpl->setOnScreenMessage('info', $lng->txt("skmg_skill_in_use"));
200 } elseif ($this->tree_access_manager->hasManageCompetencesPermission()) {
201 $ilToolbar->addButton(
202 $lng->txt("skmg_add_level"),
203 $ilCtrl->getLinkTarget($this, "addLevel")
204 );
205 }
206
207 $table = new ilSkillLevelTableGUI(
208 $this->base_skill_id,
209 $this,
210 "edit",
211 0,
212 $this->isInUse(),
213 $this->tree_access_manager->hasManageCompetencesPermission()
214 );
215 $tpl->setContent($table->getHTML());
216 }
217
218 public function initForm(string $a_mode = "edit"): void
219 {
221 $ilCtrl = $this->ctrl;
222
223 $this->form = new ilPropertyFormGUI();
224
225 // title
226 $ti = new ilTextInputGUI($lng->txt("title"), "title");
227 $ti->setMaxLength(200);
228 $ti->setSize(50);
229 $ti->setRequired(true);
230 $this->form->addItem($ti);
231
232 // description
233 $ta = new ilTextAreaInputGUI($lng->txt("description"), "description");
234 $ta->setRows(5);
235 $this->form->addItem($ta);
236
237 // status
238 $this->addStatusInput($this->form);
239
240 // selectable
241 $cb = new ilCheckboxInputGUI($lng->txt("skmg_selectable"), "self_eval");
242 $cb->setInfo($lng->txt("skmg_selectable_info"));
243 $this->form->addItem($cb);
244
245 // save and cancel commands
246 if ($this->tree_access_manager->hasManageCompetencesPermission()) {
247 if ($a_mode == "create") {
248 $this->form->addCommandButton("save", $lng->txt("save"));
249 $this->form->addCommandButton("cancelSave", $lng->txt("cancel"));
250 $this->form->setTitle($lng->txt("skmg_create_skll"));
251 } else {
252 $this->form->addCommandButton("update", $lng->txt("save"));
253 $this->form->setTitle($lng->txt("skmg_edit_skll"));
254 }
255 } else {
256 foreach ($this->form->getItems() as $item) {
257 $item->setDisabled(true);
258 }
259 }
260
261 $ilCtrl->setParameter($this, "node_id", $this->requested_node_id);
262 $this->form->setFormAction($ilCtrl->getFormAction($this));
263 }
264
265 public function editProperties(): void
266 {
267 $this->setTabs("properties");
268 parent::editProperties();
269 }
270
271
272 //
273 //
274 // Skill level related methods
275 //
276 //
277
278 public function addLevel(): void
279 {
281
282 $form = $this->initLevelForm("create");
283 $tpl->setContent($this->ui_ren->render([$form]));
284 }
285
286 public function editLevel(): void
287 {
290
291 if (!$this->tree_access_manager->hasManageCompetencesPermission() && $this->getType() == "skll"
292 || !$this->tree_access_manager->hasManageCompetenceTemplatesPermission() && $this->getType() == "sktp") {
293 return;
294 }
295
296 if ($this->isInUse()) {
297 $this->tpl->setOnScreenMessage('info', $lng->txt("skmg_skill_in_use"));
298 }
299
300 $form = $this->initLevelForm();
301 $tpl->setContent($this->ui_ren->render([$form]));
302 }
303
304 public function saveLevel(): void
305 {
308 $ilCtrl = $this->ctrl;
309
310 if (!$this->tree_access_manager->hasManageCompetencesPermission() && $this->getType() == "skll"
311 || !$this->tree_access_manager->hasManageCompetenceTemplatesPermission() && $this->getType() == "sktp") {
312 return;
313 }
314
315 $form = $this->initLevelForm("create");
316 if ($this->request->getMethod() == "POST"
317 && $this->request->getQueryParams()["level_settings"] == "level_settings_config") {
318 $form = $form->withRequest($this->request);
319 $result = $form->getData();
320
321 if (is_null($result)) {
322 $tpl->setContent($this->ui_ren->render($form));
323 return;
324 }
325
326 $this->node_object->addLevel(
327 $result["section_level"]["input_ti"],
328 $result["section_level"]["input_desc"]
329 );
330
331 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
332 $ilCtrl->redirect($this, "edit");
333 }
334
335 $tpl->setContent($this->ui_ren->render([$form]));
336 }
337
338 public function updateLevel(): void
339 {
341 $ilCtrl = $this->ctrl;
343
344 if (!$this->tree_access_manager->hasManageCompetencesPermission() && $this->getType() == "skll"
345 || !$this->tree_access_manager->hasManageCompetenceTemplatesPermission() && $this->getType() == "sktp") {
346 return;
347 }
348
349 $form = $this->initLevelForm("edit");
350 if ($this->request->getMethod() == "POST"
351 && $this->request->getQueryParams()["level_settings"] == "level_settings_config") {
352 $form = $form->withRequest($this->request);
353 $result = $form->getData();
354
355 if (is_null($result)) {
356 $tpl->setContent($this->ui_ren->render($form));
357 return;
358 }
359
360 $this->node_object->writeLevelTitle(
361 $this->requested_level_id,
362 $result["section_level"]["input_ti"]
363 );
364
365 $this->node_object->writeLevelDescription(
366 $this->requested_level_id,
367 $result["section_level"]["input_desc"]
368 );
369
370 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
371 $ilCtrl->redirect($this, "edit");
372 }
373
374 $tpl->setContent($this->ui_ren->render([$form]));
375 }
376
377 public function initLevelForm(string $a_mode = "edit"): Form
378 {
380 $ilCtrl = $this->ctrl;
381 $ilTabs = $this->tabs;
382
383 $ilCtrl->saveParameter($this, "level_id");
384 $this->setLevelHead();
385 $ilTabs->activateTab("level_settings");
386
387 $input_ti = $this->ui_fac->input()->field()->text($lng->txt("title"))
388 ->withRequired(true);
389
390 $input_desc = $this->ui_fac->input()->field()->textarea($lng->txt("description"));
391
392 $ilCtrl->setParameter(
393 $this,
394 'level_settings',
395 'level_settings_config'
396 );
397
398 if ($a_mode == "create") {
399 $section_level = $this->ui_fac->input()->field()->section(
400 ["input_ti" => $input_ti,
401 "input_desc" => $input_desc],
402 $lng->txt("skmg_new_level")
403 );
404 $form_action = $ilCtrl->getFormAction($this, "saveLevel");
405 } else {
406 $data = $this->node_object->getLevelData($this->requested_level_id);
407 $input_ti = $input_ti->withValue($data["title"]);
408 $input_desc = $input_desc->withValue($data["description"]);
409
410 $section_level = $this->ui_fac->input()->field()->section(
411 ["input_ti" => $input_ti,
412 "input_desc" => $input_desc],
413 $lng->txt("skmg_edit_level")
414 );
415 $form_action = $ilCtrl->getFormAction($this, "updateLevel");
416 }
417
418 $form = $this->ui_fac->input()->container()->form()->standard(
419 $form_action,
420 ["section_level" => $section_level]
421 );
422
423 return $form;
424 }
425
426 public function updateLevelOrder(): void
427 {
429 $ilCtrl = $this->ctrl;
430
431 if (!$this->tree_access_manager->hasManageCompetencesPermission() && $this->getType() == "skll"
432 || !$this->tree_access_manager->hasManageCompetenceTemplatesPermission() && $this->getType() == "sktp") {
433 return;
434 }
435
436 $order = ilArrayUtil::stripSlashesArray($this->requested_level_order);
437 $this->node_object->updateLevelOrder($order);
438 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
439 $ilCtrl->redirect($this, "edit");
440 }
441
442 public function confirmLevelDeletion(): void
443 {
444 $ilCtrl = $this->ctrl;
447
448 if (!$this->tree_access_manager->hasManageCompetencesPermission() && $this->getType() == "skll"
449 || !$this->tree_access_manager->hasManageCompetenceTemplatesPermission() && $this->getType() == "sktp") {
450 return;
451 }
452
453 $this->setTabs("levels");
454
455 if (empty($this->requested_level_ids)) {
456 $this->tpl->setOnScreenMessage('info', $lng->txt("no_checkbox"), true);
457 $ilCtrl->redirect($this, "edit");
458 } else {
459 $cgui = new ilConfirmationGUI();
460 $cgui->setFormAction($ilCtrl->getFormAction($this));
461 $cgui->setHeaderText($lng->txt("skmg_really_delete_levels"));
462 $cgui->setCancel($lng->txt("cancel"), "edit");
463 $cgui->setConfirm($lng->txt("delete"), "deleteLevel");
464
465 foreach ($this->requested_level_ids as $i) {
466 $cgui->addItem("id[]", (string) $i, ilBasicSkill::lookupLevelTitle($i));
467 }
468
469 $tpl->setContent($cgui->getHTML());
470 }
471 }
472
473 public function deleteLevel(): void
474 {
476 $ilCtrl = $this->ctrl;
477
478 if (!$this->tree_access_manager->hasManageCompetencesPermission() && $this->getType() == "skll"
479 || !$this->tree_access_manager->hasManageCompetenceTemplatesPermission() && $this->getType() == "sktp") {
480 return;
481 }
482
483 if (!empty($this->requested_level_ids)) {
484 foreach ($this->requested_level_ids as $id) {
485 $this->node_object->deleteLevel($id);
486 }
487 $this->node_object->fixLevelNumbering();
488 }
489 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
490 $ilCtrl->redirect($this, "edit");
491 }
492
493 public function setLevelHead(): void
494 {
495 $ilTabs = $this->tabs;
496 $ilCtrl = $this->ctrl;
499 $ilHelp = $this->help;
500
501 // tabs
502 $ilTabs->clearTargets();
503 $ilHelp->setScreenIdComponent("skmg_lev");
504
505 $ilTabs->setBackTarget(
506 $lng->txt("back"),
507 $ilCtrl->getLinkTarget($this, "edit")
508 );
509
510 if ($this->requested_level_id > 0) {
511 $ilTabs->addTab(
512 "level_settings",
513 $lng->txt("settings"),
514 $ilCtrl->getLinkTarget($this, "editLevel")
515 );
516
517 $ilTabs->addTab(
518 "level_resources",
519 $lng->txt("skmg_resources"),
520 $ilCtrl->getLinkTarget($this, "showLevelResources")
521 );
522 }
523
524 // title
525 if ($this->requested_level_id > 0) {
526 $tpl->setTitle($lng->txt("skmg_skill_level") . ": " .
527 ilBasicSkill::lookupLevelTitle($this->requested_level_id));
528 } else {
529 $tpl->setTitle($lng->txt("skmg_skill_level"));
530 }
531
532 $desc = $this->skill_tree_node_manager->getWrittenPath($this->node_object->getId());
533 $tpl->setDescription($desc);
534 }
535
536 public function setTabs(string $a_tab = "levels"): void
537 {
538 $ilTabs = $this->tabs;
539 $ilCtrl = $this->ctrl;
542 $ilHelp = $this->help;
543
544 $ilTabs->clearTargets();
545 $ilHelp->setScreenIdComponent("skmg_skll");
546 // $ilTabs->setBackTarget($lng->txt("skmg_skill_hierarchie"),
547 // $ilCtrl->getLinkTargetByClass("ilobjskillmanagementgui", "editSkills"));
548
549 if (is_object($this->node_object)) {
550 // levels
551 $ilTabs->addTab(
552 "levels",
553 $lng->txt("skmg_skill_levels"),
554 $ilCtrl->getLinkTarget($this, 'edit')
555 );
556
557 // properties
558 $ilTabs->addTab(
559 "properties",
560 $lng->txt("settings"),
561 $ilCtrl->getLinkTarget($this, 'editProperties')
562 );
563
564 // usage
565 $this->addUsageTab($ilTabs);
566
567 // assigned objects
568 $this->addObjectsTab($ilTabs);
569
570 $parent_node_id = $this->tree_repo->getParentNodeIdForNodeId($this->requested_node_id);
571 $parent_title = ilSkillTreeNode::_lookupTitle($parent_node_id);
572 $parent_type = ilSkillTreeNode::_lookupType($parent_node_id);
573
574 if ($parent_type === "scat") {
575 $ilCtrl->setParameterByClass(
576 "ilskillcategorygui",
577 "node_id",
578 $parent_node_id
579 );
580 $ilTabs->setBackTarget(
581 $parent_title,
582 $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "listItems")
583 );
584 $ilCtrl->setParameterByClass(
585 "ilskillcategorygui",
586 "node_id",
587 ""
588 );
589 } else {
590 $ilCtrl->setParameterByClass(
591 "ilskillrootgui",
592 "node_id",
593 $this->skill_tree_node_manager->getRootId()
594 );
595 $ilTabs->setBackTarget(
596 $lng->txt("skmg_skills"),
597 $ilCtrl->getLinkTargetByClass("ilskillrootgui", "listSkills")
598 );
599 $ilCtrl->setParameterByClass(
600 "ilskillrootgui",
601 "node_id",
602 $this->requested_node_id
603 );
604 }
605
606 $ilTabs->activateTab($a_tab);
607
608 $tpl->setTitle($lng->txt("skmg_skill") . ": " .
609 $this->node_object->getTitle());
610
612 } else {
613 $tpl->setTitle($lng->txt("skmg_skill"));
614 $tpl->setDescription("");
615 }
616 parent::setTitleIcon();
617 }
618
622 public function redirectToParent(bool $a_tmp_mode = false): void
623 {
624 $ilCtrl = $this->ctrl;
625
626 $t = ilSkillTreeNode::_lookupType($this->requested_node_id);
627
628 switch ($t) {
629 case "skrt":
630 $ilCtrl->setParameterByClass("ilskillrootgui", "node_id", $this->requested_node_id);
631 $ilCtrl->redirectByClass("ilskillrootgui", "listSkills");
632 break;
633 }
634
635 parent::redirectToParent();
636 }
637
638
642
643 public function showLevelResources(): void
644 {
646 $ilTabs = $this->tabs;
647 $ilToolbar = $this->toolbar;
649 $ilCtrl = $this->ctrl;
650
651 if ($this->tree_access_manager->hasManageCompetencesPermission() && $this->getType() == "skll"
652 || $this->tree_access_manager->hasManageCompetenceTemplatesPermission() && $this->getType() == "sktp") {
653 $ilToolbar->addButton(
654 $lng->txt("skmg_add_resource"),
655 $ilCtrl->getLinkTarget($this, "addLevelResource")
656 );
657 } else {
658 return;
659 }
660
661 $this->setLevelHead();
662 $ilTabs->activateTab("level_resources");
663
664 $table = $this->table_manager->getLevelResourcesTable(
665 $this->requested_ref_id,
666 $this->base_skill_id,
667 $this->tref_id,
668 $this->requested_level_id
669 )->getComponent();
670
671 $tpl->setContent($this->ui_ren->render($table));
672 }
673
674 public function addLevelResource(): void
675 {
676 $ilTabs = $this->tabs;
678
679 $this->setLevelHead();
680 $ilTabs->activateTab("level_resources");
681
683 $this,
684 "addLevelResource",
685 $this,
686 "saveLevelResource",
687 "root_id",
688 "",
689 "rep_node_id"
690 );
691 if (!$exp->handleCommand()) {
692 $tpl->setContent($exp->getHTML());
693 }
694 }
695
696 public function saveLevelResource(): void
697 {
698 $ilCtrl = $this->ctrl;
700
702 if (!$this->tree_access_manager->hasManageCompetencesPermission() && $this->getType() == "skll"
703 || !$this->tree_access_manager->hasManageCompetenceTemplatesPermission() && $this->getType() == "sktp") {
704 return;
705 }
706
707 if ($ref_id > 0) {
708 $this->resource_manager->setResource(
709 $this->base_skill_id,
710 $this->tref_id,
711 $this->requested_level_id,
712 $ref_id,
713 true,
714 false
715 );
716
717 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
718 }
719
720 $ilCtrl->redirect($this, "showLevelResources");
721 }
722
723 public function removeLevelResources(): void
724 {
725 $ilCtrl = $this->ctrl;
727
728 if (!$this->tree_access_manager->hasManageCompetencesPermission() && $this->getType() == "skll"
729 || !$this->tree_access_manager->hasManageCompetenceTemplatesPermission() && $this->getType() == "sktp") {
730 return;
731 }
732
733 if (!empty($this->requested_resource_ids)) {
734 foreach ($this->requested_resource_ids as $i) {
735 $this->resource_manager->removeResource(
736 $this->base_skill_id,
737 $this->tref_id,
738 $this->requested_level_id,
739 $i
740 );
741 }
742 $this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
743 }
744
745 $ilCtrl->redirect($this, "showLevelResources");
746 }
747
748 public function saveResourcesAsSuggested(): void
749 {
750 $ilCtrl = $this->ctrl;
753
754 if ($this->requested_table_action == "setSuggested"
755 && !empty($this->requested_table_rep_ref_ids)
756 && $this->requested_table_rep_ref_ids[0] === "ALL_OBJECTS"
757 ) {
758 $resources = $this->resource_manager->getResourcesOfLevel(
759 $this->base_skill_id,
760 $this->tref_id,
761 $this->requested_level_id
762 );
763 foreach ($resources as $resource) {
764 $this->resource_manager->setResourceAsSuggested(
765 $resource->getBaseSkillId(),
766 $resource->getTrefId(),
767 $resource->getLevelId(),
768 $resource->getRepoRefId()
769 );
770 }
771 } elseif ($this->requested_table_action == "setSuggested") {
772 if (empty($this->requested_table_rep_ref_ids)) {
773 $tpl->setOnScreenMessage("info", $lng->txt("no_checkbox"), true);
774 $ilCtrl->redirect($this, "showLevelResources");
775 } else {
776 foreach ($this->requested_table_rep_ref_ids as $i) {
777 $this->resource_manager->setResourceAsSuggested(
778 $this->base_skill_id,
779 $this->tref_id,
780 $this->requested_level_id,
781 (int) $i
782 );
783 }
784 }
785 }
786
787 $tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
788 $ilCtrl->redirect($this, "showLevelResources");
789 }
790
791 public function saveResourcesAsNotSuggested(): void
792 {
793 $ilCtrl = $this->ctrl;
796
797 if ($this->requested_table_action == "unsetSuggested"
798 && !empty($this->requested_table_rep_ref_ids)
799 && $this->requested_table_rep_ref_ids[0] === "ALL_OBJECTS"
800 ) {
801 $resources = $this->resource_manager->getResourcesOfLevel(
802 $this->base_skill_id,
803 $this->tref_id,
804 $this->requested_level_id
805 );
806 foreach ($resources as $resource) {
807 $this->resource_manager->setResourceAsNotSuggested(
808 $resource->getBaseSkillId(),
809 $resource->getTrefId(),
810 $resource->getLevelId(),
811 $resource->getRepoRefId()
812 );
813 }
814 } elseif ($this->requested_table_action == "unsetSuggested") {
815 if (empty($this->requested_table_rep_ref_ids)) {
816 $tpl->setOnScreenMessage("info", $lng->txt("no_checkbox"), true);
817 $ilCtrl->redirect($this, "showLevelResources");
818 } else {
819 foreach ($this->requested_table_rep_ref_ids as $i) {
820 $this->resource_manager->setResourceAsNotSuggested(
821 $this->base_skill_id,
822 $this->tref_id,
823 $this->requested_level_id,
824 (int) $i
825 );
826 }
827 }
828 }
829
830 $tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
831 $ilCtrl->redirect($this, "showLevelResources");
832 }
833
834 public function saveResourcesAsTrigger(): void
835 {
836 $ilCtrl = $this->ctrl;
839
840 if ($this->requested_table_action == "setTrigger"
841 && !empty($this->requested_table_rep_ref_ids)
842 && $this->requested_table_rep_ref_ids[0] === "ALL_OBJECTS"
843 ) {
844 $resources = $this->resource_manager->getResourcesOfLevel(
845 $this->base_skill_id,
846 $this->tref_id,
847 $this->requested_level_id
848 );
849 foreach ($resources as $resource) {
850 $this->resource_manager->setResourceAsTrigger(
851 $resource->getBaseSkillId(),
852 $resource->getTrefId(),
853 $resource->getLevelId(),
854 $resource->getRepoRefId()
855 );
856 }
857 } elseif ($this->requested_table_action == "setTrigger") {
858 if (empty($this->requested_table_rep_ref_ids)) {
859 $tpl->setOnScreenMessage("info", $lng->txt("no_checkbox"), true);
860 $ilCtrl->redirect($this, "showLevelResources");
861 } else {
862 foreach ($this->requested_table_rep_ref_ids as $i) {
863 $this->resource_manager->setResourceAsTrigger(
864 $this->base_skill_id,
865 $this->tref_id,
866 $this->requested_level_id,
867 (int) $i
868 );
869 }
870 }
871 }
872
873 $tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
874 $ilCtrl->redirect($this, "showLevelResources");
875 }
876
877 public function saveResourcesAsNoTrigger(): void
878 {
879 $ilCtrl = $this->ctrl;
882
883 if ($this->requested_table_action == "unsetTrigger"
884 && !empty($this->requested_table_rep_ref_ids)
885 && $this->requested_table_rep_ref_ids[0] === "ALL_OBJECTS"
886 ) {
887 $resources = $this->resource_manager->getResourcesOfLevel(
888 $this->base_skill_id,
889 $this->tref_id,
890 $this->requested_level_id
891 );
892 foreach ($resources as $resource) {
893 $this->resource_manager->setResourceAsNoTrigger(
894 $resource->getBaseSkillId(),
895 $resource->getTrefId(),
896 $resource->getLevelId(),
897 $resource->getRepoRefId()
898 );
899 }
900 } elseif ($this->requested_table_action == "unsetTrigger") {
901 if (empty($this->requested_table_rep_ref_ids)) {
902 $tpl->setOnScreenMessage("info", $lng->txt("no_checkbox"), true);
903 $ilCtrl->redirect($this, "showLevelResources");
904 } else {
905 foreach ($this->requested_table_rep_ref_ids as $i) {
906 $this->resource_manager->setResourceAsNoTrigger(
907 $this->base_skill_id,
908 $this->tref_id,
909 $this->requested_level_id,
910 (int) $i
911 );
912 }
913 }
914 }
915
916 $tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
917 $ilCtrl->redirect($this, "showLevelResources");
918 }
919}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static stripSlashesArray(array $a_arr, bool $a_strip_html=true, string $a_allow="")
Basic skill GUI class.
setTabs(string $a_tab="levels")
Resource SkillResourcesManager $resource_manager
initForm(string $a_mode="edit")
ServerRequestInterface $request
redirectToParent(bool $a_tmp_mode=false)
Redirect to parent (identified by current node_id)
ilGlobalTemplateInterface $tpl
initLevelForm(string $a_mode="edit")
__construct(Node\SkillTreeNodeManager $node_manager, int $a_node_id=0)
ArrayBasedRequestWrapper $query
static lookupLevelTitle(int $a_id)
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...
Class ilCtrl provides processing control methods.
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
Help GUI class.
setScreenIdComponent(string $a_comp)
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This class represents a property form user interface.
Explorer for selecting repository items.
Basic GUI class for skill tree nodes.
addUsageTab(ilTabsGUI $a_tabs)
addObjectsTab(ilTabsGUI $a_tabs)
addStatusInput(ilPropertyFormGUI $a_form)
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
static _lookupType(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const POS_LAST_NODE
setDescription(string $a_descr)
Sets description below title in standard template.
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setContent(string $a_html)
Sets content for standard template.
This describes commonalities between all forms.
Definition: Form.php:33
$ref_id
Definition: ltiauth.php:66
$resources
Definition: ltiservices.php:68
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd, string $submit_caption="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26