Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modules/Test/classes/class.ilTestPersonalSkillsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getHTML() : string

$gui->setProfileId($this->getSelectedSkillProfile());

$html = $gui->getGapAnalysisHTML($this->getUsrId(), $this->getAvailableSkills());
$html = $gui->getGapAnalysisHTML((int) $this->getUsrId(), $this->getAvailableSkills());

return $html;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use ILIAS\GlobalScreen\Scope\Tool\Provider\AbstractDynamicToolProvider;
use ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts;
use ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection;
use ILIAS\UI\Component\Legacy\Legacy;

/**
* Workspace GS tool provider
Expand Down Expand Up @@ -57,21 +58,14 @@ public function getToolsForContextStack(CalledContexts $called_contexts) : array

$icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("outlined/icon_skmg.svg"), $title);


$additional_data = $called_contexts->current()->getAdditionalData();
if ($additional_data->is(self::SHOW_SKILL_TREE, true)) {
$tree_id = $additional_data->get(self::SKILL_TREE_ID);
$iff = function ($id) {
return $this->identification_provider->contextAwareIdentifier($id);
};
$l = function (string $content) {
return $this->dic->ui()->factory()->legacy($content);
};
$tools[] = $this->factory->tool($iff("tree"))
$tools[] = $this->factory->tool($this->identification_provider->contextAwareIdentifier("tree"))
->withTitle($title)
->withSymbol($icon)
->withContentWrapper(function () use ($l, $tree_id) {
return $l($this->getSkillTree($tree_id));
->withContentWrapper(function () use ($tree_id) : Legacy {
return $this->dic->ui()->factory()->legacy($this->getSkillTree($tree_id));
});
}

Expand All @@ -80,17 +74,11 @@ public function getToolsForContextStack(CalledContexts $called_contexts) : array

if ($additional_data->is(self::SHOW_TEMPLATE_TREE, true)) {
$tree_id = $additional_data->get(self::SKILL_TREE_ID);
$iff = function ($id) {
return $this->identification_provider->contextAwareIdentifier($id);
};
$l = function (string $content) {
return $this->dic->ui()->factory()->legacy($content);
};
$tools[] = $this->factory->tool($iff("tree"))
$tools[] = $this->factory->tool($this->identification_provider->contextAwareIdentifier("tree"))
->withTitle("Templates")
->withSymbol($icon)
->withContentWrapper(function () use ($l, $tree_id) {
return $l($this->getTemplateTree($tree_id));
->withContentWrapper(function () use ($tree_id) : Legacy {
return $this->dic->ui()->factory()->legacy($this->getTemplateTree($tree_id));
});
}
return $tools;
Expand Down
50 changes: 35 additions & 15 deletions Services/Skill/Profile/class.ilSkillProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class ilSkillProfile implements ilSkillUsageInfo
protected int $ref_id = 0;
protected string $image_id = "";
protected int $skill_tree_id = 0;

/**
* @var array{base_skill_id: int, tref_id: int, level_id: int, order_nr: int}[]
*/
protected array $skill_level = [];

public function __construct(int $a_id = 0)
Expand Down Expand Up @@ -89,7 +93,7 @@ public function getRefId() : int
return $this->ref_id;
}

public function setImageId(string $a_val)
public function setImageId(string $a_val) : void
{
$this->image_id = $a_val;
}
Expand All @@ -99,7 +103,7 @@ public function getImageId() : string
return $this->image_id;
}

public function setSkillTreeId(int $a_val)
public function setSkillTreeId(int $a_val) : void
{
$this->skill_tree_id = $a_val;
}
Expand Down Expand Up @@ -131,9 +135,12 @@ public function removeSkillLevel(int $a_base_skill_id, int $a_tref_id, int $a_le
}
}

/**
* @return array{base_skill_id: int, tref_id: int, level_id: int, order_nr: int}[]
*/
public function getSkillLevels() : array
{
usort($this->skill_level, function ($level_a, $level_b) {
usort($this->skill_level, static function (array $level_a, array $level_b) : int {
return $level_a['order_nr'] <=> $level_b['order_nr'];
});

Expand Down Expand Up @@ -415,11 +422,8 @@ public static function getLocalProfilesForObject(int $a_ref_id) : array

return $profiles;
}

/**
* @return mixed
*/
protected static function lookup(int $a_id, string $a_field)

protected static function lookup(int $a_id, string $a_field) : ?string
{
global $DIC;

Expand All @@ -430,7 +434,8 @@ protected static function lookup(int $a_id, string $a_field)
" WHERE id = " . $ilDB->quote($a_id, "integer")
);
$rec = $ilDB->fetchAssoc($set);
return $rec[$a_field];

return isset($rec[$a_field]) ? (string) $rec[$a_field] : null;
}

public static function lookupTitle(int $a_id) : string
Expand All @@ -440,7 +445,7 @@ public static function lookupTitle(int $a_id) : string

public static function lookupRefId(int $a_id) : int
{
return self::lookup($a_id, "ref_id");
return (int) self::lookup($a_id, "ref_id");
}

/**
Expand Down Expand Up @@ -536,6 +541,9 @@ public static function removeUserFromAllProfiles(int $a_user_id) : void
);
}

/**
* @return array{id: int, title: string, description: string, image_id: string}[]
*/
public static function getProfilesOfUser(int $a_user_id) : array
{
global $DIC;
Expand All @@ -554,6 +562,7 @@ public static function getProfilesOfUser(int $a_user_id) : array
" ORDER BY p.title ASC"
);
while ($rec = $ilDB->fetchAssoc($set)) {
$rec['id'] = (int) $rec['id'];
$user_profiles[] = $rec;
}

Expand All @@ -570,9 +579,9 @@ public static function getProfilesOfUser(int $a_user_id) : array
// merge competence profiles and remove multiple occurrences
$all_profiles = array_merge($user_profiles, $role_profiles);
$temp_profiles = [];
foreach ($all_profiles as &$v) {
foreach ($all_profiles as $v) {
if (!isset($temp_profiles[$v["id"]])) {
$temp_profiles[$v["id"]] = &$v;
$temp_profiles[$v["id"]] = $v;
}
}
$all_profiles = array_values($temp_profiles);
Expand Down Expand Up @@ -667,6 +676,7 @@ public static function removeRoleFromAllProfiles(int $a_role_id) : void

/**
* Get global and local profiles of a role
* @return array{id: int, title: string, description: string, image_id: string}[]
*/
public static function getAllProfilesOfRole(int $a_role_id) : array
{
Expand All @@ -682,11 +692,15 @@ public static function getAllProfilesOfRole(int $a_role_id) : array
" ORDER BY p.title ASC"
);
while ($rec = $ilDB->fetchAssoc($set)) {
$rec['id'] = (int) $rec['id'];
$profiles[] = $rec;
}
return $profiles;
}

/**
* @return array{id: int, title: string, description: string, image_id: string}[]
*/
public static function getGlobalProfilesOfRole(int $a_role_id) : array
{
global $DIC;
Expand All @@ -702,8 +716,10 @@ public static function getGlobalProfilesOfRole(int $a_role_id) : array
" ORDER BY p.title ASC"
);
while ($rec = $ilDB->fetchAssoc($set)) {
$rec['id'] = (int) $rec['id'];
$profiles[] = $rec;
}

return $profiles;
}

Expand Down Expand Up @@ -741,11 +757,15 @@ public static function countRoles(int $a_profile_id) : int
return (int) $rec["rcnt"];
}

public static function getUsageInfo(array $a_cskill_ids, array &$a_usages) : void
/**
* @param array{skill_id: int, tref_id: int}[] $a_cskill_ids
*
* @return array<string, array<string, array{key: string}[]>>
*/
public static function getUsageInfo(array $a_cskill_ids) : array
{
ilSkillUsage::getUsageInfoGeneric(
return ilSkillUsage::getUsageInfoGeneric(
$a_cskill_ids,
$a_usages,
ilSkillUsage::PROFILE,
"skl_profile_level",
"profile_id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function getUserId() : int
return $this->user_id;
}

/**
* @param array{base_skill_id: int, tref_id: int, level_id: int} $a_skills
* @return array<int, array<int, int>>
*/
public function getActualMaxLevels(
array $a_skills = null,
string $a_gap_mode = "",
Expand Down Expand Up @@ -73,6 +77,7 @@ public function getActualLastLevels(
int $a_gap_mode_obj_id = 0
) : array {
// todo for coming feature
return [];
}

/**
Expand Down Expand Up @@ -121,6 +126,7 @@ public function isProfileFulfilled(int $a_profile_id) : bool

/**
* Get all profiles of user which are fulfilled or non-fulfilled
* @return array<int, bool>
*/
public function getAllProfileCompletionsForUser() : array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public function removeAllEntries() : void

/**
* Get all profile completion entries for a user
* @return array{profile_id: int, user_id: int, date: string, fulfilled: int}[]
*/
public static function getFulfilledEntriesForUser(int $a_user_id) : array
{
Expand All @@ -187,10 +188,10 @@ public static function getFulfilledEntriesForUser(int $a_user_id) : array
$entries = [];
while ($rec = $ilDB->fetchAssoc($set)) {
$entries[] = array(
"profile_id" => $rec["profile_id"],
"user_id" => $rec["user_id"],
"profile_id" => (int) $rec["profile_id"],
"user_id" => (int) $rec["user_id"],
"date" => $rec["date"],
"fulfilled" => $rec["fulfilled"]
"fulfilled" => (int) $rec["fulfilled"]
);
}

Expand Down
24 changes: 22 additions & 2 deletions Services/Skill/Profile/class.ilSkillProfileGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,34 @@ class ilSkillProfileGUI
protected SkillAdminGUIRequest $admin_gui_request;
protected int $requested_ref_id = 0;
protected int $requested_sprof_id = 0;

/**
* @var int[]
*/
protected array $requested_profile_ids = [];
protected bool $requested_local_context = false;
protected string $requested_cskill_id = "";
protected int $requested_level_id = 0;

/**
* @var string[]
*/
protected array $requested_level_ass_ids = [];

/**
* @var int[]
*/
protected array $requested_level_order = [];
protected string $requested_user_login = "";

/**
* @var int[]
*/
protected array $requested_users = [];

/**
* @var int[]
*/
protected array $requested_user_ids = [];
protected bool $local_context = false;

Expand Down Expand Up @@ -901,11 +921,11 @@ public function removeUsers() : void
$type = ilObject::_lookupType($i);
switch ($type) {
case 'usr':
$this->profile->removeUserFromProfile((int) $i);
$this->profile->removeUserFromProfile($i);
break;

case 'role':
$this->profile->removeRoleFromProfile((int) $i);
$this->profile->removeRoleFromProfile($i);
break;

default:
Expand Down
Loading