Skip to content

Commit

Permalink
41593: UI Data Table not suitable for assigning Competence Targets in…
Browse files Browse the repository at this point in the history
… Competence Management
  • Loading branch information
tfamula committed Jun 24, 2024
1 parent b1f8a01 commit 677ff13
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 225 deletions.
68 changes: 39 additions & 29 deletions Services/Skill/Profile/class.ilSkillProfileGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,7 @@ class ilSkillProfileGUI
* @var string[]
*/
protected array $requested_table_profile_ids = [];
protected string $requested_table_profile_level_assignment_action = "";

/**
* @var string[]
*/
protected array $requested_table_profile_level_assignment_ids = [];
protected int $requested_level_id = 0;
protected bool $local_context = false;

public function __construct(SkillTreeAccess $skill_tree_access_manager, int $skill_tree_id = 0)
Expand Down Expand Up @@ -145,8 +140,7 @@ public function __construct(SkillTreeAccess $skill_tree_access_manager, int $ski
$this->requested_user_ids = $this->admin_gui_request->getUserIds();
$this->requested_table_profile_action = $this->admin_gui_request->getTableProfileAction();
$this->requested_table_profile_ids = $this->admin_gui_request->getTableProfileIds();
$this->requested_table_profile_level_assignment_action = $this->admin_gui_request->getTableProfileLevelAssignmentAction();
$this->requested_table_profile_level_assignment_ids = $this->admin_gui_request->getTableProfileLevelAssignmentIds();
$this->requested_level_id = $this->admin_gui_request->getLevelId();

if ($this->requested_sprof_id > 0) {
$this->id = $this->requested_sprof_id;
Expand Down Expand Up @@ -663,9 +657,31 @@ public function assignLevelSelectSkill(bool $update = false): void
);
}

$table = $this->table_manager->getProfileLevelAssignmentTable($this->requested_cskill_id, $update)
->getComponent();
$tpl->setContent($this->ui_ren->render($table));
$id_parts = explode(":", $this->requested_cskill_id);
$skill_id = (int) $id_parts[0];
$skill = new ilBasicSkill($skill_id);
$level_data = $skill->getLevelData();

$items = [];
foreach ($level_data as $levels) {
$ilCtrl->setParameterByClass(self::class, "level_id", $levels["id"]);
$items[] = $this->ui_fac->item()->standard($levels["title"])->withMainAction(
$this->ui_fac->link()->standard(
$lng->txt("skmg_assign_level"),
$ilCtrl->getLinkTarget($this, $update ? "updateLevelOfProfile" : "assignLevelToProfile")
)
);
$ilCtrl->clearParameterByClass(self::class, "level_id");
}

$list = $this->ui_fac->panel()->listing()->standard(
$skill->getTitle() . ", " . $lng->txt("skmg_skill_levels"),
[
$this->ui_fac->item()->group("", $items)
]
);

$tpl->setContent($this->ui_ren->render($list));
}

public function updateLevelOfSelectedSkill(): void
Expand All @@ -685,15 +701,13 @@ public function assignLevelToProfile(Profile\SkillProfileLevel $level = null): v

if ($level) {
$this->profile_manager->updateSkillLevel($level);
} elseif ($this->requested_table_profile_level_assignment_action === "assignLevel"
&& !empty($this->requested_table_profile_level_assignment_ids)
) {
} else {
$parts = explode(":", $this->requested_cskill_id);
$level = $this->skill_factory->profile()->profileLevel(
$this->profile->getId(),
(int) $parts[0],
(int) $parts[1],
(int) $this->requested_table_profile_level_assignment_ids[0],
$this->requested_level_id,
$this->profile_manager->getMaxLevelOrderNr($this->profile->getId()) + 10
);
$this->profile_manager->addSkillLevel($level);
Expand All @@ -711,20 +725,16 @@ public function assignLevelToProfile(Profile\SkillProfileLevel $level = null): v

public function updateLevelOfProfile(): void
{
if ($this->requested_table_profile_level_assignment_action === "assignLevel"
&& !empty($this->requested_table_profile_level_assignment_ids)
) {
$parts = explode(":", $this->requested_cskill_id);
$level = $this->profile_manager->getSkillLevel($this->profile->getId(), (int) $parts[0], (int) $parts[1]);
$level_updated = $this->skill_factory->profile()->profileLevel(
$level->getProfileId(),
$level->getBaseSkillId(),
$level->getTrefId(),
(int) $this->requested_table_profile_level_assignment_ids[0],
$level->getOrderNr()
);
$this->assignLevelToProfile($level_updated);
}
$parts = explode(":", $this->requested_cskill_id);
$level = $this->profile_manager->getSkillLevel($this->profile->getId(), (int) $parts[0], (int) $parts[1]);
$level_updated = $this->skill_factory->profile()->profileLevel(
$level->getProfileId(),
$level->getBaseSkillId(),
$level->getTrefId(),
$this->requested_level_id,
$level->getOrderNr()
);
$this->assignLevelToProfile($level_updated);
}

public function confirmLevelAssignmentRemoval(): void
Expand Down
13 changes: 0 additions & 13 deletions Services/Skill/Service/classes/class.SkillAdminGUIRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,6 @@ public function getTableProfileIds(): array
return $this->getTableIds("skl_profile_table_profile_ids");
}

public function getTableProfileLevelAssignmentAction(): string
{
return $this->getTableAction("skl_profile_level_assignment_table_action");
}

/**
* @return string[]
*/
public function getTableProfileLevelAssignmentIds(): array
{
return $this->getTableIds("skl_profile_level_assignment_table_level_ids");
}

public function getTableProfileUserAssignmentAction(): string
{
return $this->getTableAction("skl_profile_user_assignment_table_action");
Expand Down
176 changes: 0 additions & 176 deletions Services/Skill/Table/classes/class.ProfileLevelAssignmentTable.php

This file was deleted.

7 changes: 0 additions & 7 deletions Services/Skill/Table/classes/class.TableManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ public function getProfileTable(
return new ProfileTable($ref_id, $skill_tree_id);
}

public function getProfileLevelAssignmentTable(
string $cskill_id,
bool $update = false
): ProfileLevelAssignmentTable {
return new ProfileLevelAssignmentTable($cskill_id, $update);
}

public function getProfileUserAssignmentTable(
Profile\SkillProfile $profile,
Access\SkillTreeAccess $tree_access_manager
Expand Down

0 comments on commit 677ff13

Please sign in to comment.