ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSkillSelfEvaluation Class Reference

Self evaluation application class. More...

+ Collaboration diagram for ilSkillSelfEvaluation:

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 setId ($a_val)
 Set id. More...
 
 getId ()
 Get id. More...
 
 setUserId ($a_val)
 Set user id. More...
 
 getUserId ()
 Get user id. More...
 
 setTopSkillId ($a_val)
 Set top skill id. More...
 
 getTopSkillId ()
 Get top skill id. More...
 
 setCreated ($a_val)
 Set created at. More...
 
 getCreated ()
 Get created at. More...
 
 setLastUpdate ($a_val)
 Set last update. More...
 
 getLastUpdate ()
 Get last update. More...
 
 setLevels ($a_val, $a_keep_existing=false)
 Set level. More...
 
 getLevels ()
 Get level. More...
 
 read ()
 Read. More...
 
 create ()
 Create self evaluation. More...
 
 update ()
 Update self evaluation. More...
 
 delete ()
 Delete self evaluation. More...
 

Static Public Member Functions

static getAllSelfEvaluationsOfUser ($a_user, $a_one_per_top_skill=false)
 Get all self evaluations. More...
 
static getAverageLevel ($a_se_id, $a_user_id, $a_top_skill_id)
 Get average level of user self evaluation. More...
 
static determineSteps ($a_sn_id)
 Determine steps. More...
 

Static Protected Member Functions

static lookupProperty ($a_id, $a_prop)
 Lookup property. More...
 

Detailed Description

Self evaluation application class.

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

Definition at line 12 of file class.ilSkillSelfEvaluation.php.

Constructor & Destructor Documentation

◆ __construct()

ilSkillSelfEvaluation::__construct (   $a_id = 0)

Constructor.

Parameters

Definition at line 19 of file class.ilSkillSelfEvaluation.php.

References read(), and setId().

20  {
21  if ($a_id > 0)
22  {
23  $this->setId($a_id);
24  $this->read();
25  }
26  }
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilSkillSelfEvaluation::create ( )

Create self evaluation.

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

References $ilDB, getLevels(), and setId().

199  {
200  global $ilDB;
201 
202  $this->setId($ilDB->nextId("skl_self_eval"));
203 
204  $ilDB->manipulate("INSERT INTO skl_self_eval ".
205  "(id, user_id, top_skill_id, created, last_update) VALUES (".
206  $ilDB->quote($this->getId(), "integer").",".
207  $ilDB->quote($this->getUserId(), "integer").",".
208  $ilDB->quote($this->getTopSkillId(), "integer").",".
209  $ilDB->now().",".
210  $ilDB->now().
211  ")");
212 
213  $levels = $this->getLevels();
214  if (is_array($levels))
215  {
216  foreach ($levels as $skill_id => $level_id)
217  {
218  $ilDB->manipulate("INSERT INTO skl_self_eval_level ".
219  "(self_eval_id, skill_id, level_id) VALUES (".
220  $ilDB->quote($this->getId(), "integer").",".
221  $ilDB->quote($skill_id, "integer").",".
222  $ilDB->quote($level_id, "integer").
223  ")");
224  }
225  }
226  }
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilSkillSelfEvaluation::delete ( )

Delete self evaluation.

Definition at line 264 of file class.ilSkillSelfEvaluation.php.

References $ilDB.

265  {
266  global $ilDB;
267 
268  $ilDB->manipulate("DELETE FROM skl_self_eval WHERE "
269  ." id = ".$ilDB->quote($this->getId(), "integer")
270  );
271 
272  $ilDB->manipulate("DELETE FROM skl_self_eval_level WHERE "
273  ." self_eval_id = ".$ilDB->quote($this->getId(), "integer")
274  );
275  }
global $ilDB

◆ determineSteps()

static ilSkillSelfEvaluation::determineSteps (   $a_sn_id)
static

Determine steps.

Parameters

Definition at line 392 of file class.ilSkillSelfEvaluation.php.

References $steps, and array.

Referenced by ilSkillSelfEvaluationGUI\saveSelfEvaluation(), ilSkillSelfEvaluationGUI\startSelfEvaluation(), and ilSkillSelfEvaluationGUI\updateSelfEvaluation().

393  {
394  $steps = array();
395  if ($a_sn_id > 0 )
396  {
397  include_once("./Services/Skill/classes/class.ilSkillTree.php");
398  include_once("./Services/Skill/classes/class.ilSkillSelfEvalSkillTableGUI.php");
399  $stree = new ilSkillTree();
400 
401  if ($stree->isInTree($a_sn_id))
402  {
403  $cnode = $stree->getNodeData($a_sn_id);
404  $childs = $stree->getSubTree($cnode);
405  foreach ($childs as $child)
406  {
407  if ($child["type"] == "skll")
408  {
409  $steps[] = $child["child"];
410  }
411  }
412  }
413  }
414  return $steps;
415  }
Skill tree.
$steps
Definition: latex.php:3
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getAllSelfEvaluationsOfUser()

static ilSkillSelfEvaluation::getAllSelfEvaluationsOfUser (   $a_user,
  $a_one_per_top_skill = false 
)
static

Get all self evaluations.

Definition at line 280 of file class.ilSkillSelfEvaluation.php.

References $ilDB, and array.

Referenced by ilSelfEvaluationTableGUI\__construct(), and ilSkillSelfEvaluationGUI\getPresentationView().

281  {
282  global $ilDB;
283 
284  $set = $ilDB->query("SELECT * FROM skl_self_eval WHERE user_id = ".
285  $ilDB->quote($a_user, "integer")." ".
286  "ORDER BY last_update DESC"
287  );
288 
289  $self_evaluation = array();
290 
291  $top_skills = array();
292  while ($rec = $ilDB->fetchAssoc($set))
293  {
294  if (!$a_one_per_top_skill || !in_array($rec["top_skill_id"], $top_skills))
295  {
296  $self_evaluation[] = $rec;
297  $top_skills[] = $rec["top_skill_id"];
298  }
299  }
300 
301  return $self_evaluation;
302  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getAverageLevel()

static ilSkillSelfEvaluation::getAverageLevel (   $a_se_id,
  $a_user_id,
  $a_top_skill_id 
)
static

Get average level of user self evaluation.

Note: this method does not make much sense in general, since it assumes that all basic skills have the same level

Definition at line 327 of file class.ilSkillSelfEvaluation.php.

References $l, $ld, $lng, and array.

328  {
329  global $lng;
330 
331  $lng->loadLanguageModule("skmg");
332 
333  include_once("./Services/Skill/classes/class.ilSkillTree.php");
334  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
335  $stree = new ilSkillTree();
336  $cnt = 0;
337  $sum = 0;
338  if ($stree->isInTree($a_top_skill_id))
339  {
340  $se = new ilSkillSelfEvaluation($a_se_id);
341  $levels = $se->getLevels();
342 
343  $cnode = $stree->getNodeData($a_top_skill_id);
344  $childs = $stree->getSubTree($cnode);
345 
346  foreach ($childs as $child)
347  {
348  if ($child["type"] == "skll")
349  {
350  $sk = new ilBasicSkill($child["child"]);
351  $ls = $sk->getLevelData();
352  $ord = array();
353  foreach ($ls as $k => $l)
354  {
355  $ord[$l["id"]] = $k + 1;
356  }
357  reset($ls);
358  foreach ($ls as $ld)
359  {
360  if ($ld["id"] == $levels[$child["child"]])
361  {
362  $sum+= $ord[$ld["id"]];
363  }
364  }
365  $cnt+= 1;
366  }
367  }
368  }
369  if ($cnt > 0)
370  {
371  $avg = round($sum/$cnt);
372  if ($avg > 0)
373  {
374  return (array("skill_title" => $cnode["title"],
375  "ord" => $avg, "avg_title" => $ls[$avg - 1]["title"]));
376  }
377  else
378  {
379  return (array("skill_title" => $cnode["title"],
380  "ord" => $avg, "avg_title" => $lng->txt("skmg_no_skills")));
381  }
382  }
383  return null;
384  }
Skill tree.
$ld
Definition: langwiz.php:244
Self evaluation application class.
Create styles array
The data for the language used.
global $l
Definition: afr.php:30
global $lng
Definition: privfeed.php:17
Basic Skill.

◆ getCreated()

ilSkillSelfEvaluation::getCreated ( )

Get created at.

Returns
timestamp created at

Definition at line 103 of file class.ilSkillSelfEvaluation.php.

104  {
105  return $this->created;
106  }

◆ getId()

ilSkillSelfEvaluation::getId ( )

Get id.

Returns
integer id

Definition at line 43 of file class.ilSkillSelfEvaluation.php.

Referenced by update().

44  {
45  return $this->id;
46  }
+ Here is the caller graph for this function:

◆ getLastUpdate()

ilSkillSelfEvaluation::getLastUpdate ( )

Get last update.

Returns
timestamp last update

Definition at line 123 of file class.ilSkillSelfEvaluation.php.

124  {
125  return $this->last_update;
126  }

◆ getLevels()

ilSkillSelfEvaluation::getLevels ( )

Get level.

Returns
array level

Definition at line 156 of file class.ilSkillSelfEvaluation.php.

Referenced by create(), and update().

157  {
158  return $this->levels;
159  }
+ Here is the caller graph for this function:

◆ getTopSkillId()

ilSkillSelfEvaluation::getTopSkillId ( )

Get top skill id.

Returns
integer top skill id

Definition at line 83 of file class.ilSkillSelfEvaluation.php.

84  {
85  return $this->top_skill_id;
86  }

◆ getUserId()

ilSkillSelfEvaluation::getUserId ( )

Get user id.

Returns
integer user id

Definition at line 63 of file class.ilSkillSelfEvaluation.php.

64  {
65  return $this->user_id;
66  }

◆ lookupProperty()

static ilSkillSelfEvaluation::lookupProperty (   $a_id,
  $a_prop 
)
staticprotected

Lookup property.

Parameters
idlevel id
Returns
mixed property value

Definition at line 310 of file class.ilSkillSelfEvaluation.php.

References $ilDB.

311  {
312  global $ilDB;
313 
314  $set = $ilDB->query("SELECT $a_prop FROM skl_self_eval WHERE ".
315  " id = ".$ilDB->quote($a_id, "integer")
316  );
317  $rec = $ilDB->fetchAssoc($set);
318  return $rec[$a_prop];
319  }
global $ilDB

◆ read()

ilSkillSelfEvaluation::read ( )

Read.

Parameters

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

References $ilDB, array, setCreated(), setLastUpdate(), setLevels(), setTopSkillId(), and setUserId().

Referenced by __construct().

168  {
169  global $ilDB;
170 
171  $set = $ilDB->query("SELECT * FROM skl_self_eval WHERE ".
172  " id = ".$ilDB->quote($this->getId(), "integer")
173  );
174  if ($rec = $ilDB->fetchAssoc($set))
175  {
176  $this->setUserId($rec["user_id"]);
177  $this->setTopSkillId($rec["top_skill_id"]);
178  $this->setCreated($rec["created"]);
179  $this->setLastUpdate($rec["last_update"]);
180  }
181 
182  // levels
183  $set = $ilDB->query("SELECT * FROM skl_self_eval_level WHERE ".
184  " self_eval_id = ".$ilDB->quote($this->getId(), "integer")
185  );
186  $levels = array();
187  while ($rec = $ilDB->fetchAssoc($set))
188  {
189  $levels[$rec["skill_id"]] = $rec["level_id"];
190  }
191  $this->setLevels($levels);
192 
193  }
setLevels($a_val, $a_keep_existing=false)
Set level.
setTopSkillId($a_val)
Set top skill id.
Create styles array
The data for the language used.
setLastUpdate($a_val)
Set last update.
global $ilDB
setCreated($a_val)
Set created at.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCreated()

ilSkillSelfEvaluation::setCreated (   $a_val)

Set created at.

Parameters
timestampcreated at

Definition at line 93 of file class.ilSkillSelfEvaluation.php.

Referenced by read().

94  {
95  $this->created = $a_val;
96  }
+ Here is the caller graph for this function:

◆ setId()

ilSkillSelfEvaluation::setId (   $a_val)

Set id.

Parameters
integerid

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

Referenced by __construct(), and create().

34  {
35  $this->id = $a_val;
36  }
+ Here is the caller graph for this function:

◆ setLastUpdate()

ilSkillSelfEvaluation::setLastUpdate (   $a_val)

Set last update.

Parameters
timestamplast update

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

Referenced by read().

114  {
115  $this->last_update = $a_val;
116  }
+ Here is the caller graph for this function:

◆ setLevels()

ilSkillSelfEvaluation::setLevels (   $a_val,
  $a_keep_existing = false 
)

Set level.

Parameters
arraylevel; index: skill id, value: level id (or 0 for no skills)

Definition at line 133 of file class.ilSkillSelfEvaluation.php.

References levels.

Referenced by read().

134  {
135  if (!$a_keep_existing)
136  {
137  $this->levels = $a_val;
138  }
139  else
140  {
141  if (is_array($a_val))
142  {
143  foreach ($a_val as $k => $v)
144  {
145  $this->levels[$k] = $v;
146  }
147  }
148  }
149  }
+ Here is the caller graph for this function:

◆ setTopSkillId()

ilSkillSelfEvaluation::setTopSkillId (   $a_val)

Set top skill id.

Parameters
integertop skill id

Definition at line 73 of file class.ilSkillSelfEvaluation.php.

Referenced by read().

74  {
75  $this->top_skill_id = $a_val;
76  }
+ Here is the caller graph for this function:

◆ setUserId()

ilSkillSelfEvaluation::setUserId (   $a_val)

Set user id.

Parameters
integeruser id

Definition at line 53 of file class.ilSkillSelfEvaluation.php.

Referenced by read().

54  {
55  $this->user_id = $a_val;
56  }
+ Here is the caller graph for this function:

◆ update()

ilSkillSelfEvaluation::update ( )

Update self evaluation.

Definition at line 231 of file class.ilSkillSelfEvaluation.php.

References $ilDB, getId(), and getLevels().

232  {
233  global $ilDB;
234 
235  $ilDB->manipulate("UPDATE skl_self_eval SET ".
236  " user_id = ".$ilDB->quote($this->getUserId(), "integer").
237  ", top_skill_id = ".$ilDB->quote($this->getTopSkillId(), "integer").
238  ", last_update = ".$ilDB->now().
239  " WHERE id = ".$ilDB->quote($this->getId(), "integer")
240  );
241 
242  $ilDB->manipulate("DELETE FROM skl_self_eval_level WHERE "
243  ." self_eval_id = ".$ilDB->quote($this->getId(), "integer")
244  );
245 
246  $levels = $this->getLevels();
247  if (is_array($levels))
248  {
249  foreach ($levels as $skill_id => $level_id)
250  {
251  $ilDB->manipulate("INSERT INTO skl_self_eval_level ".
252  "(self_eval_id, skill_id, level_id) VALUES (".
253  $ilDB->quote($this->getId(), "integer").",".
254  $ilDB->quote($skill_id, "integer").",".
255  $ilDB->quote($level_id, "integer").
256  ")");
257  }
258  }
259  }
global $ilDB
+ Here is the call graph for this function:

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