19 declare(strict_types=1);
35 protected \ilLanguage
$lng;
41 protected Data\Factory
$df;
49 public function __construct(
int $top_skill_id,
int $tref_id,
int $basic_skill_id)
53 $this->
ctrl = $DIC->ctrl();
54 $this->
lng = $DIC->language();
55 $this->
user = $DIC->user();
56 $this->ui_fac = $DIC->ui()->factory();
57 $this->request = $DIC->http()->request();
58 $this->df =
new Data\Factory();
59 $this->ws_tree = new \ilWorkspaceTree($this->
user->getId());
60 if (!$this->ws_tree->readRootId()) {
61 $this->ws_tree->createTreeForUser($this->
user->getId());
63 $this->ws_access = new \ilWorkspaceAccessHandler();
69 $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
70 $tree_id = $this->tree_repo->getTreeIdForNodeId($this->basic_skill_id);
71 $this->node_manager = $DIC->skills()->internal()->manager()->getTreeNodeManager($tree_id);
72 $this->assigned_material_manager = $DIC->skills()->internal()->manager()->getAssignedMaterialManager();
81 $title = $this->node_manager->getWrittenPath($this->basic_skill_id);
82 $table = $this->ui_fac->table()
83 ->data($data_retrieval, $title, $columns)
86 $this->top_skill_id .
"_" .
87 $this->tref_id .
"_" .
90 ->withActions($actions)
91 ->withRequest($this->request);
99 "title" => $this->ui_fac->table()->column()->text($this->
lng->txt(
"skmg_skill_level"))
100 ->withIsSortable(
false),
101 "description" => $this->ui_fac->table()->column()->text($this->
lng->txt(
"description"))
102 ->withIsSortable(
false),
103 "resources" => $this->ui_fac->table()->column()->linkListing($this->
lng->txt(
"skmg_materials"))
104 ->withIsSortable(
false)
112 $query_params_namespace = [
"skl_assign_materials_table"];
114 $uri_assign = $this->df->uri(
115 ILIAS_HTTP_PATH .
"/" . $this->
ctrl->getLinkTargetByClass(
116 "ilpersonalskillsgui",
120 $url_builder_assign =
new UI\URLBuilder($uri_assign);
121 list($url_builder_assign, $action_parameter_token_assign, $row_id_token_assign) =
122 $url_builder_assign->acquireParameters(
123 $query_params_namespace,
129 "assign" => $this->ui_fac->table()->action()->single(
130 $this->
lng->txt(
"skmg_assign_materials"),
131 $url_builder_assign->withParameter($action_parameter_token_assign,
"assignMaterials"),
136 foreach ($this->assigned_material_manager->getAllAssignedMaterialsForSkill(
137 $this->user->getId(),
141 $obj_id = $this->ws_tree->lookupObjectId($material->getWorkspaceId());
143 $uri_remove = $this->df->uri(
144 ILIAS_HTTP_PATH .
"/" . $this->
ctrl->getLinkTargetByClass(
145 "ilpersonalskillsgui",
149 $url_builder_remove =
new UI\URLBuilder($uri_remove);
150 list($url_builder_remove, $action_parameter_token_remove, $row_id_token_remove, $wsp_token_remove) =
151 $url_builder_remove->acquireParameters(
152 $query_params_namespace,
157 $url_builder_remove = $url_builder_remove->withParameter($wsp_token_remove, (
string) $material->getWorkspaceId());
159 $actions[
"remove_" . $material->getLevelId() .
"_" . $material->getWorkspaceId()] =
160 $this->ui_fac->table()->action()->single(
162 $url_builder_remove->withParameter($action_parameter_token_remove,
"removeMaterial"),
172 $data_retrieval =
new class (
184 protected int $basic_skill_id,
185 protected int $tref_id,
188 protected Personal\AssignedMaterialManager $assigned_material_manager,
194 public function getRows(
196 array $visible_column_ids,
200 ?array $additional_parameters
202 $records = $this->getRecords($range);
203 foreach ($records as $idx => $record) {
204 $row_id = $record[
"id"];
205 $res_ids = $record[
"res_ids"];
207 $data_row = $row_builder->buildDataRow((
string) $row_id, $record);
208 foreach ($this->assigned_material_manager->getAllAssignedMaterialsForSkill(
209 $this->user->getId(),
213 if (!in_array($material->getWorkspaceId(), $res_ids) || $row_id != $material->getLevelId()) {
214 $data_row = $data_row->withDisabledAction(
215 "remove_" . $material->getLevelId() .
"_" . $material->getWorkspaceId()
224 public function getTotalRowCount(
226 ?array $additional_parameters
228 return count($this->getRecords());
231 protected function getRecords(?
Data\
Range $range =
null): array
236 foreach ($skill->getLevelData() as $level) {
237 $records[$i][
"id"] = $level[
"id"];
238 $records[$i][
"title"] = $level[
"title"];
239 $records[$i][
"description"] = $level[
"description"];
241 $materials = $this->assigned_material_manager->getAssignedMaterials(
242 $this->user->getId(),
248 foreach ($materials as $m) {
249 $wsp_ids[] = $m->getWorkspaceId();
250 $obj_id = $this->ws_tree->lookupObjectId($m->getWorkspaceId());
251 $obj_links[] = $this->ui_fac->link()->standard(
253 $this->ws_access->getGotoLink($m->getWorkspaceId(), $obj_id)
256 $records[$i][
"res_ids"] = $wsp_ids;
257 $records[$i][
"resources"] = $this->ui_fac->listing()->unordered($obj_links);
263 $records = $this->limitRecords($records, $range);
270 return $data_retrieval;
__construct(int $top_skill_id, int $tref_id, int $basic_skill_id)
Node SkillTreeNodeManager $node_manager
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilWorkspaceAccessHandler $ws_access
static getInstance(int $a_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Both the subject and the direction need to be specified when expressing an order. ...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilSkillTreeRepository $tree_repo
static _lookupTitle(int $obj_id)
This is how the factory for UI elements looks.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Personal AssignedMaterialManager $assigned_material_manager
A simple class to express a naive range of whole positive numbers.
ServerRequestInterface $request