ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 fulfilled 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...
 
 writeCompletionEntryForAllProfilesOfUser (int $user_id)
 Write profile completion entries (fulfilled or non-fulfilled) of user for all profiles. More...
 
 writeCompletionEntryForSingleProfileOfUser (int $user_id, int $profile_id)
 Write profile completion entry (fulfilled or non-fulfilled) of user for given profile. More...
 
 writeCompletionEntryForAllAssignedUsersOfProfile (int $profile_id)
 Write completion entries for a profile for all assigned users of the given profile. More...
 
 writeCompletionEntryForRole (int $role_id, int $profile_id)
 Write completion entries for a profile for assigned users of a role. 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 33 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 40 of file class.SkillProfileCompletionManager.php.

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

43  {
44  global $DIC;
45 
46  $this->profile_manager = $profile_manager;
47  $this->profile_completion_repo = ($profile_completion_repo)
48  ?: $DIC->skills()->internal()->repo()->getProfileCompletionRepo();
49  $this->tree_service = $DIC->repositoryTree();
50  $this->obj_definition = $DIC["objDefinition"];
51  }
global $DIC
Definition: shib_login.php:22

Member Function Documentation

◆ deleteEntriesForProfile()

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

Delete all profile completion entries for a profile.

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

279  : void
280  {
281  $this->profile_completion_repo->deleteEntriesForProfile($profile_id);
282  }

◆ deleteEntriesForUser()

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

Delete all profile completion entries for a user.

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

287  : void
288  {
289  $this->profile_completion_repo->deleteEntriesForUser($user_id);
290  }

◆ 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 97 of file class.SkillProfileCompletionManager.php.

103  : array {
104  // todo for coming feature
105  return [];
106  }

◆ 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
GapAnalysisSkill[]$skills
Returns
array<int, array<int, int>>

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

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

Referenced by ILIAS\Skill\Profile\SkillProfileCompletionManager\getProfileProgress().

63  : array {
64  // get actual levels for gap analysis
65  $actual_levels = [];
66  foreach ($skills as $sk) {
67  $bs = new \ilBasicSkill($sk->getBaseSkillId());
68  if ($gap_mode == "max_per_type") {
69  $max = $bs->getMaxLevelPerType($sk->getTrefId(), $gap_mode_type, $user_id);
70  } elseif ($gap_mode == "max_per_object") {
71  if ($this->obj_definition->isContainer(\ilObject::_lookupType($gap_mode_obj_id))) {
72  $sub_objects = $this->tree_service->getSubTree(
73  $this->tree_service->getNodeData((int) current(\ilObject::_getAllReferences($gap_mode_obj_id))),
74  false,
76  );
77  $max = 0;
78  foreach ($sub_objects as $ref_id) {
79  $obj_id = \ilContainerReference::_lookupObjectId($ref_id);
80  $max_tmp = $bs->getMaxLevelPerObject($sk->getTrefId(), $obj_id, $user_id);
81  if ($max_tmp > $max) {
82  $max = $max_tmp;
83  }
84  }
85  } else {
86  $max = $bs->getMaxLevelPerObject($sk->getTrefId(), $gap_mode_obj_id, $user_id);
87  }
88  } else {
89  $max = $bs->getMaxLevel($sk->getTrefId(), $user_id);
90  }
91  $actual_levels[$sk->getBaseSkillId()][$sk->getTrefId()] = $max;
92  }
93 
94  return $actual_levels;
95  }
static getSupportedObjectTypes()
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:65
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller 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
GapAnalysisSkill[]$skills
Returns
array<int, array<int, float>>

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

References $user_id.

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

◆ getAllEntriesForProfile()

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

Get all completion entries for a single profile.

Returns
SkillProfileCompletion[]

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

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

◆ getAllEntriesForUser()

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

Get all profile completion entries for a user.

Returns
SkillProfileCompletion[]

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

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

◆ 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 176 of file class.SkillProfileCompletionManager.php.

References ILIAS\Skill\Profile\SkillProfileCompletionManager\isProfileFulfilled().

Referenced by ILIAS\Skill\Profile\SkillProfileCompletionManager\writeCompletionEntryForAllProfilesOfUser().

176  : array
177  {
178  $user_profiles = $this->profile_manager->getProfilesOfUser($user_id);
179  $profile_comps = [];
180  foreach ($user_profiles as $p) {
181  if ($this->isProfileFulfilled($user_id, $p->getId())) {
182  $profile_comps[$p->getId()] = true;
183  } else {
184  $profile_comps[$p->getId()] = false;
185  }
186  }
187 
188  return $profile_comps;
189  }
isProfileFulfilled(int $user_id, int $profile_id)
Check if a profile is fulfilled (progress = 100%)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEntries()

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

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

Returns
SkillProfileCompletion[]

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

195  : array
196  {
197  return $this->profile_completion_repo->getEntries($user_id, $profile_id);
198  }

◆ getFulfilledEntriesForUser()

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

Get all fulfilled profile completion entries for a user.

Returns
SkillProfileCompletion[]

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

204  : array
205  {
206  return $this->profile_completion_repo->getFulfilledEntriesForUser($user_id);
207  }

◆ getProfileProgress()

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

Get progress in percent for a profile.

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

References ILIAS\Skill\Profile\SkillProfileCompletionManager\getActualMaxLevels().

Referenced by ILIAS\Skill\Profile\SkillProfileCompletionManager\isProfileFulfilled().

139  : int
140  {
141  $profile_levels = $this->profile_manager->getSkillLevels($profile_id);
142  $actual_levels = $this->getActualMaxLevels($user_id, $profile_levels);
143 
144  $profile_count = 0;
145  $achieved_count = 0;
146  foreach ($profile_levels as $level) {
147  if (isset($actual_levels[$level->getBaseSkillId()][$level->getTrefId()]) &&
148  $actual_levels[$level->getBaseSkillId()][$level->getTrefId()] >= $level->getLevelId()) {
149  $achieved_count++;
150  }
151  $profile_count++;
152  }
153  if ($profile_count == 0) {
154  return 0;
155  }
156  $progress = $achieved_count / $profile_count * 100;
157 
158  return (int) $progress;
159  }
getActualMaxLevels(int $user_id, array $skills, string $gap_mode="", string $gap_mode_type="", int $gap_mode_obj_id=0)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isProfileFulfilled()

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

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

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

References ILIAS\Skill\Profile\SkillProfileCompletionManager\getProfileProgress().

Referenced by ILIAS\Skill\Profile\SkillProfileCompletionManager\getAllProfileCompletionsForUser(), and ILIAS\Skill\Profile\SkillProfileCompletionManager\writeCompletionEntryForSingleProfileOfUser().

164  : bool
165  {
166  if ($this->getProfileProgress($user_id, $profile_id) == 100) {
167  return true;
168  }
169  return false;
170  }
getProfileProgress(int $user_id, int $profile_id)
Get progress in percent for a profile.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeCompletionEntryForAllAssignedUsersOfProfile()

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

Write completion entries for a profile for all assigned users of the given profile.

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

References $user_id, and ILIAS\Skill\Profile\SkillProfileCompletionManager\writeCompletionEntryForSingleProfileOfUser().

257  : void
258  {
259  $users = $this->profile_manager->getAssignedUserIdsIncludingRoleAssignments($profile_id);
260  foreach ($users as $user_id) {
261  $this->writeCompletionEntryForSingleProfileOfUser($user_id, $profile_id);
262  }
263  }
writeCompletionEntryForSingleProfileOfUser(int $user_id, int $profile_id)
Write profile completion entry (fulfilled or non-fulfilled) of user for given profile.
+ Here is the call graph for this function:

◆ writeCompletionEntryForAllProfilesOfUser()

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

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

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

References ILIAS\Skill\Profile\SkillProfileCompletionManager\getAllProfileCompletionsForUser().

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

◆ writeCompletionEntryForRole()

ILIAS\Skill\Profile\SkillProfileCompletionManager::writeCompletionEntryForRole ( int  $role_id,
int  $profile_id 
)

Write completion entries for a profile for assigned users of a role.

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

References $user_id, and ILIAS\Skill\Profile\SkillProfileCompletionManager\writeCompletionEntryForSingleProfileOfUser().

268  : void
269  {
270  $r_users = $this->profile_manager->getAssignedUsersForRole($role_id);
271  foreach ($r_users as $user_id) {
272  $this->writeCompletionEntryForSingleProfileOfUser($user_id, $profile_id);
273  }
274  }
writeCompletionEntryForSingleProfileOfUser(int $user_id, int $profile_id)
Write profile completion entry (fulfilled or non-fulfilled) of user for given profile.
+ Here is the call graph for this function:

◆ writeCompletionEntryForSingleProfileOfUser()

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

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

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

References ILIAS\Skill\Profile\SkillProfileCompletionManager\isProfileFulfilled().

Referenced by ILIAS\Skill\Profile\SkillProfileCompletionManager\writeCompletionEntryForAllAssignedUsersOfProfile(), and ILIAS\Skill\Profile\SkillProfileCompletionManager\writeCompletionEntryForRole().

245  : void
246  {
247  if ($this->isProfileFulfilled($user_id, $profile_id)) {
248  $this->profile_completion_repo->addFulfilmentEntry($user_id, $profile_id);
249  } else {
250  $this->profile_completion_repo->addNonFulfilmentEntry($user_id, $profile_id);
251  }
252  }
isProfileFulfilled(int $user_id, int $profile_id)
Check if a profile is fulfilled (progress = 100%)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $obj_definition

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

Definition at line 38 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 37 of file class.SkillProfileCompletionManager.php.


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