ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 

Static Public Member Functions

static setUsage ($a_obj_id, $a_skill_id, $a_tref_id, $a_use=true)
 Set usage. More...
 
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
Version
$Id$

Definition at line 26 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 155 of file class.ilSkillUsage.php.

156 {
158
159 $usages = array();
160 foreach ($classes as $class)
161 {
162 // make static call
163 include_once("./Services/Skill/classes/class.".$class.".php");
164 //call_user_func($class.'::getUsageInfo', $a_cskill_ids, $usages);
165 $class::getUsageInfo($a_cskill_ids, $usages);
166 }
167 return $usages;
168 }

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

178 {
179 // get nodes
180 include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
181 $vtree = new ilVirtualSkillTree();
182 $nodes = $vtree->getSubTreeForCSkillId($a_skill_id.":".$a_tref_id);
183
184 return $this->getAllUsagesInfo($nodes);
185 }
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 193 of file class.ilSkillUsage.php.

194 {
195 // get nodes
196 include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
197 $vtree = new ilVirtualSkillTree();
198 $allnodes = array();
199 foreach ($a_cskill_ids as $s)
200 {
201 $nodes = $vtree->getSubTreeForCSkillId($s["skill_id"].":".$s["tref_id"]);
202 foreach ($nodes as $n)
203 {
204 $allnodes[] = $n;
205 }
206 }
207
208 return $this->getAllUsagesInfo($allnodes);
209 }
$n
Definition: RandomTest.php:80

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

218 {
219 $skill_logger = ilLoggerFactory::getLogger('skll');
220 $skill_logger->debug("ilSkillUsage: getAllUsagesOfTemplate(".$a_tempate_id.")");
221
222 // get all trefs for template id
223 include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
225
226 // get all usages of subtrees of template_id:tref
227 $cskill_ids = array();
228 foreach ($trefs as $tref)
229 {
230 $cskill_ids[] = array("skill_id" => $a_tempate_id, "tref_id" => $tref);
231 $skill_logger->debug("ilSkillUsage: ... skill_id: ".$a_tempate_id.", tref_id: ".$tref.".");
232 }
233
234 $skill_logger->debug("ilSkillUsage: ... count cskill_ids: ".count($cskill_ids).".");
235
236 return $this->getAllUsagesInfoOfSubtrees($cskill_ids);
237 }
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().

+ Here is the call graph for this function:

◆ getObjTypeString()

static ilSkillUsage::getObjTypeString (   $a_type)
static

Get type info string.

Parameters

return

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

259 {
260 global $lng;
261
262 switch ($a_type)
263 {
265 case self::RESOURCE:
266 return $lng->txt("skmg_usage_obj_objects");
267 break;
268
272 case self::SELF_EVAL:
273 return $lng->txt("skmg_usage_obj_users");
274 break;
275
276 case self::PROFILE:
277 return $lng->txt("skmg_usage_obj_profiles");
278 break;
279 }
280
281 return $lng->txt("skmg_usage_type_info_".$a_type);
282 }
global $lng
Definition: privfeed.php:40

References $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 245 of file class.ilSkillUsage.php.

246 {
247 global $lng;
248
249 return $lng->txt("skmg_usage_type_info_".$a_type);
250 }

References $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 106 of file class.ilSkillUsage.php.

107 {
108 global $ilDB;
109
111 "skl_usage", "obj_id");
112 }
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 $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 120 of file class.ilSkillUsage.php.

122 {
123 global $ilDB;
124
125 if (count($a_cskill_ids) == 0)
126 {
127 return;
128 }
129
130 $w = "WHERE";
131 $q = "SELECT ".$a_key_field.", ".$a_skill_field.", ".$a_tref_field." FROM ".$a_table." ";
132 foreach ($a_cskill_ids as $sk)
133 {
134 $q.= $w." (".$a_skill_field." = ".$ilDB->quote($sk["skill_id"], "integer").
135 " AND ".$a_tref_field." = ".$ilDB->quote($sk["tref_id"], "integer").") ";
136 $w = "OR";
137 }
138 $q.= " GROUP BY ".$a_key_field.", ".$a_skill_field.", ".$a_tref_field;
139
140 $set = $ilDB->query($q);
141 while ($rec = $ilDB->fetchAssoc($set))
142 {
143 $a_usages[$rec[$a_skill_field].":".$rec[$a_tref_field]][$a_usage_type][] =
144 array("key" => $rec[$a_key_field]);
145 }
146 }
$w

References $ilDB, and $w.

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

84 {
85 global $ilDB;
86
87 $set = $ilDB->query("SELECT obj_id FROM skl_usage ".
88 " WHERE skill_id = ".$ilDB->quote($a_skill_id, "integer").
89 " AND tref_id = ".$ilDB->quote($a_tref_id, "integer")
90 );
91 $obj_ids = array();
92 while ($rec = $ilDB->fetchAssoc($set))
93 {
94 $obj_ids[] = $rec["obj_id"];
95 }
96
97 return $obj_ids;
98 }

References $ilDB.

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

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

References $ilDB.

Referenced by ilSurveySkill\addQuestionSkillAssignment(), and ilSurveySkill\removeUsagesOfSkills().

+ Here is the caller graph for this function:

Field Documentation

◆ $classes

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

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

Referenced by getAllUsagesInfo().

◆ PERSONAL_SKILL

const ilSkillUsage::PERSONAL_SKILL = "pers"

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

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

◆ PROFILE

const ilSkillUsage::PROFILE = "prof"

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

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

◆ RESOURCE

const ilSkillUsage::RESOURCE = "res"

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

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

◆ SELF_EVAL

const ilSkillUsage::SELF_EVAL = "seval"

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

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

◆ TYPE_GENERAL

const ilSkillUsage::TYPE_GENERAL = "gen"

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

Referenced by getObjTypeString(), and getUsageInfo().

◆ USER_ASSIGNED

const ilSkillUsage::USER_ASSIGNED = "user"

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

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

◆ USER_MATERIAL

const ilSkillUsage::USER_MATERIAL = "mat"

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

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


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