ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
Version
$Id$ /

Definition at line 21 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 53 of file class.ilSkillResources.php.

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

54  {
55  global $DIC;
56 
57  $this->db = $DIC->database();
58  $this->tree = $DIC->repositoryTree();
59  $this->setBaseSkillId($a_skill_id);
60  $this->setTemplateRefId($a_tref_id);
61 
62  if ($a_skill_id > 0) {
63  $this->readResources();
64  }
65  }
global $DIC
Definition: saml.php:7
setBaseSkillId($a_val)
Set base skill id.
readResources()
Read resources.
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 82 of file class.ilSkillResources.php.

References $base_skill_id.

83  {
84  return $this->base_skill_id;
85  }

◆ getResources()

ilSkillResources::getResources ( )

Get resources.

Returns

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

References $resources.

Referenced by save().

170  {
171  return $this->resources;
172  }
+ 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 180 of file class.ilSkillResources.php.

References $ret, and array.

181  {
182  $ret = (is_array($this->resources[$a_level_id]))
183  ? $this->resources[$a_level_id]
184  : array();
185 
186  return $ret;
187  }
Create styles array
The data for the language used.
$ret
Definition: parser.php:6

◆ getTemplateRefId()

ilSkillResources::getTemplateRefId ( )

Get template reference id.

Returns
int template reference id

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

References $tref_id.

103  {
104  return $this->tref_id;
105  }

◆ 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 256 of file class.ilSkillResources.php.

References $db, $DIC, and array.

Referenced by ilSkillAppEventListener\handleEvent().

257  {
258  global $DIC;
259 
260  $db = $DIC->database();
261 
262  $set = $db->query("SELECT * FROM skl_skill_resource " .
263  " WHERE rep_ref_id = " . $db->quote($a_ref_id, "integer") .
264  " AND ltrigger = " . $db->quote(1, "integer"));
265 
266  $skill_levels = array();
267  while ($rec = $db->fetchAssoc($set)) {
268  $skill_levels[] = array(
269  "base_skill_id" => $rec["base_skill_id"],
270  "tref_id" => $rec["tref_id"],
271  "level_id" => $rec["level_id"]
272  );
273  }
274  return $skill_levels;
275  }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
+ 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 233 of file class.ilSkillResources.php.

References $DIC, $ilDB, ilSkillUsage\getUsageInfoGeneric(), and ilSkillUsage\RESOURCE.

234  {
235  global $DIC;
236 
237  $ilDB = $DIC->database();
238 
239  include_once("./Services/Skill/classes/class.ilSkillUsage.php");
241  $a_cskill_ids,
242  $a_usages,
244  "skl_skill_resource",
245  "rep_ref_id",
246  "base_skill_id"
247  );
248  }
global $DIC
Definition: saml.php:7
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
+ Here is the call graph for this function:

◆ readResources()

ilSkillResources::readResources ( )

Read resources.

Parameters

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

References $db, $ilDB, $tree, and array.

Referenced by __construct().

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

◆ save()

ilSkillResources::save ( )

Save resources.

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

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

139  {
140  $ilDB = $this->db;
141 
142  $ilDB->manipulate(
143  "DELETE FROM skl_skill_resource WHERE " .
144  " base_skill_id = " . $ilDB->quote((int) $this->getBaseSkillId(), "integer") .
145  " AND tref_id = " . $ilDB->quote((int) $this->getTemplateRefId(), "integer")
146  );
147  foreach ($this->getResources() as $level_id => $l) {
148  foreach ($l as $ref_id => $r) {
149  if ($r["imparting"] || $r["trigger"]) {
150  $ilDB->manipulate("INSERT INTO skl_skill_resource " .
151  "(base_skill_id, tref_id, level_id, rep_ref_id, imparting, ltrigger) VALUES (" .
152  $ilDB->quote((int) $this->getBaseSkillId(), "integer") . "," .
153  $ilDB->quote((int) $this->getTemplateRefId(), "integer") . "," .
154  $ilDB->quote((int) $level_id, "integer") . "," .
155  $ilDB->quote((int) $ref_id, "integer") . "," .
156  $ilDB->quote((int) $r["imparting"], "integer") . "," .
157  $ilDB->quote((int) $r["trigger"], "integer") .
158  ")");
159  }
160  }
161  }
162  }
$r
Definition: example_031.php:79
getResources()
Get resources.
global $l
Definition: afr.php:30
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 72 of file class.ilSkillResources.php.

Referenced by __construct().

73  {
74  $this->base_skill_id = (int) $a_val;
75  }
+ 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 215 of file class.ilSkillResources.php.

References array.

216  {
217  if (!is_array($this->resources[$a_level_id])) {
218  $this->resources[$a_level_id] = array();
219  }
220  if (!is_array($this->resources[$a_level_id][$a_rep_ref_id])) {
221  $this->resources[$a_level_id][$a_rep_ref_id] = array();
222  }
223 
224  $this->resources[$a_level_id][$a_rep_ref_id]["imparting"] = $a_imparting;
225  }
Create styles array
The data for the language used.

◆ 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 196 of file class.ilSkillResources.php.

References array.

197  {
198  if (!is_array($this->resources[$a_level_id])) {
199  $this->resources[$a_level_id] = array();
200  }
201  if (!is_array($this->resources[$a_level_id][$a_rep_ref_id])) {
202  $this->resources[$a_level_id][$a_rep_ref_id] = array();
203  }
204 
205  $this->resources[$a_level_id][$a_rep_ref_id]["trigger"] = $a_trigger;
206  }
Create styles array
The data for the language used.

◆ setTemplateRefId()

ilSkillResources::setTemplateRefId (   $a_val)

Set template reference id.

Parameters
int$a_valtemplate reference id

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

Referenced by __construct().

93  {
94  $this->tref_id = (int) $a_val;
95  }
+ Here is the caller graph for this function:

Field Documentation

◆ $base_skill_id

ilSkillResources::$base_skill_id
protected

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

Referenced by getBaseSkillId().

◆ $db

ilSkillResources::$db
protected

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

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

◆ $resources

ilSkillResources::$resources = array()
protected

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

Referenced by getResources().

◆ $tree

ilSkillResources::$tree
protected

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

Referenced by readResources().

◆ $tref_id

ilSkillResources::$tref_id
protected

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

Referenced by getTemplateRefId().


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