ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 

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

References $classes.

Referenced by getAllUsagesInfoOfSubtree(), and getAllUsagesInfoOfSubtrees().

171  {
173 
174  $usages = array();
175  foreach ($classes as $class) {
176  // make static call
177  include_once("./Services/Skill/classes/class." . $class . ".php");
178  //call_user_func($class.'::getUsageInfo', $a_cskill_ids, $usages);
179  $class::getUsageInfo($a_cskill_ids, $usages);
180  }
181  return $usages;
182  }
+ 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 191 of file class.ilSkillUsage.php.

References $nodes, and getAllUsagesInfo().

192  {
193  // get nodes
194  include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
195  $vtree = new ilVirtualSkillTree();
196  $nodes = $vtree->getSubTreeForCSkillId($a_skill_id . ":" . $a_tref_id);
197 
198  return $this->getAllUsagesInfo($nodes);
199  }
getAllUsagesInfo($a_cskill_ids)
Get all usages info.
+ 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 207 of file class.ilSkillUsage.php.

References $n, $nodes, $s, and getAllUsagesInfo().

Referenced by getAllUsagesOfTemplate().

208  {
209  // get nodes
210  include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
211  $vtree = new ilVirtualSkillTree();
212  $allnodes = array();
213  foreach ($a_cskill_ids as $s) {
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  }
getAllUsagesInfo($a_cskill_ids)
Get all usages info.
$s
Definition: pwgen.php:45
$n
Definition: RandomTest.php:85
+ 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 229 of file class.ilSkillUsage.php.

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

230  {
231  $skill_logger = ilLoggerFactory::getLogger('skll');
232  $skill_logger->debug("ilSkillUsage: getAllUsagesOfTemplate(" . $a_tempate_id . ")");
233 
234  // get all trefs for template id
235  include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
237 
238  // get all usages of subtrees of template_id:tref
239  $cskill_ids = array();
240  foreach ($trefs as $tref) {
241  $cskill_ids[] = array("skill_id" => $a_tempate_id, "tref_id" => $tref);
242  $skill_logger->debug("ilSkillUsage: ... skill_id: " . $a_tempate_id . ", tref_id: " . $tref . ".");
243  }
244 
245  $skill_logger->debug("ilSkillUsage: ... count cskill_ids: " . count($cskill_ids) . ".");
246 
247  return $this->getAllUsagesInfoOfSubtrees($cskill_ids);
248  }
getAllUsagesInfoOfSubtrees($a_cskill_ids)
Get all usages info of subtree.
static _lookupTrefIdsForTemplateId($a_tid)
Get all tref ids for a template id.
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

◆ getObjTypeString()

static ilSkillUsage::getObjTypeString (   $a_type)
static

Get type info string.

Parameters

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

References $a_type, $DIC, and $lng.

Referenced by ilSkillUsageTableGUI\fillRow().

272  {
273  global $DIC;
274 
275  $lng = $DIC->language();
276 
277  switch ($a_type) {
278  case self::TYPE_GENERAL:
279  case self::RESOURCE:
280  return $lng->txt("skmg_usage_obj_objects");
281  break;
282 
283  case self::USER_ASSIGNED:
284  case self::PERSONAL_SKILL:
285  case self::USER_MATERIAL:
286  case self::SELF_EVAL:
287  return $lng->txt("skmg_usage_obj_users");
288  break;
289 
290  case self::PROFILE:
291  return $lng->txt("skmg_usage_obj_profiles");
292  break;
293  }
294 
295  return $lng->txt("skmg_usage_type_info_" . $a_type);
296  }
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92
$lng
+ 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 256 of file class.ilSkillUsage.php.

References $a_type, $DIC, and $lng.

Referenced by ilSkillUsageTableGUI\fillRow().

257  {
258  global $DIC;
259 
260  $lng = $DIC->language();
261 
262  return $lng->txt("skmg_usage_type_info_" . $a_type);
263  }
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92
$lng
+ 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 109 of file class.ilSkillUsage.php.

References $DIC, $ilDB, and TYPE_GENERAL.

110  {
111  global $DIC;
112 
113  $ilDB = $DIC->database();
114 
115  self::getUsageInfoGeneric(
116  $a_cskill_ids,
117  $a_usages,
119  "skl_usage",
120  "obj_id"
121  );
122  }
global $DIC
Definition: saml.php:7
global $ilDB

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

References $DIC, $ilDB, and $w.

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

138  {
139  global $DIC;
140 
141  $ilDB = $DIC->database();
142 
143  if (count($a_cskill_ids) == 0) {
144  return;
145  }
146 
147  $w = "WHERE";
148  $q = "SELECT " . $a_key_field . ", " . $a_skill_field . ", " . $a_tref_field . " FROM " . $a_table . " ";
149  foreach ($a_cskill_ids as $sk) {
150  $q .= $w . " (" . $a_skill_field . " = " . $ilDB->quote($sk["skill_id"], "integer") .
151  " AND " . $a_tref_field . " = " . $ilDB->quote($sk["tref_id"], "integer") . ") ";
152  $w = "OR";
153  }
154  $q .= " GROUP BY " . $a_key_field . ", " . $a_skill_field . ", " . $a_tref_field;
155 
156  $set = $ilDB->query($q);
157  while ($rec = $ilDB->fetchAssoc($set)) {
158  $a_usages[$rec[$a_skill_field] . ":" . $rec[$a_tref_field]][$a_usage_type][] =
159  array("key" => $rec[$a_key_field]);
160  }
161  }
global $DIC
Definition: saml.php:7
$w
global $ilDB
+ 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 84 of file class.ilSkillUsage.php.

References $DIC, and $ilDB.

85  {
86  global $DIC;
87 
88  $ilDB = $DIC->database();
89 
90  $set = $ilDB->query(
91  "SELECT obj_id FROM skl_usage " .
92  " WHERE skill_id = " . $ilDB->quote($a_skill_id, "integer") .
93  " AND tref_id = " . $ilDB->quote($a_tref_id, "integer")
94  );
95  $obj_ids = array();
96  while ($rec = $ilDB->fetchAssoc($set)) {
97  $obj_ids[] = $rec["obj_id"];
98  }
99 
100  return $obj_ids;
101  }
global $DIC
Definition: saml.php:7
global $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.

References $DIC, and $ilDB.

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

51  {
52  global $DIC;
53 
54  $ilDB = $DIC->database();
55 
56  if ($a_use) {
57  $ilDB->replace(
58  "skl_usage",
59  array(
60  "obj_id" => array("integer", $a_obj_id),
61  "skill_id" => array("integer", $a_skill_id),
62  "tref_id" => array("integer", $a_tref_id)
63  ),
64  array()
65  );
66  } else {
67  $ilDB->manipulate(
68  $q = "DELETE FROM skl_usage WHERE " .
69  " obj_id = " . $ilDB->quote($a_obj_id, "integer") .
70  " AND skill_id = " . $ilDB->quote($a_skill_id, "integer") .
71  " AND tref_id = " . $ilDB->quote($a_tref_id, "integer")
72  );
73  //echo $q; exit;
74  }
75  }
global $DIC
Definition: saml.php:7
global $ilDB
+ 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 ilPersonalSkill\getUsageInfo().

◆ PROFILE

const ilSkillUsage::PROFILE = "prof"

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

Referenced by ilSkillProfile\getUsageInfo().

◆ RESOURCE

const ilSkillUsage::RESOURCE = "res"

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

Referenced by ilSkillResources\getUsageInfo().

◆ SELF_EVAL

const ilSkillUsage::SELF_EVAL = "seval"

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

Referenced by ilPersonalSkill\getUsageInfo().

◆ TYPE_GENERAL

const ilSkillUsage::TYPE_GENERAL = "gen"

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

Referenced by getUsageInfo().

◆ USER_ASSIGNED

const ilSkillUsage::USER_ASSIGNED = "user"

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

Referenced by ilBasicSkill\getUsageInfo().

◆ USER_MATERIAL

const ilSkillUsage::USER_MATERIAL = "mat"

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

Referenced by ilPersonalSkill\getUsageInfo().


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