ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSkillProfileLevelsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
26 
33 {
34  protected Profile\SkillProfile $profile;
38  protected int $requested_ref_id = 0;
39 
40  public function __construct(
41  $a_parent_obj,
42  string $a_parent_cmd,
43  Profile\SkillProfile $a_profile
44  ) {
45  global $DIC;
46 
47  $this->skill_manager = $DIC->skills()->internal()->manager();
48  $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
49  $this->admin_gui_request = $DIC->skills()->internal()->gui()->admin_request();
50 
51  $this->profile = $a_profile;
52  $this->requested_ref_id = $this->admin_gui_request->getRefId();
53  parent::__construct($a_parent_obj, $a_parent_cmd);
54 
55  // convert skill levels to array structure, because tables can only handle arrays
56  $levels = $this->skill_manager->getProfileManager()->getSkillLevels($this->profile->getId());
57  $levels_array = [];
58  foreach ($levels as $level) {
59  $levels_array[] = [
60  "profile_id" => $level->getProfileId(),
61  "base_skill_id" => $level->getBaseSkillId(),
62  "tref_id" => $level->getTrefId(),
63  "level_id" => $level->getLevelId(),
64  "order_nr" => $level->getOrderNr()
65  ];
66  }
67 
68  $this->setData($levels_array);
69  $this->setTitle($this->lng->txt("skmg_target_levels"));
70 
71  $access_manager = $this->skill_manager->getTreeAccessManager($this->requested_ref_id);
72  if ($access_manager->hasManageProfilesPermission()) {
73  $this->addColumn("", "", "1", true);
74  $this->addColumn($this->lng->txt("skmg_order"), "", "1px");
75  }
76  $this->addColumn($this->lng->txt("skmg_skill"));
77  $this->addColumn($this->lng->txt("skmg_level"));
78  if ($access_manager->hasManageProfilesPermission()) {
79  $this->addColumn($this->lng->txt("actions"));
80  }
81 
82  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
83  $this->setRowTemplate("tpl.skill_profile_level_row.html", "Services/Skill");
84 
85  if ($access_manager->hasManageProfilesPermission()) {
86  $this->addMultiCommand("confirmLevelAssignmentRemoval", $this->lng->txt("skmg_remove_levels"));
87  if (count($this->skill_manager->getProfileManager()->getSkillLevels($this->profile->getId())) > 0) {
88  $this->addCommandButton("saveLevelOrder", $this->lng->txt("skmg_save_order"));
89  }
90  }
91  }
92 
93  protected function fillRow(array $a_set): void
94  {
95  $tree_id = $this->tree_repo->getTreeIdForNodeId($a_set["base_skill_id"]);
96  $node_manager = $this->skill_manager->getTreeNodeManager($tree_id);
97  $this->tpl->setVariable(
98  "SKILL_TITLE",
99  $node_manager->getWrittenPath(
100  $a_set["base_skill_id"],
101  $a_set["tref_id"]
102  )
103  );
104 
105  $this->tpl->setVariable("LEVEL_TITLE", ilBasicSkill::lookupLevelTitle($a_set["level_id"]));
106 
107  $access_manager = $this->skill_manager->getTreeAccessManager($this->requested_ref_id);
108  if ($access_manager->hasManageProfilesPermission()) {
109  $this->tpl->setCurrentBlock("checkbox");
110  $this->tpl->setVariable(
111  "ID",
112  ($a_set["base_skill_id"]) . ":" . ($a_set["tref_id"]) . ":" . ($a_set["level_id"]) .
113  ":" . ($a_set["order_nr"])
114  );
115  $this->tpl->setVariable("SKILL_ID", $a_set["base_skill_id"]);
116  $this->tpl->setVariable("TREF_ID", $a_set["tref_id"]);
117  $this->tpl->parseCurrentBlock();
118 
119  $this->tpl->setCurrentBlock("order");
120  $this->tpl->setVariable("ORDER_NR", $a_set["order_nr"]);
121  $this->tpl->parseCurrentBlock();
122 
123  $this->tpl->setCurrentBlock("cmd");
124  $this->tpl->setVariable("CMD", $this->lng->txt("edit"));
125  $this->ctrl->setParameter($this->parent_obj, "cskill_id", $a_set["base_skill_id"] . ":" . $a_set["tref_id"]);
126  $this->tpl->setVariable("CMD_HREF", $this->ctrl->getLinkTarget($this->parent_obj, "updateLevelOfSelectedSkill"));
127  $this->tpl->parseCurrentBlock();
128  }
129  }
130 }
TableGUI class for skill profile levels.
setData(array $a_data)
setFormAction(string $a_form_action, bool $a_multipart=false)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
Request wrapper for guis in skill administration.
static lookupLevelTitle(int $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
__construct( $a_parent_obj, string $a_parent_cmd, Profile\SkillProfile $a_profile)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
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)
addMultiCommand(string $a_cmd, string $a_text)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...