ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSkillResources Class Reference

Manages resources for skills. More...

+ Inheritance diagram for ilSkillResources:
+ Collaboration diagram for ilSkillResources:

Public Member Functions

 __construct ($a_skill_id=0, $a_tref_id=0)
 Constructor. More...
 
 setBaseSkillId ($a_val)
 Set base skill id. More...
 
 getBaseSkillId ()
 Get base skill id. More...
 
 setTemplateRefId ($a_val)
 Set template reference id. More...
 
 getTemplateRefId ()
 Get template reference id. More...
 
 readResources ()
 Read resources. More...
 
 save ()
 Save resources. More...
 
 getResources ()
 Get resources. More...
 
 getResourcesOfLevel ($a_level_id)
 Get resoures for level id. More...
 
 setResourceAsTrigger ($a_level_id, $a_rep_ref_id, $a_trigger=true)
 Set resource as trigger. More...
 
 setResourceAsImparting ($a_level_id, $a_rep_ref_id, $a_imparting=true)
 Set resource as imparting resource. More...
 

Static Public Member Functions

static getUsageInfo ($a_cskill_ids, &$a_usages)
 Get usage info. More...
 
static getTriggerLevelsForRefId ($a_ref_id)
 Get levels for trigger per ref id. More...
 

Protected Attributes

 $db
 
 $tree
 
 $base_skill_id
 
 $tref_id
 
 $resources = array()
 

Detailed Description

Manages resources for skills.

This is not about user assigned materials, it is about resources that are assigned to skill levels in the competence management administration of ILIAS.

This can be either triggers (e.g. a course that triggers a competence level) or resources that impart the knowledge of a competence level. Imparting does not necessarily mean that it triggers a competence level.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

Definition at line 17 of file class.ilSkillResources.php.

Constructor & Destructor Documentation

◆ __construct()

ilSkillResources::__construct (   $a_skill_id = 0,
  $a_tref_id = 0 
)

Constructor.

Parameters
int$a_skill_idbase skill id
int$a_tref_idtemplate reference id (0, if no template is involved)

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

References $DIC, readResources(), setBaseSkillId(), and setTemplateRefId().

50  {
51  global $DIC;
52 
53  $this->db = $DIC->database();
54  $this->tree = $DIC->repositoryTree();
55  $this->setBaseSkillId($a_skill_id);
56  $this->setTemplateRefId($a_tref_id);
57 
58  if ($a_skill_id > 0) {
59  $this->readResources();
60  }
61  }
setBaseSkillId($a_val)
Set base skill id.
readResources()
Read resources.
global $DIC
Definition: goto.php:24
setTemplateRefId($a_val)
Set template reference id.
+ Here is the call graph for this function:

Member Function Documentation

◆ getBaseSkillId()

ilSkillResources::getBaseSkillId ( )

Get base skill id.

Returns
int base skill id

Definition at line 78 of file class.ilSkillResources.php.

References $base_skill_id.

79  {
80  return $this->base_skill_id;
81  }

◆ getResources()

ilSkillResources::getResources ( )

Get resources.

Returns

Definition at line 165 of file class.ilSkillResources.php.

References $resources.

Referenced by save().

166  {
167  return $this->resources;
168  }
+ Here is the caller graph for this function:

◆ getResourcesOfLevel()

ilSkillResources::getResourcesOfLevel (   $a_level_id)

Get resoures for level id.

Parameters
int$a_level_idlevel id
Returns
array array of resources

Definition at line 176 of file class.ilSkillResources.php.

References $ret.

177  {
178  $ret = (is_array($this->resources[$a_level_id]))
179  ? $this->resources[$a_level_id]
180  : array();
181 
182  return $ret;
183  }
$ret
Definition: parser.php:6

◆ getTemplateRefId()

ilSkillResources::getTemplateRefId ( )

Get template reference id.

Returns
int template reference id

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

References $tref_id.

99  {
100  return $this->tref_id;
101  }

◆ getTriggerLevelsForRefId()

static ilSkillResources::getTriggerLevelsForRefId (   $a_ref_id)
static

Get levels for trigger per ref id.

Parameters
int$a_ref_id
Returns
array skill levels

Definition at line 247 of file class.ilSkillResources.php.

References $db, and $DIC.

Referenced by ilSkillAppEventListener\handleEvent().

248  {
249  global $DIC;
250 
251  $db = $DIC->database();
252 
253  $set = $db->query("SELECT * FROM skl_skill_resource " .
254  " WHERE rep_ref_id = " . $db->quote($a_ref_id, "integer") .
255  " AND ltrigger = " . $db->quote(1, "integer"));
256 
257  $skill_levels = array();
258  while ($rec = $db->fetchAssoc($set)) {
259  $skill_levels[] = array(
260  "base_skill_id" => $rec["base_skill_id"],
261  "tref_id" => $rec["tref_id"],
262  "level_id" => $rec["level_id"]
263  );
264  }
265  return $skill_levels;
266  }
global $DIC
Definition: goto.php:24
+ Here is the caller graph for this function:

◆ getUsageInfo()

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

Get usage info.

Parameters

Implements ilSkillUsageInfo.

Definition at line 229 of file class.ilSkillResources.php.

References ilSkillUsage\getUsageInfoGeneric(), and ilSkillUsage\RESOURCE.

230  {
232  $a_cskill_ids,
233  $a_usages,
235  "skl_skill_resource",
236  "rep_ref_id",
237  "base_skill_id"
238  );
239  }
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.
+ Here is the call graph for this function:

◆ readResources()

ilSkillResources::readResources ( )

Read resources.

Parameters

Definition at line 109 of file class.ilSkillResources.php.

References $db, $ilDB, and $tree.

Referenced by __construct().

110  {
111  $ilDB = $this->db;
112  $tree = $this->tree;
113 
114  $set = $ilDB->query(
115  "SELECT * FROM skl_skill_resource " .
116  " WHERE base_skill_id = " . $ilDB->quote($this->getBaseSkillId(), "integer") .
117  " AND tref_id = " . $ilDB->quote($this->getTemplateRefId(), "integer")
118  );
119  while ($rec = $ilDB->fetchAssoc($set)) {
120  if ($tree->isInTree($rec["rep_ref_id"])) {
121  $this->resources[$rec["level_id"]][$rec["rep_ref_id"]] = array(
122  "level_id" => $rec["level_id"],
123  "rep_ref_id" => $rec["rep_ref_id"],
124  "trigger" => $rec["ltrigger"],
125  "imparting" => $rec["imparting"]
126  );
127  }
128  }
129  }
global $ilDB
+ Here is the caller graph for this function:

◆ save()

ilSkillResources::save ( )

Save resources.

Definition at line 134 of file class.ilSkillResources.php.

References $db, $ilDB, and getResources().

135  {
136  $ilDB = $this->db;
137 
138  $ilDB->manipulate(
139  "DELETE FROM skl_skill_resource WHERE " .
140  " base_skill_id = " . $ilDB->quote((int) $this->getBaseSkillId(), "integer") .
141  " AND tref_id = " . $ilDB->quote((int) $this->getTemplateRefId(), "integer")
142  );
143  foreach ($this->getResources() as $level_id => $l) {
144  foreach ($l as $ref_id => $r) {
145  if ($r["imparting"] || $r["trigger"]) {
146  $ilDB->manipulate("INSERT INTO skl_skill_resource " .
147  "(base_skill_id, tref_id, level_id, rep_ref_id, imparting, ltrigger) VALUES (" .
148  $ilDB->quote((int) $this->getBaseSkillId(), "integer") . "," .
149  $ilDB->quote((int) $this->getTemplateRefId(), "integer") . "," .
150  $ilDB->quote((int) $level_id, "integer") . "," .
151  $ilDB->quote((int) $ref_id, "integer") . "," .
152  $ilDB->quote((int) $r["imparting"], "integer") . "," .
153  $ilDB->quote((int) $r["trigger"], "integer") .
154  ")");
155  }
156  }
157  }
158  }
getResources()
Get resources.
global $ilDB
+ Here is the call graph for this function:

◆ setBaseSkillId()

ilSkillResources::setBaseSkillId (   $a_val)

Set base skill id.

Parameters
int$a_valbase skill id

Definition at line 68 of file class.ilSkillResources.php.

Referenced by __construct().

69  {
70  $this->base_skill_id = (int) $a_val;
71  }
+ Here is the caller graph for this function:

◆ setResourceAsImparting()

ilSkillResources::setResourceAsImparting (   $a_level_id,
  $a_rep_ref_id,
  $a_imparting = true 
)

Set resource as imparting resource.

Parameters
int$a_level_idlevel id
int$a_rep_ref_idrepository resource ref id
bool$a_impartingimparting knowledge true/false

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

212  {
213  if (!is_array($this->resources[$a_level_id])) {
214  $this->resources[$a_level_id] = array();
215  }
216  if (!is_array($this->resources[$a_level_id][$a_rep_ref_id])) {
217  $this->resources[$a_level_id][$a_rep_ref_id] = array();
218  }
219 
220  $this->resources[$a_level_id][$a_rep_ref_id]["imparting"] = $a_imparting;
221  }

◆ setResourceAsTrigger()

ilSkillResources::setResourceAsTrigger (   $a_level_id,
  $a_rep_ref_id,
  $a_trigger = true 
)

Set resource as trigger.

Parameters
int$a_level_idlevel id
int$a_rep_ref_idrepository resource ref id
bool$a_triggertrigger true/false

Definition at line 192 of file class.ilSkillResources.php.

193  {
194  if (!is_array($this->resources[$a_level_id])) {
195  $this->resources[$a_level_id] = array();
196  }
197  if (!is_array($this->resources[$a_level_id][$a_rep_ref_id])) {
198  $this->resources[$a_level_id][$a_rep_ref_id] = array();
199  }
200 
201  $this->resources[$a_level_id][$a_rep_ref_id]["trigger"] = $a_trigger;
202  }

◆ setTemplateRefId()

ilSkillResources::setTemplateRefId (   $a_val)

Set template reference id.

Parameters
int$a_valtemplate reference id

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

Referenced by __construct().

89  {
90  $this->tref_id = (int) $a_val;
91  }
+ Here is the caller graph for this function:

Field Documentation

◆ $base_skill_id

ilSkillResources::$base_skill_id
protected

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

Referenced by getBaseSkillId().

◆ $db

ilSkillResources::$db
protected

Definition at line 22 of file class.ilSkillResources.php.

Referenced by getTriggerLevelsForRefId(), readResources(), and save().

◆ $resources

ilSkillResources::$resources = array()
protected

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

Referenced by getResources().

◆ $tree

ilSkillResources::$tree
protected

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

Referenced by readResources().

◆ $tref_id

ilSkillResources::$tref_id
protected

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

Referenced by getTemplateRefId().


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