ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 

Protected Attributes

 $db
 

Detailed Description

Self evaluation application class.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilSkillSelfEvaluation::__construct (   $a_id = 0)

Constructor.

Parameters

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

References $DIC, read(), and setId().

23  {
24  global $DIC;
25 
26  $this->db = $DIC->database();
27  if ($a_id > 0) {
28  $this->setId($a_id);
29  $this->read();
30  }
31  }
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilSkillSelfEvaluation::create ( )

Create self evaluation.

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

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

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

◆ delete()

ilSkillSelfEvaluation::delete ( )

Delete self evaluation.

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

References $db, and $ilDB.

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

◆ determineSteps()

static ilSkillSelfEvaluation::determineSteps (   $a_sn_id)
static

Determine steps.

Parameters

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

References $steps.

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

386  {
387  $steps = array();
388  if ($a_sn_id > 0) {
389  $stree = new ilSkillTree();
390 
391  if ($stree->isInTree($a_sn_id)) {
392  $cnode = $stree->getNodeData($a_sn_id);
393  $childs = $stree->getSubTree($cnode);
394  foreach ($childs as $child) {
395  if ($child["type"] == "skll") {
396  $steps[] = $child["child"];
397  }
398  }
399  }
400  }
401  return $steps;
402  }
Skill tree.
$steps
Definition: latex.php:3
+ 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 279 of file class.ilSkillSelfEvaluation.php.

References $DIC, and $ilDB.

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

280  {
281  global $DIC;
282 
283  $ilDB = $DIC->database();
284 
285  $set = $ilDB->query(
286  "SELECT * FROM skl_self_eval WHERE user_id = " .
287  $ilDB->quote($a_user, "integer") . " " .
288  "ORDER BY last_update DESC"
289  );
290 
291  $self_evaluation = array();
292 
293  $top_skills = array();
294  while ($rec = $ilDB->fetchAssoc($set)) {
295  if (!$a_one_per_top_skill || !in_array($rec["top_skill_id"], $top_skills)) {
296  $self_evaluation[] = $rec;
297  $top_skills[] = $rec["top_skill_id"];
298  }
299  }
300 
301  return $self_evaluation;
302  }
global $DIC
Definition: goto.php:24
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 330 of file class.ilSkillSelfEvaluation.php.

References $DIC, and $lng.

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

◆ getCreated()

ilSkillSelfEvaluation::getCreated ( )

Get created at.

Returns
timestamp created at

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

109  {
110  return $this->created;
111  }

◆ getId()

ilSkillSelfEvaluation::getId ( )

Get id.

Returns
integer id

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

Referenced by update().

49  {
50  return $this->id;
51  }
+ Here is the caller graph for this function:

◆ getLastUpdate()

ilSkillSelfEvaluation::getLastUpdate ( )

Get last update.

Returns
timestamp last update

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

129  {
130  return $this->last_update;
131  }

◆ 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 88 of file class.ilSkillSelfEvaluation.php.

89  {
90  return $this->top_skill_id;
91  }

◆ getUserId()

ilSkillSelfEvaluation::getUserId ( )

Get user id.

Returns
integer user id

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

69  {
70  return $this->user_id;
71  }

◆ 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 $DIC, and $ilDB.

311  {
312  global $DIC;
313 
314  $ilDB = $DIC->database();
315 
316  $set = $ilDB->query(
317  "SELECT $a_prop FROM skl_self_eval WHERE " .
318  " id = " . $ilDB->quote($a_id, "integer")
319  );
320  $rec = $ilDB->fetchAssoc($set);
321  return $rec[$a_prop];
322  }
global $DIC
Definition: goto.php:24
global $ilDB

◆ read()

ilSkillSelfEvaluation::read ( )

Read.

Parameters

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

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

Referenced by __construct().

168  {
169  $ilDB = $this->db;
170 
171  $set = $ilDB->query(
172  "SELECT * FROM skl_self_eval WHERE " .
173  " id = " . $ilDB->quote($this->getId(), "integer")
174  );
175  if ($rec = $ilDB->fetchAssoc($set)) {
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(
184  "SELECT * FROM skl_self_eval_level WHERE " .
185  " self_eval_id = " . $ilDB->quote($this->getId(), "integer")
186  );
187  $levels = array();
188  while ($rec = $ilDB->fetchAssoc($set)) {
189  $levels[$rec["skill_id"]] = $rec["level_id"];
190  }
191  $this->setLevels($levels);
192  }
setLevels($a_val, $a_keep_existing=false)
Set level.
setTopSkillId($a_val)
Set top skill id.
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 98 of file class.ilSkillSelfEvaluation.php.

Referenced by read().

99  {
100  $this->created = $a_val;
101  }
+ Here is the caller graph for this function:

◆ setId()

ilSkillSelfEvaluation::setId (   $a_val)

Set id.

Parameters
integerid

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

Referenced by __construct(), and create().

39  {
40  $this->id = $a_val;
41  }
+ Here is the caller graph for this function:

◆ setLastUpdate()

ilSkillSelfEvaluation::setLastUpdate (   $a_val)

Set last update.

Parameters
timestamplast update

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

Referenced by read().

119  {
120  $this->last_update = $a_val;
121  }
+ 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 138 of file class.ilSkillSelfEvaluation.php.

Referenced by read().

139  {
140  if (!$a_keep_existing) {
141  $this->levels = $a_val;
142  } else {
143  if (is_array($a_val)) {
144  foreach ($a_val as $k => $v) {
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 78 of file class.ilSkillSelfEvaluation.php.

Referenced by read().

79  {
80  $this->top_skill_id = $a_val;
81  }
+ Here is the caller graph for this function:

◆ setUserId()

ilSkillSelfEvaluation::setUserId (   $a_val)

Set user id.

Parameters
integeruser id

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

Referenced by read().

59  {
60  $this->user_id = $a_val;
61  }
+ Here is the caller graph for this function:

◆ update()

ilSkillSelfEvaluation::update ( )

Update self evaluation.

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

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

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

Field Documentation

◆ $db

ilSkillSelfEvaluation::$db
protected

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

Referenced by create(), delete(), read(), and update().


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