ILIAS  release_8 Revision v8.24
class.SkillProfile.php
Go to the documentation of this file.
1<?php
2
21
28{
29 protected int $id = 0;
30 protected string $title = "";
31 protected string $description = "";
32 protected int $skill_tree_id = 0;
33 protected string $image_id = "";
34 protected int $ref_id = 0;
38 protected array $skill_level = [];
39
41
42 public function __construct(
43 int $id,
44 string $title,
45 string $description,
47 string $image_id = "",
48 int $ref_id = 0
49 ) {
50 global $DIC;
51
52 $this->id = $id;
53 $this->title = $title;
54 $this->description = $description;
55 $this->skill_tree_id = $skill_tree_id;
56 $this->image_id = $image_id;
57 $this->ref_id = $ref_id;
58
59 $this->profile_levels_repo = $DIC->skills()->internal()->repo()->getProfileLevelsRepo();
60
61 if ($this->getId() > 0) {
62 $levels = $this->profile_levels_repo->getProfileLevels($this->getId());
63 foreach ($levels as $level) {
64 $this->addSkillLevel(
65 $level["base_skill_id"],
66 $level["tref_id"],
67 $level["level_id"],
68 $level["order_nr"]
69 );
70 }
71 }
72 }
73
74 public function getId(): int
75 {
76 return $this->id;
77 }
78
79 public function getTitle(): string
80 {
81 return $this->title;
82 }
83
84 public function getDescription(): string
85 {
86 return $this->description;
87 }
88
89 public function getRefId(): int
90 {
91 return $this->ref_id;
92 }
93
94 public function getImageId(): string
95 {
96 return $this->image_id;
97 }
98
99 public function getSkillTreeId(): int
100 {
102 }
103
104 public function addSkillLevel(int $base_skill_id, int $tref_id, int $level_id, int $order_nr): void
105 {
106 $this->skill_level[] = array(
107 "base_skill_id" => $base_skill_id,
108 "tref_id" => $tref_id,
109 "level_id" => $level_id,
110 "order_nr" => $order_nr
111 );
112 }
113
114 public function removeSkillLevel(int $base_skill_id, int $tref_id, int $level_id, int $order_nr): void
115 {
116 foreach ($this->skill_level as $k => $sl) {
117 if ((int) $sl["base_skill_id"] == $base_skill_id &&
118 (int) $sl["tref_id"] == $tref_id &&
119 (int) $sl["level_id"] == $level_id &&
120 (int) $sl["order_nr"] == $order_nr) {
121 unset($this->skill_level[$k]);
122 }
123 }
124 }
125
129 public function getSkillLevels(): array
130 {
131 usort($this->skill_level, static function (array $level_a, array $level_b): int {
132 return $level_a['order_nr'] <=> $level_b['order_nr'];
133 });
134
135 return $this->skill_level;
136 }
137
143 public static function getUsageInfo(array $a_cskill_ids): array
144 {
145 return \ilSkillUsage::getUsageInfoGeneric(
146 $a_cskill_ids,
148 "skl_profile_level",
149 "profile_id",
150 "base_skill_id"
151 );
152 }
153}
static getUsageInfo(array $a_cskill_ids)
removeSkillLevel(int $base_skill_id, int $tref_id, int $level_id, int $order_nr)
__construct(int $id, string $title, string $description, int $skill_tree_id, string $image_id="", int $ref_id=0)
addSkillLevel(int $base_skill_id, int $tref_id, int $level_id, int $order_nr)
SkillProfileLevelsDBRepository $profile_levels_repo
global $DIC
Definition: feed.php:28
Get info on usages of skills.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...