ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
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 24 of file class.ilSkillSelfEvaluation.php.

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

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

Member Function Documentation

◆ create()

ilSkillSelfEvaluation::create ( )

Create self evaluation.

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

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

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

◆ delete()

ilSkillSelfEvaluation::delete ( )

Delete self evaluation.

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

References $db, and $ilDB.

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

◆ determineSteps()

static ilSkillSelfEvaluation::determineSteps (   $a_sn_id)
static

Determine steps.

Parameters

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

References $steps, and array.

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

390  {
391  $steps = array();
392  if ($a_sn_id > 0) {
393  include_once("./Services/Skill/classes/class.ilSkillTree.php");
394  include_once("./Services/Skill/classes/class.ilSkillSelfEvalSkillTableGUI.php");
395  $stree = new ilSkillTree();
396 
397  if ($stree->isInTree($a_sn_id)) {
398  $cnode = $stree->getNodeData($a_sn_id);
399  $childs = $stree->getSubTree($cnode);
400  foreach ($childs as $child) {
401  if ($child["type"] == "skll") {
402  $steps[] = $child["child"];
403  }
404  }
405  }
406  }
407  return $steps;
408  }
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 281 of file class.ilSkillSelfEvaluation.php.

References $DIC, $ilDB, and array.

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

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

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

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

111  {
112  return $this->created;
113  }

◆ getId()

ilSkillSelfEvaluation::getId ( )

Get id.

Returns
integer id

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

References $id.

Referenced by update().

51  {
52  return $this->id;
53  }
if(!array_key_exists('StateId', $_REQUEST)) $id
+ Here is the caller graph for this function:

◆ getLastUpdate()

ilSkillSelfEvaluation::getLastUpdate ( )

Get last update.

Returns
timestamp last update

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

131  {
132  return $this->last_update;
133  }

◆ getLevels()

ilSkillSelfEvaluation::getLevels ( )

Get level.

Returns
array level

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

Referenced by create(), and update().

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

◆ getTopSkillId()

ilSkillSelfEvaluation::getTopSkillId ( )

Get top skill id.

Returns
integer top skill id

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

91  {
92  return $this->top_skill_id;
93  }

◆ getUserId()

ilSkillSelfEvaluation::getUserId ( )

Get user id.

Returns
integer user id

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

71  {
72  return $this->user_id;
73  }

◆ lookupProperty()

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

Lookup property.

Parameters
idlevel id
Returns
mixed property value

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

References $DIC, and $ilDB.

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

◆ read()

ilSkillSelfEvaluation::read ( )

Read.

Parameters

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

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

Referenced by __construct().

170  {
171  $ilDB = $this->db;
172 
173  $set = $ilDB->query(
174  "SELECT * FROM skl_self_eval WHERE " .
175  " id = " . $ilDB->quote($this->getId(), "integer")
176  );
177  if ($rec = $ilDB->fetchAssoc($set)) {
178  $this->setUserId($rec["user_id"]);
179  $this->setTopSkillId($rec["top_skill_id"]);
180  $this->setCreated($rec["created"]);
181  $this->setLastUpdate($rec["last_update"]);
182  }
183 
184  // levels
185  $set = $ilDB->query(
186  "SELECT * FROM skl_self_eval_level WHERE " .
187  " self_eval_id = " . $ilDB->quote($this->getId(), "integer")
188  );
189  $levels = array();
190  while ($rec = $ilDB->fetchAssoc($set)) {
191  $levels[$rec["skill_id"]] = $rec["level_id"];
192  }
193  $this->setLevels($levels);
194  }
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 100 of file class.ilSkillSelfEvaluation.php.

Referenced by read().

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

◆ setId()

ilSkillSelfEvaluation::setId (   $a_val)

Set id.

Parameters
integerid

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

Referenced by __construct(), and create().

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

◆ setLastUpdate()

ilSkillSelfEvaluation::setLastUpdate (   $a_val)

Set last update.

Parameters
timestamplast update

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

Referenced by read().

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

References levels.

Referenced by read().

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

◆ setTopSkillId()

ilSkillSelfEvaluation::setTopSkillId (   $a_val)

Set top skill id.

Parameters
integertop skill id

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

Referenced by read().

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

◆ setUserId()

ilSkillSelfEvaluation::setUserId (   $a_val)

Set user id.

Parameters
integeruser id

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

Referenced by read().

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

◆ update()

ilSkillSelfEvaluation::update ( )

Update self evaluation.

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

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

231  {
232  $ilDB = $this->db;
233 
234  $ilDB->manipulate(
235  "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(
243  "DELETE FROM skl_self_eval_level WHERE "
244  . " self_eval_id = " . $ilDB->quote($this->getId(), "integer")
245  );
246 
247  $levels = $this->getLevels();
248  if (is_array($levels)) {
249  foreach ($levels as $skill_id => $level_id) {
250  $ilDB->manipulate("INSERT INTO skl_self_eval_level " .
251  "(self_eval_id, skill_id, level_id) VALUES (" .
252  $ilDB->quote($this->getId(), "integer") . "," .
253  $ilDB->quote($skill_id, "integer") . "," .
254  $ilDB->quote($level_id, "integer") .
255  ")");
256  }
257  }
258  }
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilSkillSelfEvaluation::$db
protected

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

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


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