ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Skill\Usage\SkillUsageManager Class Reference

Skill usage. More...

+ Inheritance diagram for ILIAS\Skill\Usage\SkillUsageManager:
+ Collaboration diagram for ILIAS\Skill\Usage\SkillUsageManager:

Public Member Functions

 __construct (?SkillUsageDBRepository $usage_repo=null, ?SkillTreeFactory $tree_factory=null, ?\ilSkillTreeRepository $tree_repo=null, ?SkillProfileManager $profile_manager=null)
 
 addUsage (int $obj_id, int $skill_id, int $tref_id)
 
 removeUsage (int $obj_id, int $skill_id, int $tref_id)
 
 removeUsagesFromObject (int $obj_id)
 
 removeUsagesForSkill (int $node_id, bool $is_referenece=false)
 
 getUsages (int $skill_id, int $tref_id)
 
 getUsageInfoGeneric (array $cskill_ids, string $usage_type, string $table, string $key_field, string $skill_field="skill_id", string $tref_field="tref_id")
 Get standard usage query. More...
 
 getAllUsagesInfo (array $cskill_ids)
 
 getAllUsagesInfoOfTrees (array $tree_ids)
 
 getAllUsagesInfoOfSubtree (int $skill_id, int $tref_id=0)
 
 getAllUsagesInfoOfSubtrees (array $cskill_ids)
 
 getAllUsagesOfTemplate (int $template_id)
 
 getTypeInfoString (string $type)
 
 getObjTypeString (string $type)
 
 getAssignedObjectsForSkill (int $skill_id, int $tref_id)
 
 getAssignedObjectsForSkillTemplate (int $template_id)
 
 getAssignedObjectsForSkillProfile (int $profile_id)
 

Static Public Member Functions

static getUsageInfo (array $a_cskill_ids)
 Get title of an assigned item.
Parameters
array{skill_idint, tref_id: int}[] $a_cskill_ids array of common skill ids
Returns
array<string, array<string, array{key: string}[]>>
More...
 
static getUsageInfo (array $a_cskill_ids)
 Get title of an assigned item. More...
 

Data Fields

const TYPE_GENERAL = "gen"
 
const USER_ASSIGNED = "user"
 
const PERSONAL_SKILL = "pers"
 
const USER_MATERIAL = "mat"
 
const SELF_EVAL = "seval"
 
const PROFILE = "prof"
 
const RESOURCE = "res"
 

Protected Attributes

array $classes
 
SkillUsageDBRepository $usage_repo
 
SkillTreeFactory $tree_factory
 
ilSkillTreeRepository $tree_repo
 
SkillProfileManager $profile_manager
 
ilLanguage $lng
 

Detailed Description

Skill usage.

With this class a general skill use by an object (identified by its obj_id) is registered or unregistered.

The class maintains skill usages of the following types

  • GENERAL: General use submitted by an object, saved in table "skl_usage"
  • USER_ASSIGNED: Skill level is assigned to a user (tables skl_user_skill_level and skl_user_has_level)
  • PERSONAL_SKILL: table skl_personal_skill (do we need that?)
  • USER_MATERIAL: User has assigned material to the skill
  • SELF_EVAL: User has self evaluated (may be USER_ASSIGNED in the future)
  • PROFILE: Skill is used in skill profile (table "skl_profile_level")
  • RESOURCE: A resource is assigned to a skill level (table "skl_skill_resource")
Author
Alex Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..com

Definition at line 45 of file class.SkillUsageManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Usage\SkillUsageManager::__construct ( ?SkillUsageDBRepository  $usage_repo = null,
?SkillTreeFactory  $tree_factory = null,
?\ilSkillTreeRepository  $tree_repo = null,
?SkillProfileManager  $profile_manager = null 
)

Definition at line 67 of file class.SkillUsageManager.php.

72 {
73 global $DIC;
74
75 $this->usage_repo = ($usage_repo) ?: $DIC->skills()->internal()->repo()->getUsageRepo();
76 $this->tree_factory = ($tree_factory) ?: $DIC->skills()->internal()->factory()->tree();
77 $this->tree_repo = ($tree_repo) ?: $DIC->skills()->internal()->repo()->getTreeRepo();
78 $this->profile_manager = ($profile_manager) ?: $DIC->skills()->internal()->manager()->getProfileManager();
79 $this->lng = $DIC->language();
80 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Skill\Usage\SkillUsageManager\$profile_manager, ILIAS\Skill\Usage\SkillUsageManager\$tree_factory, ILIAS\Skill\Usage\SkillUsageManager\$tree_repo, ILIAS\Skill\Usage\SkillUsageManager\$usage_repo, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ addUsage()

ILIAS\Skill\Usage\SkillUsageManager::addUsage ( int  $obj_id,
int  $skill_id,
int  $tref_id 
)

Definition at line 82 of file class.SkillUsageManager.php.

82 : void
83 {
84 $this->usage_repo->add($obj_id, $skill_id, $tref_id);
85 }

◆ getAllUsagesInfo()

ILIAS\Skill\Usage\SkillUsageManager::getAllUsagesInfo ( array  $cskill_ids)
Parameters
array{skill_idint, tref_id: int}[] $cskill_ids array of common skill ids ("skill_id" => skill_id, "tref_id" => tref_id)
Returns
array<string, array<string, array{key: string}[]>>

Definition at line 160 of file class.SkillUsageManager.php.

160 : array
161 {
163
164 $usages = [];
165 foreach ($classes as $class) {
166 $usages = array_merge_recursive($usages, $class::getUsageInfo($cskill_ids));
167 }
168 return $usages;
169 }

◆ getAllUsagesInfoOfSubtree()

ILIAS\Skill\Usage\SkillUsageManager::getAllUsagesInfoOfSubtree ( int  $skill_id,
int  $tref_id = 0 
)
Returns
array<string, array<string, array{key: string}[]>>

Definition at line 194 of file class.SkillUsageManager.php.

194 : array
195 {
196 // get nodes
197 $vtree = $this->tree_repo->getVirtualTreeForNodeId($skill_id);
198 $nodes = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id);
199
200 return $this->getAllUsagesInfo($nodes);
201 }

◆ getAllUsagesInfoOfSubtrees()

ILIAS\Skill\Usage\SkillUsageManager::getAllUsagesInfoOfSubtrees ( array  $cskill_ids)
Parameters
array$cskill_idsarray of common skill ids ("skill_id" => skill_id, "tref_id" => tref_id)
Returns
array<string, array<string, array{key: string}[]>>

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

207 : array
208 {
209 // get nodes
210 $allnodes = [];
211 foreach ($cskill_ids as $s) {
212 $vtree = $this->tree_repo->getVirtualTreeForNodeId($s["skill_id"]);
213 $nodes = $vtree->getSubTreeForCSkillId($s["skill_id"] . ":" . $s["tref_id"]);
214 foreach ($nodes as $n) {
215 $allnodes[] = $n;
216 }
217 }
218
219 return $this->getAllUsagesInfo($allnodes);
220 }

◆ getAllUsagesInfoOfTrees()

ILIAS\Skill\Usage\SkillUsageManager::getAllUsagesInfoOfTrees ( array  $tree_ids)
Parameters
array$tree_idsarray of common skill ids ("skill_id" => skill_id, "tref_id" => tref_id)
Returns
array<string, array<string, array{key: string}[]>>

Definition at line 175 of file class.SkillUsageManager.php.

175 : array
176 {
177 // get nodes
178
179 $allnodes = [];
180 foreach ($tree_ids as $t) {
181 $vtree = $this->tree_factory->getGlobalVirtualTree();
182 $nodes = $vtree->getSubTreeForTreeId((string) $t);
183 foreach ($nodes as $n) {
184 $allnodes[] = $n;
185 }
186 }
187
188 return $this->getAllUsagesInfo($allnodes);
189 }

◆ getAllUsagesOfTemplate()

ILIAS\Skill\Usage\SkillUsageManager::getAllUsagesOfTemplate ( int  $template_id)
Returns
array<string, array<string, array{key: string}[]>>

Definition at line 225 of file class.SkillUsageManager.php.

225 : array
226 {
227 $skill_logger = \ilLoggerFactory::getLogger("skll");
228 $skill_logger->debug("SkillUsageManager: getAllUsagesOfTemplate(" . $template_id . ")");
229
230 // get all trefs for template id
232
233 // get all usages of subtrees of template_id:tref
234 $cskill_ids = [];
235 foreach ($trefs as $tref) {
236 $cskill_ids[] = array("skill_id" => $template_id, "tref_id" => $tref);
237 $skill_logger->debug("SkillUsageManager: ... skill_id: " . $template_id . ", tref_id: " . $tref . ".");
238 }
239
240 $skill_logger->debug("SkillUsageManager: ... count cskill_ids: " . count($cskill_ids) . ".");
241
242 return $this->getAllUsagesInfoOfSubtrees($cskill_ids);
243 }
static getLogger(string $a_component_id)
Get component logger.

References ilSkillTemplateReference\_lookupTrefIdsForTemplateId(), and ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

◆ getAssignedObjectsForSkill()

ILIAS\Skill\Usage\SkillUsageManager::getAssignedObjectsForSkill ( int  $skill_id,
int  $tref_id 
)
Returns
int[]

Definition at line 274 of file class.SkillUsageManager.php.

274 : array
275 {
276 //$objects = $this->getAllUsagesInfoOfSubtree($a_skill_id, $a_tref_id);
277 $objects = $this->getUsages($skill_id, $tref_id);
278
279 return $objects;
280 }

◆ getAssignedObjectsForSkillProfile()

ILIAS\Skill\Usage\SkillUsageManager::getAssignedObjectsForSkillProfile ( int  $profile_id)
Returns
int[]

Definition at line 296 of file class.SkillUsageManager.php.

296 : array
297 {
298 $skills = $this->profile_manager->getSkillLevels($profile_id);
299 $objects = [];
300
301 // usages for skills within skill profile
302 foreach ($skills as $skill) {
303 $obj_usages = $this->getUsages($skill->getBaseSkillId(), $skill->getTrefId());
304 foreach ($obj_usages as $id) {
305 if (!in_array($id, $objects) && \ilObject::_hasUntrashedReference($id)) {
306 $objects[] = $id;
307 }
308 }
309 }
310
311 // courses and groups which are using skill profile
312 $roles = $this->profile_manager->getRoleAssignments($profile_id);
313 foreach ($roles as $role) {
314 if (($role->getObjType() == "crs" || $role->getObjType() == "grp")
315 && !in_array($role->getObjId(), $objects)) {
316 $obj_ref_id = \ilObject::_getAllReferences($role->getObjId());
317 $obj_ref_id = end($obj_ref_id);
318 if ($role->getId() === \ilParticipants::getDefaultMemberRole($obj_ref_id)) {
319 $objects[] = $role->getObjId();
320 }
321 }
322 }
323
324 return $objects;
325 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
static _getAllReferences(int $id)
get all reference ids for object ID
static getDefaultMemberRole(int $a_ref_id)

References $id, ilObject\_getAllReferences(), ilObject\_hasUntrashedReference(), and ilParticipants\getDefaultMemberRole().

+ Here is the call graph for this function:

◆ getAssignedObjectsForSkillTemplate()

ILIAS\Skill\Usage\SkillUsageManager::getAssignedObjectsForSkillTemplate ( int  $template_id)
Returns
string[]

Definition at line 285 of file class.SkillUsageManager.php.

285 : array
286 {
287 $usages = $this->getAllUsagesOfTemplate($template_id);
288 $obj_usages = array_column($usages, "gen");
289
290 return array_column(current(array_reverse($obj_usages)) ?: [], "key");
291 }

◆ getObjTypeString()

ILIAS\Skill\Usage\SkillUsageManager::getObjTypeString ( string  $type)

Definition at line 250 of file class.SkillUsageManager.php.

250 : string
251 {
252 switch ($type) {
254 case self::RESOURCE:
255 return $this->lng->txt("skmg_usage_obj_objects");
256
260 case self::SELF_EVAL:
261 return $this->lng->txt("skmg_usage_obj_users");
262
263 case self::PROFILE:
264 return $this->lng->txt("skmg_usage_obj_profiles");
265
266 default:
267 return $this->lng->txt("skmg_usage_type_info_" . $type);
268 }
269 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getTypeInfoString()

ILIAS\Skill\Usage\SkillUsageManager::getTypeInfoString ( string  $type)

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

245 : string
246 {
247 return $this->lng->txt("skmg_usage_type_info_" . $type);
248 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getUsageInfo()

static ILIAS\Skill\Usage\SkillUsageManager::getUsageInfo ( array  $a_cskill_ids)
static

Get title of an assigned item.

Parameters
array{skill_idint, tref_id: int}[] $a_cskill_ids array of common skill ids
Returns
array<string, array<string, array{key: string}[]>>

Implements ILIAS\Skill\Usage\SkillUsageInfo.

Definition at line 115 of file class.SkillUsageManager.php.

115 : array
116 {
117 $class = new self();
118 return $class->getUsageInfoGeneric(
119 $a_cskill_ids,
120 self::TYPE_GENERAL,
121 "skl_usage",
122 "obj_id"
123 );
124 }

◆ getUsageInfoGeneric()

ILIAS\Skill\Usage\SkillUsageManager::getUsageInfoGeneric ( array  $cskill_ids,
string  $usage_type,
string  $table,
string  $key_field,
string  $skill_field = "skill_id",
string  $tref_field = "tref_id" 
)

Get standard usage query.

Parameters
array{skill_idint, tref_id: int}[] $cskill_ids
Returns
array<string, array<string, array{key: string}[]>>

Definition at line 132 of file class.SkillUsageManager.php.

139 : array {
140 if (count($cskill_ids) === 0) {
141 return [];
142 }
143
144 $usages = $this->usage_repo->getUsageInfoGeneric(
145 $cskill_ids,
146 $usage_type,
147 $table,
148 $key_field,
149 $skill_field,
150 $tref_field
151 );
152
153 return $usages;
154 }

◆ getUsages()

ILIAS\Skill\Usage\SkillUsageManager::getUsages ( int  $skill_id,
int  $tref_id 
)
Returns
int[]

Definition at line 105 of file class.SkillUsageManager.php.

105 : array
106 {
107 $obj_ids = $this->usage_repo->getUsages($skill_id, $tref_id);
108
109 return $obj_ids;
110 }

◆ removeUsage()

ILIAS\Skill\Usage\SkillUsageManager::removeUsage ( int  $obj_id,
int  $skill_id,
int  $tref_id 
)

Definition at line 87 of file class.SkillUsageManager.php.

87 : void
88 {
89 $this->usage_repo->remove($obj_id, $skill_id, $tref_id);
90 }

◆ removeUsagesForSkill()

ILIAS\Skill\Usage\SkillUsageManager::removeUsagesForSkill ( int  $node_id,
bool  $is_referenece = false 
)

Definition at line 97 of file class.SkillUsageManager.php.

97 : void
98 {
99 $this->usage_repo->removeForSkill($node_id, $is_referenece);
100 }

◆ removeUsagesFromObject()

ILIAS\Skill\Usage\SkillUsageManager::removeUsagesFromObject ( int  $obj_id)

Definition at line 92 of file class.SkillUsageManager.php.

92 : void
93 {
94 $this->usage_repo->removeFromObject($obj_id);
95 }

Field Documentation

◆ $classes

array ILIAS\Skill\Usage\SkillUsageManager::$classes
protected
Initial value:
= [\ilBasicSkill::class, AssignedMaterialManager::class, SkillProfileManager::class,
SkillResourcesManager::class, SkillUsageManager::class]

Definition at line 58 of file class.SkillUsageManager.php.

◆ $lng

ilLanguage ILIAS\Skill\Usage\SkillUsageManager::$lng
protected

Definition at line 65 of file class.SkillUsageManager.php.

◆ $profile_manager

SkillProfileManager ILIAS\Skill\Usage\SkillUsageManager::$profile_manager
protected

◆ $tree_factory

SkillTreeFactory ILIAS\Skill\Usage\SkillUsageManager::$tree_factory
protected

◆ $tree_repo

ilSkillTreeRepository ILIAS\Skill\Usage\SkillUsageManager::$tree_repo
protected

◆ $usage_repo

SkillUsageDBRepository ILIAS\Skill\Usage\SkillUsageManager::$usage_repo
protected

◆ PERSONAL_SKILL

const ILIAS\Skill\Usage\SkillUsageManager::PERSONAL_SKILL = "pers"

◆ PROFILE

const ILIAS\Skill\Usage\SkillUsageManager::PROFILE = "prof"

◆ RESOURCE

const ILIAS\Skill\Usage\SkillUsageManager::RESOURCE = "res"

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

◆ SELF_EVAL

const ILIAS\Skill\Usage\SkillUsageManager::SELF_EVAL = "seval"

Definition at line 51 of file class.SkillUsageManager.php.

◆ TYPE_GENERAL

const ILIAS\Skill\Usage\SkillUsageManager::TYPE_GENERAL = "gen"

Definition at line 47 of file class.SkillUsageManager.php.

◆ USER_ASSIGNED

const ILIAS\Skill\Usage\SkillUsageManager::USER_ASSIGNED = "user"

Definition at line 48 of file class.SkillUsageManager.php.

◆ USER_MATERIAL

const ILIAS\Skill\Usage\SkillUsageManager::USER_MATERIAL = "mat"

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