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