19 declare(strict_types=1);
48 ?: $DIC->skills()->internal()->repo()->getResourceRepo();
50 ?: $DIC->skills()->internal()->repo()->getLevelRepo();
58 return $this->skill_res_repo->getAll($skill_id, $tref_id);
66 $all_resources = $this->skill_res_repo->getAll($skill_id, $tref_id);
67 $resources_of_level = [];
68 foreach ($all_resources as $lid => $level) {
69 foreach ($level as $resource) {
70 if ($lid == $level_id) {
71 $resources_of_level[] = $resource;
76 return $resources_of_level;
87 $this->skill_res_repo->addOrUpdate($skill_id, $tref_id, $level_id, $rep_ref_id, $imparting, $trigger);
96 $this->skill_res_repo->updateImparting($skill_id, $tref_id, $level_id, $rep_ref_id,
true);
105 $this->skill_res_repo->updateImparting($skill_id, $tref_id, $level_id, $rep_ref_id,
false);
119 $this->skill_res_repo->updateTrigger($skill_id, $tref_id, $level_id, $rep_ref_id,
true);
128 $this->skill_res_repo->updateTrigger($skill_id, $tref_id, $level_id, $rep_ref_id,
false);
137 $this->skill_res_repo->remove($skill_id, $tref_id, $level_id, $rep_ref_id);
142 $this->skill_res_repo->removeForSkill($skill_node_id, $is_reference);
145 public function isLevelTooLow(
int $tref_id, array $skill_levels, array $profile_levels, array $actual_levels): bool
149 foreach ($skill_levels as $v) {
150 $v[
"id"] = (
int) $v[
"id"];
151 $v[
"skill_id"] = (
int) $v[
"skill_id"];
152 foreach ($profile_levels as $pl) {
153 if ($pl->getLevelId() === $v[
"id"] &&
154 $pl->getBaseSkillId() === $v[
"skill_id"]) {
159 if ($actual_levels[$v[
"skill_id"]][$tref_id] == $v[
"id"]) {
172 foreach ($skill_levels as $l) {
173 $l[
"id"] = (
int) $l[
"id"];
174 $l[
"skill_id"] = (
int) $l[
"skill_id"];
175 foreach ($profile_levels as $pl) {
176 if ($pl->getLevelId() === $l[
"id"] &&
177 $pl->getBaseSkillId() === $l[
"skill_id"]) {
178 $target_level = $l[
"id"];
183 return $target_level;
190 public function getSuggestedResources(
int $skill_id,
int $tref_id, array $skill_levels, array $profile_levels): array
193 $target_level_order_nr = $this->level_repo->lookupLevelNumber($target_level);
197 foreach ($level as
$r) {
198 $res_level_order_nr = $this->level_repo->lookupLevelNumber($r->getLevelId());
199 if ($r->getImparting() &&
200 $target_level_order_nr >= $res_level_order_nr) {
201 $imp_resources[$res_level_order_nr .
"_" . $r->getLevelId()][] =
$r;
206 ksort($imp_resources);
207 return $imp_resources;
215 return $this->skill_res_repo->getTriggerLevelsForRefId($rep_ref_id);
225 $usage_manager = $DIC->skills()->internal()->manager()->getUsageManager();
227 return $usage_manager->getUsageInfoGeneric(
230 "skl_skill_resource",
determineCurrentTargetLevel(array $skill_levels, array $profile_levels)
getResources(int $skill_id, int $tref_id)
__construct(?SkillResourceDBRepository $skill_res_repo=null, ?\ilSkillLevelRepository $level_repo=null)
setResourceAsNoTrigger(int $skill_id, int $tref_id, int $level_id, int $rep_ref_id)
static isSupportedObjectType(string $type)
getSuggestedResources(int $skill_id, int $tref_id, array $skill_levels, array $profile_levels)
setResourceAsNotSuggested(int $skill_id, int $tref_id, int $level_id, int $rep_ref_id)
Interface ilSkillLevelRepository.
removeResourcesForSkill(int $skill_node_id, bool $is_reference=false)
getResourcesOfLevel(int $skill_id, int $tref_id, int $level_id)
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getUsageInfo(array $a_cskill_ids)
Get title of an assigned item.int, tref_id: int}[] $a_cskill_ids array of common skill idsarray<strin...
setResourceAsSuggested(int $skill_id, int $tref_id, int $level_id, int $rep_ref_id)
isLevelTooLow(int $tref_id, array $skill_levels, array $profile_levels, array $actual_levels)
ilSkillLevelRepository $level_repo
removeResource(int $skill_id, int $tref_id, int $level_id, int $rep_ref_id)
setResource(int $skill_id, int $tref_id, int $level_id, int $rep_ref_id, bool $imparting, bool $trigger)
Manages resources for skills.
SkillResourceDBRepository $skill_res_repo
static _lookupType(int $id, bool $reference=false)
getTriggerLevelsForRefId(int $rep_ref_id)
Get info on usages of skills.
setResourceAsTrigger(int $skill_id, int $tref_id, int $level_id, int $rep_ref_id)