ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilPersonalSkill.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Skill/interfaces/interface.ilSkillUsageInfo.php");
6 
15 {
22  static function getSelectedUserSkills($a_user_id)
23  {
24  global $ilDB;
25 
26  include_once "Services/Skill/classes/class.ilSkillTreeNode.php";
27 
28  include_once("./Services/Skill/classes/class.ilSkillTree.php");
29  $stree = new ilSkillTree();
30 
31  $set = $ilDB->query("SELECT * FROM skl_personal_skill ".
32  " WHERE user_id = ".$ilDB->quote($a_user_id, "integer")
33  );
34  $pskills = array();
35  while ($rec = $ilDB->fetchAssoc($set))
36  {
37  if ($stree->isInTree($rec["skill_node_id"]))
38  {
39  $pskills[$rec["skill_node_id"]] = array("skill_node_id" => $rec["skill_node_id"],
40  "title" => ilSkillTreeNode::_lookupTitle($rec["skill_node_id"]));
41  }
42  }
43  return $pskills;
44  }
45 
52  static function addPersonalSkill($a_user_id, $a_skill_node_id)
53  {
54  global $ilDB;
55 
56  $set = $ilDB->query("SELECT * FROM skl_personal_skill ".
57  " WHERE user_id = ".$ilDB->quote($a_user_id, "integer").
58  " AND skill_node_id = ".$ilDB->quote($a_skill_node_id, "integer")
59  );
60  if (!$ilDB->fetchAssoc($set))
61  {
62  $ilDB->manipulate("INSERT INTO skl_personal_skill ".
63  "(user_id, skill_node_id) VALUES (".
64  $ilDB->quote($a_user_id, "integer").",".
65  $ilDB->quote($a_skill_node_id, "integer").
66  ")");
67  }
68  }
69 
76  static function removeSkill($a_user_id, $a_skill_node_id)
77  {
78  global $ilDB;
79 
80  $ilDB->manipulate("DELETE FROM skl_personal_skill WHERE ".
81  " user_id = ".$ilDB->quote($a_user_id, "integer").
82  " AND skill_node_id = ".$ilDB->quote($a_skill_node_id, "integer")
83  );
84 
85  }
86 
87 
88  //
89  // Assigned materials
90  //
91 
102  static function assignMaterial($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill, $a_level, $a_wsp_id)
103  {
104  global $ilDB;
105 
106  $set = $ilDB->query("SELECT * FROM skl_assigned_material ".
107  " WHERE user_id = ".$ilDB->quote($a_user_id, "integer").
108  " AND top_skill_id = ".$ilDB->quote($a_top_skill, "integer").
109  " AND tref_id = ".$ilDB->quote((int) $a_tref_id, "integer").
110  " AND skill_id = ".$ilDB->quote($a_basic_skill, "integer").
111  " AND level_id = ".$ilDB->quote($a_level, "integer").
112  " AND wsp_id = ".$ilDB->quote($a_wsp_id, "integer")
113  );
114  if (!$ilDB->fetchAssoc($set))
115  {
116  $ilDB->manipulate("INSERT INTO skl_assigned_material ".
117  "(user_id, top_skill_id, tref_id, skill_id, level_id, wsp_id) VALUES (".
118  $ilDB->quote($a_user_id, "integer").",".
119  $ilDB->quote($a_top_skill, "integer").",".
120  $ilDB->quote((int) $a_tref_id, "integer").",".
121  $ilDB->quote($a_basic_skill, "integer").",".
122  $ilDB->quote($a_level, "integer").",".
123  $ilDB->quote($a_wsp_id, "integer").
124  ")");
125  }
126  }
127 
135  static function getAssignedMaterial($a_user_id, $a_tref_id, $a_level)
136  {
137  global $ilDB;
138 
139  $set = $ilDB->query("SELECT * FROM skl_assigned_material ".
140  " WHERE level_id = ".$ilDB->quote($a_level, "integer").
141  " AND tref_id = ".$ilDB->quote((int) $a_tref_id, "integer").
142  " AND user_id = ".$ilDB->quote($a_user_id, "integer")
143  );
144  $mat = array();
145  while ($rec = $ilDB->fetchAssoc($set))
146  {
147  $mat[] = $rec;
148  }
149  return $mat;
150  }
151 
159  static function countAssignedMaterial($a_user_id, $a_tref_id, $a_level)
160  {
161  global $ilDB;
162 
163  $set = $ilDB->query("SELECT count(*) as cnt FROM skl_assigned_material ".
164  " WHERE level_id = ".$ilDB->quote($a_level, "integer").
165  " AND tref_id = ".$ilDB->quote((int) $a_tref_id, "integer").
166  " AND user_id = ".$ilDB->quote($a_user_id, "integer")
167  );
168  $rec = $ilDB->fetchAssoc($set);
169  return $rec["cnt"];
170  }
171 
178  static function removeMaterial($a_user_id, $a_tref_id, $a_level_id, $a_wsp_id)
179  {
180  global $ilDB;
181 
182  $t = "DELETE FROM skl_assigned_material WHERE ".
183  " user_id = ".$ilDB->quote($a_user_id, "integer").
184  " AND tref_id = ".$ilDB->quote((int) $a_tref_id, "integer").
185  " AND level_id = ".$ilDB->quote($a_level_id, "integer").
186  " AND wsp_id = ".$ilDB->quote($a_wsp_id, "integer");
187 
188  $ilDB->manipulate($t);
189  }
190 
191  //
192  // Self evaluation
193  //
194 
204  static function saveSelfEvaluation($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill, $a_level)
205  {
206  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
207  if ($a_level > 0)
208  {
209  ilBasicSkill::writeUserSkillLevelStatus($a_level, $a_user_id,
210  0, $a_tref_id, ilBasicSkill::ACHIEVED, false,
211  1);
212  }
213  else
214  {
215  ilBasicSkill::resetUserSkillLevelStatus($a_user_id, $a_basic_skill, $a_tref_id, 0, true);
216  }
217 
218  }
219 
229  static function getSelfEvaluation($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill)
230  {
231  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
232  $bs = new ilBasicSkill($a_basic_skill);
233  return $bs->getLastLevelPerObject($a_tref_id, 0, $a_user_id, 1);
234  }
235 
245  static function getSelfEvaluationDate($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill)
246  {
247  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
248  $bs = new ilBasicSkill($a_basic_skill);
249  return $bs->getLastUpdatePerObject($a_tref_id, 0, $a_user_id, 1);
250  }
251 
258  static public function getUsageInfo($a_cskill_ids, &$a_usages)
259  {
260  global $ilDB;
261 
262  // material
263  include_once("./Services/Skill/classes/class.ilSkillUsage.php");
265  "skl_assigned_material", "user_id");
266 
267  // self evaluations
269  "skl_self_eval_level", "user_id");
270 
271  // users that use the skills as personal skills
272  $pskill_ids = array();
273  $tref_ids = array();
274  foreach ($a_cskill_ids as $cs)
275  {
276  if ($cs["tref_id"] > 0)
277  {
278  include_once("./Services/Skill/classes/class.ilSkillTemplateReference.php");
279  if (ilSkillTemplateReference::_lookupTemplateId($cs["tref_id"]) == $cs["skill_id"])
280  {
281  $pskill_ids[$cs["tref_id"]] = $cs["tref_id"];
282  $tref_ids[(int) $cs["tref_id"]] = $cs["skill_id"];
283  }
284  }
285  else
286  {
287  $pskill_ids[$cs["skill_id"]] = $cs["skill_id"];
288  }
289  }
290  $set = $ilDB->query("SELECT skill_node_id, user_id FROM skl_personal_skill ".
291  " WHERE ".$ilDB->in("skill_node_id", $pskill_ids, false, "integer").
292  " GROUP BY skill_node_id, user_id"
293  );
294  while ($rec = $ilDB->fetchAssoc($set))
295  {
296  if (isset($tref_ids[(int) $rec["skill_node_id"]]))
297  {
298  $a_usages[$tref_ids[$rec["skill_node_id"]].":".$rec["skill_node_id"]][ilSkillUsage::PERSONAL_SKILL][] =
299  array("key" => $rec["user_id"]);
300  }
301  else
302  {
303  $a_usages[$rec["skill_node_id"].":0"][ilSkillUsage::PERSONAL_SKILL][] =
304  array("key" => $rec["user_id"]);
305  }
306  }
307  }
308 
309 }
310 
311 ?>
Get info on usages of skills.
Skill tree.
static getSelectedUserSkills($a_user_id)
Get personal selected user skills.
static saveSelfEvaluation($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill, $a_level)
Save self evaluation.
static removeSkill($a_user_id, $a_skill_node_id)
Remove personal skill.
static getUsageInfo($a_cskill_ids, &$a_usages)
Get usage info.
static addPersonalSkill($a_user_id, $a_skill_node_id)
Add personal skill.
static _lookupTemplateId($a_obj_id)
Lookup template ID.
static writeUserSkillLevelStatus($a_level_id, $a_user_id, $a_trigger_ref_id, $a_tref_id=0, $a_status=ilBasicSkill::ACHIEVED, $a_force=false, $a_self_eval=false, $a_unique_identifier="")
Write skill level status.
Create styles array
The data for the language used.
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.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
static getSelfEvaluation($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill)
Get self evaluation.
static getAssignedMaterial($a_user_id, $a_tref_id, $a_level)
Get assigned material (for a skill level and user)
static countAssignedMaterial($a_user_id, $a_tref_id, $a_level)
Get assigned material (for a skill level and user)
global $ilDB
Basic Skill.
static getSelfEvaluationDate($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill)
Get self evaluation.
static removeMaterial($a_user_id, $a_tref_id, $a_level_id, $a_wsp_id)
Remove material.
static assignMaterial($a_user_id, $a_top_skill, $a_tref_id, $a_basic_skill, $a_level, $a_wsp_id)
Assign material to skill level.
static resetUserSkillLevelStatus($a_user_id, $a_skill_id, $a_tref_id=0, $a_trigger_ref_id=0, $a_self_eval=false)
Reset skill level status.