ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilSkillAssignMaterialsTableGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 protected ilObjUser $user;
30 protected int $top_skill_id = 0;
31 protected int $tref_id = 0;
32 protected int $basic_skill_id = 0;
34 protected \ILIAS\UI\Factory $ui_fac;
35 protected \ILIAS\UI\Renderer $ui_ren;
36
37 public function __construct(
38 $a_parent_obj,
39 string $a_parent_cmd,
40 int $a_top_skill_id,
41 int $a_tref_id,
42 int $a_basic_skill_id
43 ) {
44 global $DIC;
45
46 $this->user = $DIC->user();
47 $this->lng = $DIC->language();
48 $this->ctrl = $DIC->ctrl();
49 $ilUser = $DIC->user();
50 $this->ui_fac = $DIC->ui()->factory();
51 $this->ui_ren = $DIC->ui()->renderer();
52
53 $this->ws_tree = new ilWorkspaceTree($ilUser->getId());
54 if (!$this->ws_tree->readRootId()) {
55 $this->ws_tree->createTreeForUser($ilUser->getId());
56 }
57 $this->ws_access = new ilWorkspaceAccessHandler();
58
59 $this->top_skill_id = $a_top_skill_id;
60 $this->tref_id = $a_tref_id;
61 $this->basic_skill_id = $a_basic_skill_id;
62
63
64 // build title
65 $tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
66 $tree_id = $tree_repo->getTreeIdForNodeId($this->basic_skill_id);
67 $node_manager = $DIC->skills()->internal()->manager()->getTreeNodeManager($tree_id);
68 $title = $node_manager->getWrittenPath($this->basic_skill_id);
69
70 parent::__construct($a_parent_obj, $a_parent_cmd);
71 $this->setData($this->getLevels());
72 $this->setTitle($title);
73 $this->setLimit(9999);
74
75 $this->addColumn($this->lng->txt("skmg_skill_level"));
76 $this->addColumn($this->lng->txt("description"));
77 $this->addColumn($this->lng->txt("skmg_materials"));
78 $this->addColumn($this->lng->txt("actions"));
79
80 $this->setEnableHeader(true);
81 // $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
82 $this->setRowTemplate("tpl.skill_materials_row.html", "Services/Skill");
83 $this->disable("footer");
84 $this->setEnableTitle(true);
85
86 // $this->addMultiCommand("", $lng->txt(""));
87// $this->addCommandButton("", $lng->txt(""));
88 }
89
90 public function getLevels(): array
91 {
92 $this->skill = ilSkillTreeNodeFactory::getInstance($this->basic_skill_id);
93 $levels = [];
94 foreach ($this->skill->getLevelData() as $k => $v) {
95 $levels[] = $v;
96 }
97
98 return $levels;
99 }
100
101 protected function fillRow(array $a_set): void
102 {
104 $ilCtrl = $this->ctrl;
106
107 $mat = ilPersonalSkill::getAssignedMaterial($ilUser->getId(), $this->tref_id, $a_set["id"]);
108 $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
109 foreach ($mat as $m) {
110 $this->tpl->setCurrentBlock("mat");
111 $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
112 $obj_type = ilObject::_lookupType($obj_id);
113 $mat_icon = $this->ui_fac->symbol()->icon()->standard(
114 $obj_type,
115 $this->lng->txt("icon") . " " . $this->lng->txt($obj_type),
116 "medium"
117 );
118 $this->tpl->setVariable(
119 "MAT_TITLE",
121 );
122 $this->tpl->setVariable("MAT_IMG", $this->ui_ren->render($mat_icon));
123 $this->tpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
124 $ilCtrl->setParameter($this->parent_obj, "wsp_id", $m["wsp_id"]);
125 $this->tpl->setVariable("HREF_REMOVE", $ilCtrl->getLinkTarget($this->parent_obj, "removeMaterial"));
126
127 $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
128 $url = $this->ws_access->getGotoLink($m["wsp_id"], $obj_id);
129 $this->tpl->setVariable("HREF_MAT", $url);
130 $this->tpl->parseCurrentBlock();
131 }
132
133 $this->tpl->setCurrentBlock("cmd");
134 $this->tpl->setVariable("HREF_CMD", $ilCtrl->getLinkTarget(
135 $this->parent_obj,
136 "assignMaterial"
137 ));
138 $this->tpl->setVariable("TXT_CMD", $lng->txt("skmg_assign_materials"));
139 $this->tpl->parseCurrentBlock();
140 $ilCtrl->setParameter($this->parent_obj, "level_id", "");
141
142 $this->tpl->setVariable("LEVEL_ID", $a_set["id"]);
143 $this->tpl->setVariable("SKILL_ID", $this->basic_skill_id);
144 $this->tpl->setVariable("TXT_SKILL", $a_set["title"]);
145 $this->tpl->setVariable("TXT_SKILL_DESC", $a_set["description"]);
146 }
147}
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...
User class.
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
static getAssignedMaterial(int $a_user_id, int $a_tref_id, int $a_level)
Get assigned material (for a skill level and user)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillRow(array $a_set)
Standard Version of Fill Row.
__construct( $a_parent_obj, string $a_parent_cmd, int $a_top_skill_id, int $a_tref_id, int $a_basic_skill_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setEnableTitle(bool $a_enabletitle)
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)
setEnableHeader(bool $a_enableheader)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
ilLanguage $lng
disable(string $a_module_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url