ILIAS  release_7 Revision v7.30-3-g800a261c036
ilSkillUsage Class Reference

Skill usage. More...

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

Public Member Functions

 getAllUsagesInfo ($a_cskill_ids)
 Get all usages info. More...
 
 getAllUsagesInfoOfSubtree ($a_skill_id, $a_tref_id=0)
 Get all usages info of subtree. More...
 
 getAllUsagesInfoOfSubtrees ($a_cskill_ids)
 Get all usages info of subtree. More...
 
 getAllUsagesOfTemplate ($a_tempate_id)
 Get all usages of template. More...
 
 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 ($a_obj_id, $a_skill_id, $a_tref_id, $a_use=true)
 Set usage. More...
 
static removeUsagesFromObject ($a_obj_id)
 
static getUsages ($a_skill_id, $a_tref_id)
 Get usages. More...
 
static getUsageInfo ($a_cskill_ids, &$a_usages)
 Get usage info. More...
 
static getUsageInfoGeneric ( $a_cskill_ids, &$a_usages, $a_usage_type, $a_table, $a_key_field, $a_skill_field="skill_id", $a_tref_field="tref_id")
 Get standard usage query. More...
 
static getTypeInfoString ($a_type)
 Get type info string. More...
 
static getObjTypeString ($a_type)
 Get type info string. More...
 
static getUsageInfo ($a_cskill_ids, &$a_usages)
 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

 $classes = array("ilBasicSkill", "ilPersonalSkill", "ilSkillProfile", "ilSkillResources", "ilSkillUsage")
 

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 22 of file class.ilSkillUsage.php.

Member Function Documentation

◆ getAllUsagesInfo()

ilSkillUsage::getAllUsagesInfo (   $a_cskill_ids)

Get all usages info.

Parameters
arrayof common skill ids ("skill_id" => skill_id, "tref_id" => tref_id)
Returns
array usages

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

179 {
181
182 $usages = array();
183 foreach ($classes as $class) {
184 $class::getUsageInfo($a_cskill_ids, $usages);
185 }
186 return $usages;
187 }

References $classes.

Referenced by getAllUsagesInfoOfSubtree(), and getAllUsagesInfoOfSubtrees().

+ Here is the caller graph for this function:

◆ getAllUsagesInfoOfSubtree()

ilSkillUsage::getAllUsagesInfoOfSubtree (   $a_skill_id,
  $a_tref_id = 0 
)

Get all usages info of subtree.

Parameters
int$a_skill_idskill node id
int$a_tref_idtref id
Returns
array usages

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

197 {
198 // get nodes
199 $vtree = new ilVirtualSkillTree();
200 $nodes = $vtree->getSubTreeForCSkillId($a_skill_id . ":" . $a_tref_id);
201
202 return $this->getAllUsagesInfo($nodes);
203 }
getAllUsagesInfo($a_cskill_ids)
Get all usages info.

References getAllUsagesInfo().

+ Here is the call graph for this function:

◆ getAllUsagesInfoOfSubtrees()

ilSkillUsage::getAllUsagesInfoOfSubtrees (   $a_cskill_ids)

Get all usages info of subtree.

Parameters
array$a_cskill_idsarray of common skill ids ("skill_id" => skill_id, "tref_id" => tref_id)
Returns
array usages

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

212 {
213 // get nodes
214 $vtree = new ilVirtualSkillTree();
215 $allnodes = array();
216 foreach ($a_cskill_ids as $s) {
217 $nodes = $vtree->getSubTreeForCSkillId($s["skill_id"] . ":" . $s["tref_id"]);
218 foreach ($nodes as $n) {
219 $allnodes[] = $n;
220 }
221 }
222
223 return $this->getAllUsagesInfo($allnodes);
224 }
$n
Definition: RandomTest.php:85

References $n, and getAllUsagesInfo().

Referenced by getAllUsagesOfTemplate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllUsagesOfTemplate()

ilSkillUsage::getAllUsagesOfTemplate (   $a_tempate_id)

Get all usages of template.

Parameters
int$a_tempate_idtemplate
Returns
array usages array

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

233 {
234 $skill_logger = ilLoggerFactory::getLogger('skll');
235 $skill_logger->debug("ilSkillUsage: getAllUsagesOfTemplate(" . $a_tempate_id . ")");
236
237 // get all trefs for template id
239
240 // get all usages of subtrees of template_id:tref
241 $cskill_ids = array();
242 foreach ($trefs as $tref) {
243 $cskill_ids[] = array("skill_id" => $a_tempate_id, "tref_id" => $tref);
244 $skill_logger->debug("ilSkillUsage: ... skill_id: " . $a_tempate_id . ", tref_id: " . $tref . ".");
245 }
246
247 $skill_logger->debug("ilSkillUsage: ... count cskill_ids: " . count($cskill_ids) . ".");
248
249 return $this->getAllUsagesInfoOfSubtrees($cskill_ids);
250 }
static getLogger($a_component_id)
Get component logger.
static _lookupTrefIdsForTemplateId($a_tid)
Get all tref ids for a template id.
getAllUsagesInfoOfSubtrees($a_cskill_ids)
Get all usages info of subtree.

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

Referenced by getAssignedObjectsForSkillTemplate().

+ 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 
)
Parameters
int$a_skill_id
int$a_tref_id
Returns
array

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

305 : array
306 {
307 //$objects = $this->getAllUsagesInfoOfSubtree($a_skill_id, $a_tref_id);
308 $objects = self::getUsages($a_skill_id, $a_tref_id);
309
310 return $objects;
311 }
static getUsages($a_skill_id, $a_tref_id)
Get usages.

References getUsages().

+ Here is the call graph for this function:

◆ getAssignedObjectsForSkillProfile()

ilSkillUsage::getAssignedObjectsForSkillProfile ( int  $a_profile_id)
Parameters
int$a_profile_id
Returns
array

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

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

References getUsages().

+ Here is the call graph for this function:

◆ getAssignedObjectsForSkillTemplate()

ilSkillUsage::getAssignedObjectsForSkillTemplate ( int  $a_template_id)
Parameters
int$a_template_id
Returns
array

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

317 : array
318 {
319 $usages = $this->getAllUsagesOfTemplate($a_template_id);
320 $obj_usages = array_column($usages, "gen");
321 foreach ($obj_usages as $obj) {
322 $objects["objects"] = array_column($obj, "key");
323 }
324
325 return $objects["objects"];
326 }
getAllUsagesOfTemplate($a_tempate_id)
Get all usages of template.

References getAllUsagesOfTemplate().

+ Here is the call graph for this function:

◆ getObjTypeString()

static ilSkillUsage::getObjTypeString (   $a_type)
static

Get type info string.

Parameters

return

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

274 {
275 global $DIC;
276
277 $lng = $DIC->language();
278
279 switch ($a_type) {
281 case self::RESOURCE:
282 return $lng->txt("skmg_usage_obj_objects");
283 break;
284
288 case self::SELF_EVAL:
289 return $lng->txt("skmg_usage_obj_users");
290 break;
291
292 case self::PROFILE:
293 return $lng->txt("skmg_usage_obj_profiles");
294 break;
295 }
296
297 return $lng->txt("skmg_usage_type_info_" . $a_type);
298 }
global $DIC
Definition: goto.php:24
$lng

References $DIC, $lng, PERSONAL_SKILL, PROFILE, RESOURCE, SELF_EVAL, TYPE_GENERAL, USER_ASSIGNED, and USER_MATERIAL.

Referenced by ilSkillUsageTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ getTypeInfoString()

static ilSkillUsage::getTypeInfoString (   $a_type)
static

Get type info string.

Parameters
string$a_typeusage type
Returns
string lang string

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

259 {
260 global $DIC;
261
262 $lng = $DIC->language();
263
264 return $lng->txt("skmg_usage_type_info_" . $a_type);
265 }

References $DIC, and $lng.

Referenced by ilSkillUsageTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ getUsageInfo()

static ilSkillUsage::getUsageInfo (   $a_cskill_ids,
$a_usages 
)
static

Get usage info.

Parameters
array$a_cskill_idsskill ids
array$a_usagesusages array

Implements ilSkillUsageInfo.

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

118 {
119 global $DIC;
120
121 $ilDB = $DIC->database();
122
124 $a_cskill_ids,
125 $a_usages,
127 "skl_usage",
128 "obj_id"
129 );
130 }
static getUsageInfoGeneric( $a_cskill_ids, &$a_usages, $a_usage_type, $a_table, $a_key_field, $a_skill_field="skill_id", $a_tref_field="tref_id")
Get standard usage query.
global $ilDB

References $DIC, $ilDB, getUsageInfoGeneric(), and TYPE_GENERAL.

+ Here is the call graph for this function:

◆ getUsageInfoGeneric()

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

Get standard usage query.

Parameters
array$a_cskill_idsskill ids
array$a_usagesusages array

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

146 {
147 global $DIC;
148
149 $ilDB = $DIC->database();
150
151 if (count($a_cskill_ids) == 0) {
152 return;
153 }
154
155 $w = "WHERE";
156 $q = "SELECT " . $a_key_field . ", " . $a_skill_field . ", " . $a_tref_field . " FROM " . $a_table . " ";
157 foreach ($a_cskill_ids as $sk) {
158 $q .= $w . " (" . $a_skill_field . " = " . $ilDB->quote($sk["skill_id"], "integer") .
159 " AND " . $a_tref_field . " = " . $ilDB->quote($sk["tref_id"], "integer") . ") ";
160 $w = "OR";
161 }
162 $q .= " GROUP BY " . $a_key_field . ", " . $a_skill_field . ", " . $a_tref_field;
163
164 $set = $ilDB->query($q);
165 while ($rec = $ilDB->fetchAssoc($set)) {
166 $a_usages[$rec[$a_skill_field] . ":" . $rec[$a_tref_field]][$a_usage_type][] =
167 array("key" => $rec[$a_key_field]);
168 }
169 }

References $DIC, and $ilDB.

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

+ Here is the caller graph for this function:

◆ getUsages()

static ilSkillUsage::getUsages (   $a_skill_id,
  $a_tref_id 
)
static

Get usages.

Parameters
int$a_skill_idskill id
int$a_tref_idtref id
Returns
array of int object ids

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

93 {
94 global $DIC;
95
96 $ilDB = $DIC->database();
97
98 $set = $ilDB->query(
99 "SELECT obj_id FROM skl_usage " .
100 " WHERE skill_id = " . $ilDB->quote($a_skill_id, "integer") .
101 " AND tref_id = " . $ilDB->quote($a_tref_id, "integer")
102 );
103 $obj_ids = array();
104 while ($rec = $ilDB->fetchAssoc($set)) {
105 $obj_ids[] = $rec["obj_id"];
106 }
107
108 return $obj_ids;
109 }

References $DIC, and $ilDB.

Referenced by getAssignedObjectsForSkill(), and getAssignedObjectsForSkillProfile().

+ Here is the caller graph for this function:

◆ removeUsagesFromObject()

static ilSkillUsage::removeUsagesFromObject (   $a_obj_id)
static

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

74 {
75 global $DIC;
76
77 $ilDB = $DIC->database();
78
79 $ilDB->manipulate(
80 $q = "DELETE FROM skl_usage WHERE " .
81 " obj_id = " . $ilDB->quote($a_obj_id, "integer")
82 );
83 }

References $DIC, and $ilDB.

Referenced by ilSkillObjDeletionHandler\processDeletion().

+ Here is the caller graph for this function:

◆ setUsage()

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

Set usage.

Parameters
int$a_obj_idobject id
int$a_skill_idskill id
int$a_tref_idtref id
bool$a_usein use true/false

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

47 {
48 global $DIC;
49
50 $ilDB = $DIC->database();
51
52 if ($a_use) {
53 $ilDB->replace(
54 "skl_usage",
55 array(
56 "obj_id" => array("integer", $a_obj_id),
57 "skill_id" => array("integer", $a_skill_id),
58 "tref_id" => array("integer", $a_tref_id)
59 ),
60 array()
61 );
62 } else {
63 $ilDB->manipulate(
64 $q = "DELETE FROM skl_usage WHERE " .
65 " obj_id = " . $ilDB->quote($a_obj_id, "integer") .
66 " AND skill_id = " . $ilDB->quote($a_skill_id, "integer") .
67 " AND tref_id = " . $ilDB->quote($a_tref_id, "integer")
68 );
69 //echo $q; exit;
70 }
71 }

References $DIC, and $ilDB.

Referenced by ilSurveySkill\addQuestionSkillAssignment(), ilContSkillAdminGUI\removeSelectedSkill(), ilSurveySkill\removeUsagesOfSkills(), and ilContSkillAdminGUI\saveSelectedSkill().

+ Here is the caller graph for this function:

Field Documentation

◆ $classes

ilSkillUsage::$classes = array("ilBasicSkill", "ilPersonalSkill", "ilSkillProfile", "ilSkillResources", "ilSkillUsage")
protected

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

Referenced by getAllUsagesInfo().

◆ PERSONAL_SKILL

const ilSkillUsage::PERSONAL_SKILL = "pers"

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

Referenced by getObjTypeString(), and ilPersonalSkill\getUsageInfo().

◆ PROFILE

const ilSkillUsage::PROFILE = "prof"

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

Referenced by getObjTypeString(), and ilSkillProfile\getUsageInfo().

◆ RESOURCE

const ilSkillUsage::RESOURCE = "res"

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

Referenced by getObjTypeString(), and ilSkillResources\getUsageInfo().

◆ SELF_EVAL

const ilSkillUsage::SELF_EVAL = "seval"

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

Referenced by getObjTypeString(), and ilPersonalSkill\getUsageInfo().

◆ TYPE_GENERAL

const ilSkillUsage::TYPE_GENERAL = "gen"

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

Referenced by getObjTypeString(), and getUsageInfo().

◆ USER_ASSIGNED

const ilSkillUsage::USER_ASSIGNED = "user"

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

Referenced by getObjTypeString(), and ilBasicSkill\getUsageInfo().

◆ USER_MATERIAL

const ilSkillUsage::USER_MATERIAL = "mat"

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

Referenced by getObjTypeString(), and ilPersonalSkill\getUsageInfo().


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