ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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...
 

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 46 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 68 of file class.SkillUsageManager.php.

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().

73  {
74  global $DIC;
75 
76  $this->usage_repo = ($usage_repo) ?: $DIC->skills()->internal()->repo()->getUsageRepo();
77  $this->tree_factory = ($tree_factory) ?: $DIC->skills()->internal()->factory()->tree();
78  $this->tree_repo = ($tree_repo) ?: $DIC->skills()->internal()->repo()->getTreeRepo();
79  $this->profile_manager = ($profile_manager) ?: $DIC->skills()->internal()->manager()->getProfileManager();
80  $this->lng = $DIC->language();
81  }
global $DIC
Definition: shib_login.php:25
+ 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 83 of file class.SkillUsageManager.php.

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

◆ 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 161 of file class.SkillUsageManager.php.

References ILIAS\Skill\Usage\SkillUsageManager\$classes.

Referenced by ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesInfoOfSubtree(), ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesInfoOfSubtrees(), and ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesInfoOfTrees().

161  : array
162  {
164 
165  $usages = [];
166  foreach ($classes as $class) {
167  $usages = array_merge_recursive($usages, $class::getUsageInfo($cskill_ids));
168  }
169  return $usages;
170  }
+ Here is the caller graph for this function:

◆ getAllUsagesInfoOfSubtree()

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

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

References ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesInfo().

195  : array
196  {
197  // get nodes
198  $vtree = $this->tree_repo->getVirtualTreeForNodeId($skill_id);
199  $nodes = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id);
200 
201  return $this->getAllUsagesInfo($nodes);
202  }
+ Here is the call graph for this function:

◆ 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 208 of file class.SkillUsageManager.php.

References ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesInfo().

Referenced by ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesOfTemplate().

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

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

References ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesInfo().

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

◆ getAllUsagesOfTemplate()

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

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

References ilSkillTemplateReference\_lookupTrefIdsForTemplateId(), ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesInfoOfSubtrees(), and ilLoggerFactory\getLogger().

Referenced by ILIAS\Skill\Usage\SkillUsageManager\getAssignedObjectsForSkillTemplate().

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

◆ getAssignedObjectsForSkill()

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

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

References ILIAS\Skill\Usage\SkillUsageManager\getUsages().

275  : array
276  {
277  //$objects = $this->getAllUsagesInfoOfSubtree($a_skill_id, $a_tref_id);
278  $objects = $this->getUsages($skill_id, $tref_id);
279 
280  return $objects;
281  }
+ Here is the call graph for this function:

◆ getAssignedObjectsForSkillProfile()

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

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

References $id, ilObject\_getAllReferences(), ilObject\_hasUntrashedReference(), ilParticipants\getDefaultMemberRole(), and ILIAS\Skill\Usage\SkillUsageManager\getUsages().

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

◆ getAssignedObjectsForSkillTemplate()

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

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

References ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesOfTemplate().

286  : array
287  {
288  $usages = $this->getAllUsagesOfTemplate($template_id);
289  $obj_usages = array_column($usages, "gen");
290 
291  return array_column(current(array_reverse($obj_usages)) ?: [], "key");
292  }
+ Here is the call graph for this function:

◆ getObjTypeString()

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

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

References ILIAS\Repository\lng().

251  : string
252  {
253  switch ($type) {
254  case self::TYPE_GENERAL:
255  case self::RESOURCE:
256  return $this->lng->txt("skmg_usage_obj_objects");
257 
258  case self::USER_ASSIGNED:
259  case self::PERSONAL_SKILL:
260  case self::USER_MATERIAL:
261  case self::SELF_EVAL:
262  return $this->lng->txt("skmg_usage_obj_users");
263 
264  case self::PROFILE:
265  return $this->lng->txt("skmg_usage_obj_profiles");
266 
267  default:
268  return $this->lng->txt("skmg_usage_type_info_" . $type);
269  }
270  }
+ Here is the call graph for this function:

◆ getTypeInfoString()

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

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

References ILIAS\Repository\lng().

246  : string
247  {
248  return $this->lng->txt("skmg_usage_type_info_" . $type);
249  }
+ 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 116 of file class.SkillUsageManager.php.

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

◆ 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 133 of file class.SkillUsageManager.php.

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

◆ getUsages()

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

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

Referenced by ILIAS\Skill\Usage\SkillUsageManager\getAssignedObjectsForSkill(), and ILIAS\Skill\Usage\SkillUsageManager\getAssignedObjectsForSkillProfile().

106  : array
107  {
108  $obj_ids = $this->usage_repo->getUsages($skill_id, $tref_id);
109 
110  return $obj_ids;
111  }
+ Here is the caller graph for this function:

◆ removeUsage()

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

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

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

◆ removeUsagesForSkill()

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

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

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

◆ removeUsagesFromObject()

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

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

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

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 59 of file class.SkillUsageManager.php.

Referenced by ILIAS\Skill\Usage\SkillUsageManager\getAllUsagesInfo().

◆ $lng

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

Definition at line 66 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"

◆ SELF_EVAL

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

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

◆ TYPE_GENERAL

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

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

◆ USER_ASSIGNED

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

Definition at line 49 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: