ILIAS  release_8 Revision v8.23
ilSkillResources Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (int $a_skill_id=0, int $a_tref_id=0)
 
 setBaseSkillId (int $a_val)
 
 getBaseSkillId ()
 
 setTemplateRefId (int $a_val)
 
 getTemplateRefId ()
 
 readResources ()
 
 save ()
 
 getResources ()
 
 getResourcesOfLevel (int $a_level_id)
 
 setResourceAsTrigger (int $a_level_id, int $a_rep_ref_id, bool $a_trigger=true)
 
 setResourceAsImparting (int $a_level_id, int $a_rep_ref_id, bool $a_imparting=true)
 

Static Public Member Functions

static getUsageInfo (array $a_cskill_ids)
 
static getTriggerLevelsForRefId (int $a_ref_id)
 

Protected Attributes

ilDBInterface $db
 
ilTree $tree
 
int $base_skill_id = 0
 
int $tref_id = 0
 
array $resources = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 32 of file class.ilSkillResources.php.

Constructor & Destructor Documentation

◆ __construct()

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

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: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ getBaseSkillId()

ilSkillResources::getBaseSkillId ( )

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

References $base_skill_id.

72  : int
73  {
74  return $this->base_skill_id;
75  }

◆ getResources()

ilSkillResources::getResources ( )
Returns
array<int, array<int, array{level_id: int, rep_ref_id: int, trigger: int, imparting: int}>>

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

References $resources.

Referenced by save().

138  : array
139  {
140  return $this->resources;
141  }
+ Here is the caller graph for this function:

◆ getResourcesOfLevel()

ilSkillResources::getResourcesOfLevel ( int  $a_level_id)
Returns
array<int, array{level_id: int, rep_ref_id: int, trigger: int, imparting: int}>

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

146  : array
147  {
148  $ret = (isset($this->resources[$a_level_id]) && is_array($this->resources[$a_level_id]))
149  ? $this->resources[$a_level_id]
150  : [];
151 
152  return $ret;
153  }

◆ getTemplateRefId()

ilSkillResources::getTemplateRefId ( )

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

References $tref_id.

82  : int
83  {
84  return $this->tref_id;
85  }

◆ getTriggerLevelsForRefId()

static ilSkillResources::getTriggerLevelsForRefId ( int  $a_ref_id)
static
Returns
array{base_skill_id: int, tref_id: int, level_id: int}[]

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

References $DIC, ilDBInterface\fetchAssoc(), ilDBInterface\query(), and ilDBInterface\quote().

Referenced by ilSkillAppEventListener\handleEvent().

198  : array
199  {
200  global $DIC;
201 
202  $db = $DIC->database();
203 
204  $set = $db->query("SELECT * FROM skl_skill_resource " .
205  " WHERE rep_ref_id = " . $db->quote($a_ref_id, "integer") .
206  " AND ltrigger = " . $db->quote(1, "integer"));
207 
208  $skill_levels = [];
209  while ($rec = $db->fetchAssoc($set)) {
210  $skill_levels[] = array(
211  "base_skill_id" => (int) $rec["base_skill_id"],
212  "tref_id" => (int) $rec["tref_id"],
213  "level_id" => (int) $rec["level_id"]
214  );
215  }
216  return $skill_levels;
217  }
fetchAssoc(ilDBStatement $statement)
quote($value, string $type)
global $DIC
Definition: feed.php:28
query(string $query)
Run a (read-only) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsageInfo()

static ilSkillResources::getUsageInfo ( array  $a_cskill_ids)
static
Parameters
array{skill_idint, tref_id: int}[] $a_cskill_ids array of common skill ids
Returns
array<string, array<string, array{key: string}[]>>

Implements ilSkillUsageInfo.

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

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

184  : array
185  {
187  $a_cskill_ids,
189  "skl_skill_resource",
190  "rep_ref_id",
191  "base_skill_id"
192  );
193  }
static getUsageInfoGeneric(array $a_cskill_ids, string $a_usage_type, string $a_table, string $a_key_field, string $a_skill_field="skill_id", string $a_tref_field="tref_id")
Get standard usage query.
+ Here is the call graph for this function:

◆ readResources()

ilSkillResources::readResources ( )

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

References $db, $ilDB, $tree, ILIAS\Repository\int(), and ilTree\isInTree().

Referenced by __construct().

87  : void
88  {
89  $ilDB = $this->db;
91 
92  $set = $ilDB->query(
93  "SELECT * FROM skl_skill_resource " .
94  " WHERE base_skill_id = " . $ilDB->quote($this->getBaseSkillId(), "integer") .
95  " AND tref_id = " . $ilDB->quote($this->getTemplateRefId(), "integer")
96  );
97  while ($rec = $ilDB->fetchAssoc($set)) {
98  if ($tree->isInTree($rec["rep_ref_id"])) {
99  $this->resources[(int) $rec["level_id"]][(int) $rec["rep_ref_id"]] = array(
100  "level_id" => (int) $rec["level_id"],
101  "rep_ref_id" => (int) $rec["rep_ref_id"],
102  "trigger" => (int) $rec["ltrigger"],
103  "imparting" => (int) $rec["imparting"]
104  );
105  }
106  }
107  }
isInTree(?int $a_node_id)
get all information of a node.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilSkillResources::save ( )

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

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

109  : void
110  {
111  $ilDB = $this->db;
112 
113  $ilDB->manipulate(
114  "DELETE FROM skl_skill_resource WHERE " .
115  " base_skill_id = " . $ilDB->quote($this->getBaseSkillId(), "integer") .
116  " AND tref_id = " . $ilDB->quote($this->getTemplateRefId(), "integer")
117  );
118  foreach ($this->getResources() as $level_id => $l) {
119  foreach ($l as $ref_id => $r) {
120  if ($r["imparting"] || $r["trigger"]) {
121  $ilDB->manipulate("INSERT INTO skl_skill_resource " .
122  "(base_skill_id, tref_id, level_id, rep_ref_id, imparting, ltrigger) VALUES (" .
123  $ilDB->quote($this->getBaseSkillId(), "integer") . "," .
124  $ilDB->quote($this->getTemplateRefId(), "integer") . "," .
125  $ilDB->quote($level_id, "integer") . "," .
126  $ilDB->quote($ref_id, "integer") . "," .
127  $ilDB->quote((int) $r["imparting"], "integer") . "," .
128  $ilDB->quote((int) $r["trigger"], "integer") .
129  ")");
130  }
131  }
132  }
133  }
$ref_id
Definition: ltiauth.php:67
+ Here is the call graph for this function:

◆ setBaseSkillId()

ilSkillResources::setBaseSkillId ( int  $a_val)

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

Referenced by __construct().

67  : void
68  {
69  $this->base_skill_id = $a_val;
70  }
+ Here is the caller graph for this function:

◆ setResourceAsImparting()

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

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

167  : void
168  {
169  if (!isset($this->resources[$a_level_id]) || !is_array($this->resources[$a_level_id])) {
170  $this->resources[$a_level_id] = [];
171  }
172  if (!isset($this->resources[$a_level_id][$a_rep_ref_id]) || !is_array($this->resources[$a_level_id][$a_rep_ref_id])) {
173  $this->resources[$a_level_id][$a_rep_ref_id] = [];
174  }
175 
176  $this->resources[$a_level_id][$a_rep_ref_id]["imparting"] = $a_imparting;
177  }

◆ setResourceAsTrigger()

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

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

155  : void
156  {
157  if (!isset($this->resources[$a_level_id]) || !is_array($this->resources[$a_level_id])) {
158  $this->resources[$a_level_id] = [];
159  }
160  if (!isset($this->resources[$a_level_id][$a_rep_ref_id]) || !is_array($this->resources[$a_level_id][$a_rep_ref_id])) {
161  $this->resources[$a_level_id][$a_rep_ref_id] = [];
162  }
163 
164  $this->resources[$a_level_id][$a_rep_ref_id]["trigger"] = $a_trigger;
165  }

◆ setTemplateRefId()

ilSkillResources::setTemplateRefId ( int  $a_val)

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

Referenced by __construct().

77  : void
78  {
79  $this->tref_id = $a_val;
80  }
+ Here is the caller graph for this function:

Field Documentation

◆ $base_skill_id

int ilSkillResources::$base_skill_id = 0
protected

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

Referenced by getBaseSkillId().

◆ $db

ilDBInterface ilSkillResources::$db
protected

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

Referenced by readResources(), and save().

◆ $resources

array ilSkillResources::$resources = []
protected

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

Referenced by getResources().

◆ $tree

ilTree ilSkillResources::$tree
protected

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

Referenced by readResources().

◆ $tref_id

int ilSkillResources::$tref_id = 0
protected

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

Referenced by getTemplateRefId().


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