ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSkillUsage Class Reference

Skill usage. More...

+ Inheritance diagram for ilSkillUsage:
+ Collaboration diagram for ilSkillUsage:

Public Member Functions

 __construct ()
 
 getAllUsagesInfo (array $a_cskill_ids)
 
 getAllUsagesInfoOfTrees (array $a_tree_ids)
 
 getAllUsagesInfoOfSubtree (int $a_skill_id, int $a_tref_id=0)
 
 getAllUsagesInfoOfSubtrees (array $a_cskill_ids)
 
 getAllUsagesOfTemplate (int $a_template_id)
 
 getAssignedObjectsForSkill (int $a_skill_id, int $a_tref_id)
 
 getAssignedObjectsForSkillTemplate (int $a_template_id)
 
 getAssignedObjectsForSkillProfile (int $a_profile_id)
 

Static Public Member Functions

static setUsage (int $a_obj_id, int $a_skill_id, int $a_tref_id, bool $a_use=true)
 
static removeUsagesFromObject (int $a_obj_id)
 
static getUsages (int $a_skill_id, int $a_tref_id)
 
static getUsageInfo (array $a_cskill_ids)
 
static getUsageInfoGeneric (array $a_cskill_ids, string $a_usage_type, string $a_table, string $a_key_field, string $a_skill_field="skill_id", string $a_tref_field="tref_id")
 Get standard usage query. More...
 
static getTypeInfoString (string $a_type)
 
static getObjTypeString (string $a_type)
 

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
 
ilSkillTreeRepository $tree_repo
 
SkillInternalFactoryService $tree_factory
 
SkillProfileManager $profile_manager
 

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 alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

Definition at line 41 of file class.ilSkillUsage.php.

Constructor & Destructor Documentation

◆ __construct()

ilSkillUsage::__construct ( )

Definition at line 61 of file class.ilSkillUsage.php.

References $DIC.

62  {
63  global $DIC;
64 
65  $this->tree_repo = $DIC->skills()->internal()->repo()->getTreeRepo();
66  $this->tree_factory = $DIC->skills()->internal()->factory();
67  $this->profile_manager = $DIC->skills()->internal()->manager()->getProfileManager();
68  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ getAllUsagesInfo()

ilSkillUsage::getAllUsagesInfo ( array  $a_cskill_ids)
Parameters
array{skill_idint, tref_id: int}[] $a_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 191 of file class.ilSkillUsage.php.

References $classes.

Referenced by getAllUsagesInfoOfSubtree(), getAllUsagesInfoOfSubtrees(), and getAllUsagesInfoOfTrees().

191  : array
192  {
194 
195  $usages = [];
196  foreach ($classes as $class) {
197  $usages = array_merge_recursive($usages, $class::getUsageInfo($a_cskill_ids));
198  }
199  return $usages;
200  }
+ Here is the caller graph for this function:

◆ getAllUsagesInfoOfSubtree()

ilSkillUsage::getAllUsagesInfoOfSubtree ( int  $a_skill_id,
int  $a_tref_id = 0 
)
Returns
array<string, array<string, array{key: string}[]>>

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

References getAllUsagesInfo().

225  : array
226  {
227  // get nodes
228  $vtree = $this->tree_repo->getVirtualTreeForNodeId($a_skill_id);
229  $nodes = $vtree->getSubTreeForCSkillId($a_skill_id . ":" . $a_tref_id);
230 
231  return $this->getAllUsagesInfo($nodes);
232  }
getAllUsagesInfo(array $a_cskill_ids)
+ Here is the call graph for this function:

◆ getAllUsagesInfoOfSubtrees()

ilSkillUsage::getAllUsagesInfoOfSubtrees ( array  $a_cskill_ids)
Parameters
array$a_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 238 of file class.ilSkillUsage.php.

References getAllUsagesInfo().

Referenced by getAllUsagesOfTemplate().

238  : array
239  {
240  // get nodes
241  $allnodes = [];
242  foreach ($a_cskill_ids as $s) {
243  $vtree = $this->tree_repo->getVirtualTreeForNodeId($s["skill_id"]);
244  $nodes = $vtree->getSubTreeForCSkillId($s["skill_id"] . ":" . $s["tref_id"]);
245  foreach ($nodes as $n) {
246  $allnodes[] = $n;
247  }
248  }
249 
250  return $this->getAllUsagesInfo($allnodes);
251  }
getAllUsagesInfo(array $a_cskill_ids)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllUsagesInfoOfTrees()

ilSkillUsage::getAllUsagesInfoOfTrees ( array  $a_tree_ids)
Parameters
array$a_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 206 of file class.ilSkillUsage.php.

References getAllUsagesInfo().

206  : array
207  {
208  // get nodes
209 
210  $allnodes = [];
211  foreach ($a_tree_ids as $t) {
212  $vtree = $this->tree_factory->tree()->getGlobalVirtualTree();
213  $nodes = $vtree->getSubTreeForTreeId($t);
214  foreach ($nodes as $n) {
215  $allnodes[] = $n;
216  }
217  }
218 
219  return $this->getAllUsagesInfo($allnodes);
220  }
getAllUsagesInfo(array $a_cskill_ids)
+ Here is the call graph for this function:

◆ getAllUsagesOfTemplate()

ilSkillUsage::getAllUsagesOfTemplate ( int  $a_template_id)
Returns
array<string, array<string, array{key: string}[]>>

Definition at line 256 of file class.ilSkillUsage.php.

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

Referenced by getAssignedObjectsForSkillTemplate().

256  : array
257  {
258  $skill_logger = ilLoggerFactory::getLogger('skll');
259  $skill_logger->debug("ilSkillUsage: getAllUsagesOfTemplate(" . $a_template_id . ")");
260 
261  // get all trefs for template id
263 
264  // get all usages of subtrees of template_id:tref
265  $cskill_ids = [];
266  foreach ($trefs as $tref) {
267  $cskill_ids[] = array("skill_id" => $a_template_id, "tref_id" => $tref);
268  $skill_logger->debug("ilSkillUsage: ... skill_id: " . $a_template_id . ", tref_id: " . $tref . ".");
269  }
270 
271  $skill_logger->debug("ilSkillUsage: ... count cskill_ids: " . count($cskill_ids) . ".");
272 
273  return $this->getAllUsagesInfoOfSubtrees($cskill_ids);
274  }
getAllUsagesInfoOfSubtrees(array $a_cskill_ids)
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()

ilSkillUsage::getAssignedObjectsForSkill ( int  $a_skill_id,
int  $a_tref_id 
)
Returns
int[]

Definition at line 313 of file class.ilSkillUsage.php.

313  : array
314  {
315  //$objects = $this->getAllUsagesInfoOfSubtree($a_skill_id, $a_tref_id);
316  $objects = self::getUsages($a_skill_id, $a_tref_id);
317 
318  return $objects;
319  }

◆ getAssignedObjectsForSkillProfile()

ilSkillUsage::getAssignedObjectsForSkillProfile ( int  $a_profile_id)
Returns
int[]

Definition at line 335 of file class.ilSkillUsage.php.

References $id.

335  : array
336  {
337  $profile = $this->profile_manager->getById($a_profile_id);
338  $skills = $profile->getSkillLevels();
339  $objects = [];
340 
341  // usages for skills within skill profile
342  foreach ($skills as $skill) {
343  $obj_usages = self::getUsages($skill["base_skill_id"], $skill["tref_id"]);
344  foreach ($obj_usages as $id) {
345  if (!in_array($id, $objects)) {
346  $objects[] = $id;
347  }
348  }
349  }
350 
351  // courses and groups which are using skill profile
352  $roles = $this->profile_manager->getAssignedRoles($profile->getId());
353  foreach ($roles as $role) {
354  if (($role["object_type"] == "crs" || $role["object_type"] == "grp")
355  && !in_array($role["object_id"], $objects)) {
356  $objects[] = $role["object_id"];
357  }
358  }
359 
360  return $objects;
361  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ getAssignedObjectsForSkillTemplate()

ilSkillUsage::getAssignedObjectsForSkillTemplate ( int  $a_template_id)
Returns
string[]

Definition at line 324 of file class.ilSkillUsage.php.

References getAllUsagesOfTemplate().

324  : array
325  {
326  $usages = $this->getAllUsagesOfTemplate($a_template_id);
327  $obj_usages = array_column($usages, "gen");
328 
329  return array_column(current(array_reverse($obj_usages)) ?: [], 'key');
330  }
getAllUsagesOfTemplate(int $a_template_id)
+ Here is the call graph for this function:

◆ getObjTypeString()

static ilSkillUsage::getObjTypeString ( string  $a_type)
static

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

References $DIC, and $lng.

Referenced by ilSkillUsageTableGUI\fillRow().

285  : string
286  {
287  global $DIC;
288 
289  $lng = $DIC->language();
290 
291  switch ($a_type) {
292  case self::TYPE_GENERAL:
293  case self::RESOURCE:
294  return $lng->txt("skmg_usage_obj_objects");
295 
296  case self::USER_ASSIGNED:
297  case self::PERSONAL_SKILL:
298  case self::USER_MATERIAL:
299  case self::SELF_EVAL:
300  return $lng->txt("skmg_usage_obj_users");
301 
302  case self::PROFILE:
303  return $lng->txt("skmg_usage_obj_profiles");
304 
305  default:
306  return $lng->txt("skmg_usage_type_info_" . $a_type);
307  }
308  }
$lng
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getTypeInfoString()

static ilSkillUsage::getTypeInfoString ( string  $a_type)
static

Definition at line 276 of file class.ilSkillUsage.php.

References $DIC, and $lng.

Referenced by ilSkillUsageTableGUI\fillRow().

276  : string
277  {
278  global $DIC;
279 
280  $lng = $DIC->language();
281 
282  return $lng->txt("skmg_usage_type_info_" . $a_type);
283  }
$lng
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getUsageInfo()

static ilSkillUsage::getUsageInfo ( array  $a_cskill_ids)
static
Parameters
array{skill_idint, tref_id: int}[] $a_cskill_ids
Returns
array<string, array<string, array{key: string}[]>>

Implements ilSkillUsageInfo.

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

References TYPE_GENERAL.

135  : array
136  {
137  return self::getUsageInfoGeneric(
138  $a_cskill_ids,
140  "skl_usage",
141  "obj_id"
142  );
143  }

◆ getUsageInfoGeneric()

static ilSkillUsage::getUsageInfoGeneric ( array  $a_cskill_ids,
string  $a_usage_type,
string  $a_table,
string  $a_key_field,
string  $a_skill_field = "skill_id",
string  $a_tref_field = "tref_id" 
)
static

Get standard usage query.

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

Definition at line 151 of file class.ilSkillUsage.php.

References $DIC, and $ilDB.

Referenced by ilSkillResources\getUsageInfo(), ilPersonalSkill\getUsageInfo(), and ilBasicSkill\getUsageInfo().

158  : array {
159  global $DIC;
160 
161  $a_usages = [];
162 
163  $ilDB = $DIC->database();
164 
165  if (count($a_cskill_ids) == 0) {
166  return [];
167  }
168 
169  $w = "WHERE";
170  $q = "SELECT " . $a_key_field . ", " . $a_skill_field . ", " . $a_tref_field . " FROM " . $a_table . " ";
171  foreach ($a_cskill_ids as $sk) {
172  $q .= $w . " (" . $a_skill_field . " = " . $ilDB->quote($sk["skill_id"], "integer") .
173  " AND " . $a_tref_field . " = " . $ilDB->quote($sk["tref_id"], "integer") . ") ";
174  $w = "OR";
175  }
176  $q .= " GROUP BY " . $a_key_field . ", " . $a_skill_field . ", " . $a_tref_field;
177 
178  $set = $ilDB->query($q);
179  while ($rec = $ilDB->fetchAssoc($set)) {
180  $a_usages[$rec[$a_skill_field] . ":" . $rec[$a_tref_field]][$a_usage_type][] =
181  array("key" => $rec[$a_key_field]);
182  }
183 
184  return $a_usages;
185  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getUsages()

static ilSkillUsage::getUsages ( int  $a_skill_id,
int  $a_tref_id 
)
static
Returns
int[]

Definition at line 111 of file class.ilSkillUsage.php.

References $DIC, $ilDB, and ILIAS\Repository\int().

111  : array
112  {
113  global $DIC;
114 
115  $ilDB = $DIC->database();
116 
117  $set = $ilDB->query(
118  "SELECT obj_id FROM skl_usage " .
119  " WHERE skill_id = " . $ilDB->quote($a_skill_id, "integer") .
120  " AND tref_id = " . $ilDB->quote($a_tref_id, "integer")
121  );
122  $obj_ids = [];
123  while ($rec = $ilDB->fetchAssoc($set)) {
124  $obj_ids[] = (int) $rec["obj_id"];
125  }
126 
127  return $obj_ids;
128  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ removeUsagesFromObject()

static ilSkillUsage::removeUsagesFromObject ( int  $a_obj_id)
static

Definition at line 96 of file class.ilSkillUsage.php.

References $DIC, and $ilDB.

Referenced by ilSkillObjDeletionHandler\processDeletion().

96  : void
97  {
98  global $DIC;
99 
100  $ilDB = $DIC->database();
101 
102  $ilDB->manipulate(
103  $q = "DELETE FROM skl_usage WHERE " .
104  " obj_id = " . $ilDB->quote($a_obj_id, "integer")
105  );
106  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ setUsage()

static ilSkillUsage::setUsage ( int  $a_obj_id,
int  $a_skill_id,
int  $a_tref_id,
bool  $a_use = true 
)
static

Definition at line 70 of file class.ilSkillUsage.php.

References $DIC, and $ilDB.

Referenced by ilSurveySkill\addQuestionSkillAssignment(), assQuestion\delete(), assQuestion\duplicateSkillAssignments(), ilAssQuestionSkillAssignmentImporter\import(), ilContSkillAdminGUI\removeSelectedSkill(), ilSurveySkill\removeUsagesOfSkills(), ilContSkillAdminGUI\saveSelectedSkill(), ilAssQuestionSkillAssignmentsGUI\saveSkillPointsCmd(), ilAssQuestionSkillAssignmentsGUI\saveSkillQuestionAssignmentPropertiesFormCmd(), assQuestion\syncSkillAssignments(), and ilAssQuestionSkillAssignmentsGUI\updateSkillQuestionAssignmentsCmd().

70  : void
71  {
72  global $DIC;
73 
74  $ilDB = $DIC->database();
75 
76  if ($a_use) {
77  $ilDB->replace(
78  "skl_usage",
79  array(
80  "obj_id" => array("integer", $a_obj_id),
81  "skill_id" => array("integer", $a_skill_id),
82  "tref_id" => array("integer", $a_tref_id)
83  ),
84  []
85  );
86  } else {
87  $ilDB->manipulate(
88  $q = "DELETE FROM skl_usage WHERE " .
89  " obj_id = " . $ilDB->quote($a_obj_id, "integer") .
90  " AND skill_id = " . $ilDB->quote($a_skill_id, "integer") .
91  " AND tref_id = " . $ilDB->quote($a_tref_id, "integer")
92  );
93  }
94  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

Field Documentation

◆ $classes

array ilSkillUsage::$classes
protected
Initial value:
= [ilBasicSkill::class, ilPersonalSkill::class, SkillProfile::class,
ilSkillResources::class, ilSkillUsage::class]

Definition at line 54 of file class.ilSkillUsage.php.

Referenced by getAllUsagesInfo().

◆ $profile_manager

SkillProfileManager ilSkillUsage::$profile_manager
protected

Definition at line 59 of file class.ilSkillUsage.php.

◆ $tree_factory

SkillInternalFactoryService ilSkillUsage::$tree_factory
protected

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

◆ $tree_repo

ilSkillTreeRepository ilSkillUsage::$tree_repo
protected

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

◆ PERSONAL_SKILL

const ilSkillUsage::PERSONAL_SKILL = "pers"

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

Referenced by ilPersonalSkill\getUsageInfo().

◆ PROFILE

const ilSkillUsage::PROFILE = "prof"

◆ RESOURCE

const ilSkillUsage::RESOURCE = "res"

Definition at line 49 of file class.ilSkillUsage.php.

Referenced by ilSkillResources\getUsageInfo().

◆ SELF_EVAL

const ilSkillUsage::SELF_EVAL = "seval"

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

◆ TYPE_GENERAL

const ilSkillUsage::TYPE_GENERAL = "gen"

Definition at line 43 of file class.ilSkillUsage.php.

Referenced by getUsageInfo().

◆ USER_ASSIGNED

const ilSkillUsage::USER_ASSIGNED = "user"

Definition at line 44 of file class.ilSkillUsage.php.

Referenced by ilBasicSkill\getUsageInfo().

◆ USER_MATERIAL

const ilSkillUsage::USER_MATERIAL = "mat"

Definition at line 46 of file class.ilSkillUsage.php.

Referenced by ilPersonalSkill\getUsageInfo().


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