ILIAS  release_8 Revision v8.24
ILIAS\Skill\Profile\SkillProfileCompletionManager Class Reference

Manages skill profile completion. More...

+ Collaboration diagram for ILIAS\Skill\Profile\SkillProfileCompletionManager:

Public Member Functions

 __construct (SkillProfileManager $profile_manager, ?SkillProfileCompletionDBRepository $profile_completion_repo=null)
 
 getActualMaxLevels (int $user_id, array $skills, string $gap_mode="", string $gap_mode_type="", int $gap_mode_obj_id=0)
 
 getActualLastLevels (int $user_id, array $skills, string $gap_mode="", string $gap_mode_type="", int $gap_mode_obj_id=0)
 
 getActualNextLevelFulfilments (int $user_id, array $skills, string $gap_mode="", string $gap_mode_type="", int $gap_mode_obj_id=0)
 
 getProfileProgress (int $user_id, int $profile_id)
 Get progress in percent for a profile. More...
 
 isProfileFulfilled (int $user_id, int $profile_id)
 Check if a profile is fulfilled (progress = 100%) More...
 
 getAllProfileCompletionsForUser (int $user_id)
 Get all profiles of user which are fulfilled or non-fulfilled. More...
 
 getEntries (int $user_id, int $profile_id)
 Get profile completion entries for given user-profile-combination. More...
 
 getFulfilledEntriesForUser (int $user_id)
 Get all profile completion entries for a user. More...
 
 getAllEntriesForUser (int $user_id)
 Get all profile completion entries for a user. More...
 
 getAllEntriesForProfile (int $profile_id)
 Get all completion entries for a single profile. More...
 
 writeCompletionEntryForAllProfiles (int $user_id)
 Write profile completion entries (fulfilled or non-fulfilled) of user for all profiles. More...
 
 writeCompletionEntryForSingleProfile (int $user_id, int $profile_id)
 Write profile completion entry (fulfilled or non-fulfilled) of user for given profile. More...
 
 deleteEntriesForProfile (int $profile_id)
 Delete all profile completion entries for a profile. More...
 
 deleteEntriesForUser (int $user_id)
 Delete all profile completion entries for a user. More...
 

Protected Attributes

SkillProfileManager $profile_manager
 
SkillProfileCompletionDBRepository $profile_completion_repo
 
ilTree $tree_service
 
ilObjectDefinition $obj_definition
 

Detailed Description

Manages skill profile completion.

(business logic)

Author
Thomas Famula famul.nosp@m.a@le.nosp@m.ifos..nosp@m.de

Definition at line 29 of file class.SkillProfileCompletionManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Profile\SkillProfileCompletionManager::__construct ( SkillProfileManager  $profile_manager,
?SkillProfileCompletionDBRepository  $profile_completion_repo = null 
)

Definition at line 36 of file class.SkillProfileCompletionManager.php.

39 {
40 global $DIC;
41
42 $this->profile_manager = $profile_manager;
43 $this->profile_completion_repo = ($profile_completion_repo)
44 ?: $DIC->skills()->internal()->repo()->getProfileCompletionRepo();
45 $this->tree_service = $DIC->repositoryTree();
46 $this->obj_definition = $DIC["objDefinition"];
47 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Skill\Profile\SkillProfileCompletionManager\$profile_completion_repo, and ILIAS\Skill\Profile\SkillProfileCompletionManager\$profile_manager.

Member Function Documentation

◆ deleteEntriesForProfile()

ILIAS\Skill\Profile\SkillProfileCompletionManager::deleteEntriesForProfile ( int  $profile_id)

Delete all profile completion entries for a profile.

Definition at line 258 of file class.SkillProfileCompletionManager.php.

258 : void
259 {
260 $this->profile_completion_repo->deleteEntriesForProfile($profile_id);
261 }

◆ deleteEntriesForUser()

ILIAS\Skill\Profile\SkillProfileCompletionManager::deleteEntriesForUser ( int  $user_id)

Delete all profile completion entries for a user.

Definition at line 266 of file class.SkillProfileCompletionManager.php.

266 : void
267 {
268 $this->profile_completion_repo->deleteEntriesForUser($user_id);
269 }

◆ getActualLastLevels()

ILIAS\Skill\Profile\SkillProfileCompletionManager::getActualLastLevels ( int  $user_id,
array  $skills,
string  $gap_mode = "",
string  $gap_mode_type = "",
int  $gap_mode_obj_id = 0 
)

Definition at line 93 of file class.SkillProfileCompletionManager.php.

99 : array {
100 // todo for coming feature
101 return [];
102 }

◆ getActualMaxLevels()

ILIAS\Skill\Profile\SkillProfileCompletionManager::getActualMaxLevels ( int  $user_id,
array  $skills,
string  $gap_mode = "",
string  $gap_mode_type = "",
int  $gap_mode_obj_id = 0 
)
Parameters
array{base_skill_idint, tref_id: int, level_id: int} $skills
Returns
array<int, array<int, int>>

Definition at line 53 of file class.SkillProfileCompletionManager.php.

59 : array {
60 // get actual levels for gap analysis
61 $actual_levels = [];
62 foreach ($skills as $sk) {
63 $bs = new \ilBasicSkill($sk["base_skill_id"]);
64 if ($gap_mode == "max_per_type") {
65 $max = $bs->getMaxLevelPerType($sk["tref_id"], $gap_mode_type, $user_id);
66 } elseif ($gap_mode == "max_per_object") {
67 if ($this->obj_definition->isContainer(\ilObject::_lookupType($gap_mode_obj_id))) {
68 $sub_objects = $this->tree_service->getSubTree(
69 $this->tree_service->getNodeData((int) current(\ilObject::_getAllReferences($gap_mode_obj_id))),
70 false,
72 );
73 $max = 0;
74 foreach ($sub_objects as $ref_id) {
76 $max_tmp = $bs->getMaxLevelPerObject($sk["tref_id"], $obj_id, $user_id);
77 if ($max_tmp > $max) {
78 $max = $max_tmp;
79 }
80 }
81 } else {
82 $max = $bs->getMaxLevelPerObject($sk["tref_id"], $gap_mode_obj_id, $user_id);
83 }
84 } else {
85 $max = $bs->getMaxLevel($sk["tref_id"], $user_id);
86 }
87 $actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
88 }
89
90 return $actual_levels;
91 }
static getSupportedObjectTypes()
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67

References $ref_id, ilObject\_getAllReferences(), ilObject\_lookupObjectId(), ilObject\_lookupType(), and ilObjectLP\getSupportedObjectTypes().

+ Here is the call graph for this function:

◆ getActualNextLevelFulfilments()

ILIAS\Skill\Profile\SkillProfileCompletionManager::getActualNextLevelFulfilments ( int  $user_id,
array  $skills,
string  $gap_mode = "",
string  $gap_mode_type = "",
int  $gap_mode_obj_id = 0 
)
Parameters
array{base_skill_idint, tref_id: int, level_id: int} $skills
Returns
array<int, array<int, float>>

Definition at line 108 of file class.SkillProfileCompletionManager.php.

114 : array {
115 // get actual next level fulfilments for gap analysis
116 $fuls = [];
117 foreach ($skills as $sk) {
118 $bs = new \ilBasicSkill($sk["base_skill_id"]);
119 if ($gap_mode == "max_per_type") {
120 $perc = $bs->getNextLevelFulfilmentPerType($sk["tref_id"], $gap_mode_type, $user_id);
121 } elseif ($gap_mode == "max_per_object") {
122 $perc = $bs->getNextLevelFulfilmentPerObject($sk["tref_id"], $gap_mode_obj_id, $user_id);
123 } else {
124 $perc = $bs->getNextLevelFulfilment($sk["tref_id"], $user_id);
125 }
126 $fuls[$sk["base_skill_id"]][$sk["tref_id"]] = $perc;
127 }
128
129 return $fuls;
130 }

◆ getAllEntriesForProfile()

ILIAS\Skill\Profile\SkillProfileCompletionManager::getAllEntriesForProfile ( int  $profile_id)

Get all completion entries for a single profile.

Definition at line 223 of file class.SkillProfileCompletionManager.php.

223 : array
224 {
225 return $this->profile_completion_repo->getAllEntriesForProfile($profile_id);
226 }

◆ getAllEntriesForUser()

ILIAS\Skill\Profile\SkillProfileCompletionManager::getAllEntriesForUser ( int  $user_id)

Get all profile completion entries for a user.

Definition at line 215 of file class.SkillProfileCompletionManager.php.

215 : array
216 {
217 return $this->profile_completion_repo->getAllEntriesForUser($user_id);
218 }

◆ getAllProfileCompletionsForUser()

ILIAS\Skill\Profile\SkillProfileCompletionManager::getAllProfileCompletionsForUser ( int  $user_id)

Get all profiles of user which are fulfilled or non-fulfilled.

Returns
array<int, bool>

Definition at line 180 of file class.SkillProfileCompletionManager.php.

180 : array
181 {
182 $user_profiles = $this->profile_manager->getProfilesOfUser($user_id);
183 $profile_comps = [];
184 foreach ($user_profiles as $p) {
185 if ($this->isProfileFulfilled($user_id, $p["id"])) {
186 $profile_comps[$p["id"]] = true;
187 } else {
188 $profile_comps[$p["id"]] = false;
189 }
190 }
191
192 return $profile_comps;
193 }
isProfileFulfilled(int $user_id, int $profile_id)
Check if a profile is fulfilled (progress = 100%)

◆ getEntries()

ILIAS\Skill\Profile\SkillProfileCompletionManager::getEntries ( int  $user_id,
int  $profile_id 
)

Get profile completion entries for given user-profile-combination.

Definition at line 198 of file class.SkillProfileCompletionManager.php.

198 : array
199 {
200 return $this->profile_completion_repo->getEntries($user_id, $profile_id);
201 }

◆ getFulfilledEntriesForUser()

ILIAS\Skill\Profile\SkillProfileCompletionManager::getFulfilledEntriesForUser ( int  $user_id)

Get all profile completion entries for a user.

Returns
array{profile_id: int, user_id: int, date: string, fulfilled: int}[]

Definition at line 207 of file class.SkillProfileCompletionManager.php.

207 : array
208 {
209 return $this->profile_completion_repo->getFulfilledEntriesForUser($user_id);
210 }

◆ getProfileProgress()

ILIAS\Skill\Profile\SkillProfileCompletionManager::getProfileProgress ( int  $user_id,
int  $profile_id 
)

Get progress in percent for a profile.

Definition at line 135 of file class.SkillProfileCompletionManager.php.

135 : int
136 {
137 $profile = $this->profile_manager->getById($profile_id);
138 $profile_levels = $profile->getSkillLevels();
139 $skills = [];
140 foreach ($profile_levels as $l) {
141 $skills[] = array(
142 "base_skill_id" => $l["base_skill_id"],
143 "tref_id" => $l["tref_id"],
144 "level_id" => $l["level_id"]
145 );
146 }
147 $actual_levels = $this->getActualMaxLevels($user_id, $skills);
148
149 $profile_count = 0;
150 $achieved_count = 0;
151 foreach ($profile_levels as $profile) {
152 if ($actual_levels[$profile["base_skill_id"]][$profile["tref_id"]] >= $profile["level_id"]) {
153 $achieved_count++;
154 }
155 $profile_count++;
156 }
157 if ($profile_count == 0) {
158 return 0;
159 }
160 $progress = $achieved_count / $profile_count * 100;
161
162 return (int) $progress;
163 }
getActualMaxLevels(int $user_id, array $skills, string $gap_mode="", string $gap_mode_type="", int $gap_mode_obj_id=0)

◆ isProfileFulfilled()

ILIAS\Skill\Profile\SkillProfileCompletionManager::isProfileFulfilled ( int  $user_id,
int  $profile_id 
)

Check if a profile is fulfilled (progress = 100%)

Definition at line 168 of file class.SkillProfileCompletionManager.php.

168 : bool
169 {
170 if ($this->getProfileProgress($user_id, $profile_id) == 100) {
171 return true;
172 }
173 return false;
174 }
getProfileProgress(int $user_id, int $profile_id)
Get progress in percent for a profile.

◆ writeCompletionEntryForAllProfiles()

ILIAS\Skill\Profile\SkillProfileCompletionManager::writeCompletionEntryForAllProfiles ( int  $user_id)

Write profile completion entries (fulfilled or non-fulfilled) of user for all profiles.

Definition at line 231 of file class.SkillProfileCompletionManager.php.

231 : void
232 {
233 $completions = $this->getAllProfileCompletionsForUser($user_id);
234 foreach ($completions as $profile_id => $fulfilled) {
235 if ($fulfilled) {
236 $this->profile_completion_repo->addFulfilmentEntry($user_id, $profile_id);
237 } else {
238 $this->profile_completion_repo->addNonFulfilmentEntry($user_id, $profile_id);
239 }
240 }
241 }
getAllProfileCompletionsForUser(int $user_id)
Get all profiles of user which are fulfilled or non-fulfilled.

◆ writeCompletionEntryForSingleProfile()

ILIAS\Skill\Profile\SkillProfileCompletionManager::writeCompletionEntryForSingleProfile ( int  $user_id,
int  $profile_id 
)

Write profile completion entry (fulfilled or non-fulfilled) of user for given profile.

Definition at line 246 of file class.SkillProfileCompletionManager.php.

246 : void
247 {
248 if ($this->isProfileFulfilled($user_id, $profile_id)) {
249 $this->profile_completion_repo->addFulfilmentEntry($user_id, $profile_id);
250 } else {
251 $this->profile_completion_repo->addNonFulfilmentEntry($user_id, $profile_id);
252 }
253 }

Field Documentation

◆ $obj_definition

ilObjectDefinition ILIAS\Skill\Profile\SkillProfileCompletionManager::$obj_definition
protected

Definition at line 34 of file class.SkillProfileCompletionManager.php.

◆ $profile_completion_repo

SkillProfileCompletionDBRepository ILIAS\Skill\Profile\SkillProfileCompletionManager::$profile_completion_repo
protected

◆ $profile_manager

SkillProfileManager ILIAS\Skill\Profile\SkillProfileCompletionManager::$profile_manager
protected

◆ $tree_service

ilTree ILIAS\Skill\Profile\SkillProfileCompletionManager::$tree_service
protected

Definition at line 33 of file class.SkillProfileCompletionManager.php.


The documentation for this class was generated from the following file: