ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilSurveySkill Class Reference

Skill/Competence handling in surveys. More...

+ Collaboration diagram for ilSurveySkill:

Public Member Functions

 __construct (ilObjSurvey $a_survey)
 Constructor. More...
 
 read ()
 Read. More...
 
 getSkillForQuestion ($a_question_id)
 Get skill for question. More...
 
 getQuestionsForSkill ($a_base_skill_id, $a_tref_id)
 Get questions for skill. More...
 
 addQuestionSkillAssignment ($a_question_id, $a_base_skill_id, $a_tref_id)
 Add survey question to skill assignment. More...
 
 removeQuestionSkillAssignment ($a_question_id)
 Remove question skill assignment. More...
 
 removeUsagesOfSkills ($a_skills)
 Remove usages of skills. More...
 
 isSkillAssignedToQuestion ($a_skill_id, $a_tref_id)
 Is skill assigned to any question? More...
 
 getAllAssignedSkillsAsOptions ()
 Get skill for question. More...
 
 determineSkillLevelsForAppraisee ($a_appraisee_id, $a_self_eval=false)
 Determine skill levels for appraisee. More...
 
 determineMaxScale ($a_base_skill, $a_tref_id=0)
 Determine max scales and questions. More...
 
 writeAppraiseeSkills ($a_app_id)
 Write appraisee skills. More...
 

Static Public Member Functions

static handleQuestionDeletion ($a_question_id, $a_obj_id)
 Remove question skill assignment. More...
 

Protected Attributes

 $q_skill = array()
 

Detailed Description

Skill/Competence handling in surveys.

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.ilSurveySkill.php.

Constructor & Destructor Documentation

◆ __construct()

ilSurveySkill::__construct ( ilObjSurvey  $a_survey)

Constructor.

Parameters

Definition at line 23 of file class.ilSurveySkill.php.

References read().

24  {
25  $this->survey = $a_survey;
26  $this->read();
27  }
+ Here is the call graph for this function:

Member Function Documentation

◆ addQuestionSkillAssignment()

ilSurveySkill::addQuestionSkillAssignment (   $a_question_id,
  $a_base_skill_id,
  $a_tref_id 
)

Add survey question to skill assignment.

Parameters
int$a_question_idquestion id
int$a_base_skill_idbase skill id
int$a_tref_idskill template reference id (0, if no template involved)

Definition at line 99 of file class.ilSurveySkill.php.

References $ilDB, and ilSkillUsage\setUsage().

100  {
101  global $ilDB;
102 
103  $ilDB->replace("svy_quest_skill",
104  array("q_id" => array("integer", $a_question_id)),
105  array(
106  "survey_id" => array("integer", $this->survey->getId()),
107  "base_skill_id" => array("integer", $a_base_skill_id),
108  "tref_id" => array("integer", $a_tref_id)
109  )
110  );
111  $this->q_skill[$a_question_id] = array("q_id" => $a_question_id,
112  "base_skill_id" => $a_base_skill_id,
113  "tref_id" => $a_tref_id);
114 
115  // add usage
116  include_once("./Services/Skill/classes/class.ilSkillUsage.php");
117  ilSkillUsage::setUsage($this->survey->getId(), $a_base_skill_id, $a_tref_id);
118 
119  }
static setUsage($a_obj_id, $a_skill_id, $a_tref_id, $a_use=true)
Set usage.
global $ilDB
+ Here is the call graph for this function:

◆ determineMaxScale()

ilSurveySkill::determineMaxScale (   $a_base_skill,
  $a_tref_id = 0 
)

Determine max scales and questions.

Parameters

Definition at line 338 of file class.ilSurveySkill.php.

References $n, and SurveyQuestion\_instanciateQuestion().

339  {
340  include_once("./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php");
341  include_once("./Modules/Survey/classes/class.ilSurveySkill.php");
342  $ssk = new ilSurveySkill($this->survey);
343  $question_ids = $ssk->getQuestionsForSkill($a_base_skill, $a_tref_id);
344  $scale_sum = 0;
345  foreach ($question_ids as $q_id)
346  {
348  if(!is_object($q))
349  {
350  continue;
351  }
352  $cats = $q->getCategories();
353  $max_scale = 0;
354  for($i = 0; $i<= $cats->getCategoryCount(); $i++)
355  {
356  $c = $cats->getCategory($i);
357  $n = $c->neutral;
358  $s = $c->scale;
359  if (!$c->neutral)
360  {
361  if ($c->scale > $max_scale)
362  {
363  $max_scale = $c->scale;
364  }
365  }
366  }
367  $scale_sum+= $max_scale;
368  }
369 
370  return $scale_sum;
371  }
Skill/Competence handling in surveys.
$n
Definition: RandomTest.php:80
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
+ Here is the call graph for this function:

◆ determineSkillLevelsForAppraisee()

ilSurveySkill::determineSkillLevelsForAppraisee (   $a_appraisee_id,
  $a_self_eval = false 
)

Determine skill levels for appraisee.

Parameters
$a_appraisee_idint user id of appraisee
Returns
array array with lots of information

Definition at line 246 of file class.ilSurveySkill.php.

References $r, $results, $t, getAllAssignedSkillsAsOptions(), and getQuestionsForSkill().

Referenced by writeAppraiseeSkills().

247  {
248  $skills = array();
249 
250  // get all skills
251  $opts = $this->getAllAssignedSkillsAsOptions();
252  foreach ($opts as $k => $title)
253  {
254  $k = explode(":", $k);
255 
256  $bs = new ilBasicSkill((int) $k[0]);
257  $ld = $bs->getLevelData();
258 
259  $skills[] = array(
260  "base_skill_id" => (int) $k[0],
261  "tref_id" => (int) $k[1],
262  "skill_title" => $title,
263  "level_data" => $ld
264  );
265  }
266 
267  if (!$a_self_eval)
268  {
269  $finished_ids = $this->survey->getFinishedIdsForAppraiseeId($a_appraisee_id, true);
270  }
271  else
272  {
273  $finished_id = $this->survey->getFinishedIdForAppraiseeIdAndRaterId($a_appraisee_id, $a_appraisee_id);
274  if ($finished_id > 0)
275  {
276  $finished_ids = array($finished_id);
277  }
278  }
279 
280  if(!sizeof($finished_ids))
281  {
282  $finished_ids = array(-1);
283  }
284 
285  $results = $this->survey->getUserSpecificResults($finished_ids);
286  foreach ($skills as $k => $s)
287  {
288  $q_ids = $this->getQuestionsForSkill($s["base_skill_id"], $s["tref_id"]);
289  $mean_sum = 0;
290  foreach ($q_ids as $q_id)
291  {
292  $qmean = 0;
293  if (is_array($results[$q_id]))
294  {
295  $cnt = 0;
296  $sum = 0;
297  foreach ($results[$q_id] as $r)
298  {
299  // this is a workaround, since we only get arrays from
300  // getUserSpecificResults()
301  $r = explode(" - ", $r);
302  $sum+= (int) $r[0];
303  $cnt++;
304  }
305  if ($cnt > 0)
306  {
307  $qmean = $sum/$cnt;
308  }
309  }
310  $mean_sum+= $qmean;
311  }
312  $skills[$k]["mean_sum"] = $mean_sum;
313 
314  include_once("./Modules/Survey/classes/class.ilSurveySkillThresholds.php");
315  $skthr = new ilSurveySkillThresholds($this->survey);
316  $thresholds = $skthr->getThresholds();
317  foreach ($skills[$k]["level_data"] as $l)
318  {
319  $t = $thresholds[$l["id"]][$s["tref_id"]];
320  if ($t > 0 && $mean_sum >= $t)
321  {
322  $skills[$k]["new_level"] = $l["title"];
323  $skills[$k]["new_level_id"] = $l["id"];
324  }
325  }
326  }
327 
328  return $skills;
329  }
Skill tresholds for 360 surveys.
$results
getAllAssignedSkillsAsOptions()
Get skill for question.
getQuestionsForSkill($a_base_skill_id, $a_tref_id)
Get questions for skill.
Basic Skill.
$r
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllAssignedSkillsAsOptions()

ilSurveySkill::getAllAssignedSkillsAsOptions ( )

Get skill for question.

Parameters
int$a_question_idquestion id
Returns
array skill array

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

References ilSkillTreeNode\_lookupTitle().

Referenced by determineSkillLevelsForAppraisee().

229  {
230  $skills = array();
231  include_once("./Services/Skill/classes/class.ilBasicSkill.php");
232  foreach ($this->q_skill as $sk)
233  {
234  $skills[$sk["base_skill_id"].":".$sk["tref_id"]] =
235  ilBasicSkill::_lookupTitle($sk["base_skill_id"]);
236  }
237  return $skills;
238  }
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionsForSkill()

ilSurveySkill::getQuestionsForSkill (   $a_base_skill_id,
  $a_tref_id 
)

Get questions for skill.

Parameters

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

Referenced by determineSkillLevelsForAppraisee().

78  {
79  $q_ids = array();
80  foreach ($this->q_skill as $q_id => $s)
81  {
82  if ($s["base_skill_id"] == $a_base_skill_id &&
83  $s["tref_id"] == $a_tref_id)
84  {
85  $q_ids[] = $q_id;
86  }
87  }
88  return $q_ids;
89  }
+ Here is the caller graph for this function:

◆ getSkillForQuestion()

ilSurveySkill::getSkillForQuestion (   $a_question_id)

Get skill for question.

Parameters
int$a_question_idquestion id
Returns
array skill array

Definition at line 62 of file class.ilSurveySkill.php.

63  {
64  if (isset($this->q_skill[$a_question_id]))
65  {
66  return $this->q_skill[$a_question_id];
67  }
68  return false;
69  }

◆ handleQuestionDeletion()

static ilSurveySkill::handleQuestionDeletion (   $a_question_id,
  $a_obj_id 
)
static

Remove question skill assignment.

Parameters
int$a_question_idquestion id

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

References $ilDB, and ilObject\_lookupType().

Referenced by SurveyQuestion\delete().

156  {
157  global $ilDB;
158  if (ilObject::_lookupType($a_obj_id) == "svy")
159  {
160  // mantis 11691
161  include_once './Modules/Survey/classes/class.ilObjSurvey.php';
162  $svy = new ilObjSurvey($a_obj_id, false);
163  $svy_skill = new ilSurveySkill($svy);
164  $svy_skill->removeQuestionSkillAssignment($a_question_id);
165  }
166  }
Skill/Competence handling in surveys.
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSkillAssignedToQuestion()

ilSurveySkill::isSkillAssignedToQuestion (   $a_skill_id,
  $a_tref_id 
)

Is skill assigned to any question?

Parameters

Definition at line 205 of file class.ilSurveySkill.php.

References $ilDB.

Referenced by removeUsagesOfSkills().

206  {
207  global $ilDB;
208 
209  $set = $ilDB->query("SELECT * FROM svy_quest_skill ".
210  " WHERE base_skill_id = ".$ilDB->quote($a_skill_id, "integer").
211  " AND tref_id = ".$ilDB->quote($a_tref_id, "integer").
212  " AND survey_id = ".$ilDB->quote($this->survey->getId(), "integer")
213  );
214  if ($rec = $ilDB->fetchAssoc($set))
215  {
216  return true;
217  }
218  return false;
219  }
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilSurveySkill::read ( )

Read.

Parameters

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

References $ilDB, and SurveyQuestion\_questionExists().

Referenced by __construct().

36  {
37  global $ilDB;
38 
39  $set = $ilDB->query("SELECT * FROM svy_quest_skill ".
40  " WHERE survey_id = ".$ilDB->quote($this->survey->getId(), "integer")
41  );
42 
43  include_once("./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php");
44 
45  while ($rec = $ilDB->fetchAssoc($set))
46  {
47  if (SurveyQuestion::_questionExists($rec["q_id"]))
48  {
49  $this->q_skill[$rec["q_id"]] = array("q_id" => $rec["q_id"],
50  "base_skill_id" => $rec["base_skill_id"],
51  "tref_id" => $rec["tref_id"]);
52  }
53  }
54  }
_questionExists($question_id)
Returns true if the question already exists in the database.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeQuestionSkillAssignment()

ilSurveySkill::removeQuestionSkillAssignment (   $a_question_id)

Remove question skill assignment.

Parameters
int$a_question_idquestion id

Definition at line 126 of file class.ilSurveySkill.php.

References $ilDB, and removeUsagesOfSkills().

127  {
128  global $ilDB;
129 
130  // read skills that are assigned to the quesiton
131  $set = $ilDB->query("SELECT * FROM svy_quest_skill ".
132  " WHERE q_id = ".$ilDB->quote($a_question_id, "integer")
133  );
134  $skills = array();
135  while ($rec = $ilDB->fetchAssoc($set))
136  {
137  $skills[] = array("skill_id" => $rec["base_skill_id"],
138  "tref_id" => $rec["tref_id"]);
139  }
140 
141  // remove assignment of question
142  $ilDB->manipulate("DELETE FROM svy_quest_skill WHERE ".
143  " q_id = ".$ilDB->quote($a_question_id, "integer")
144  );
145  unset($this->q_skill[$a_question_id]);
146 
147  $this->removeUsagesOfSkills($skills);
148  }
removeUsagesOfSkills($a_skills)
Remove usages of skills.
global $ilDB
+ Here is the call graph for this function:

◆ removeUsagesOfSkills()

ilSurveySkill::removeUsagesOfSkills (   $a_skills)

Remove usages of skills.

This function checks, if the skills are really not in use anymore

Parameters
arrayarray of arrays with keys "skill_id" and "tref_id"

Definition at line 174 of file class.ilSurveySkill.php.

References isSkillAssignedToQuestion(), and ilSkillUsage\setUsage().

Referenced by removeQuestionSkillAssignment().

175  {
176  $used_skills = array();
177  foreach ($a_skills as $skill)
178  {
179  if ($this->isSkillAssignedToQuestion($skill["skill_id"], $skill["tref_id"]))
180  {
181  $used_skills[] = $skill["skill_id"].":".$skill["tref_id"];
182  }
183  }
184  reset($a_skills);
185 
186  // now remove all usages that have been confirmed
187  include_once("./Services/Skill/classes/class.ilSkillUsage.php");
188 //var_dump($a_skills);
189 //var_dump($used_skills); exit;
190  foreach ($a_skills as $skill)
191  {
192  if (!in_array($skill["skill_id"].":".$skill["tref_id"], $used_skills))
193  {
194  ilSkillUsage::setUsage($this->survey->getId(), $skill["skill_id"], $skill["tref_id"], false);
195  }
196  }
197  }
static setUsage($a_obj_id, $a_skill_id, $a_tref_id, $a_use=true)
Set usage.
isSkillAssignedToQuestion($a_skill_id, $a_tref_id)
Is skill assigned to any question?
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeAppraiseeSkills()

ilSurveySkill::writeAppraiseeSkills (   $a_app_id)

Write appraisee skills.

Parameters

Definition at line 379 of file class.ilSurveySkill.php.

References ilBasicSkill\ACHIEVED, determineSkillLevelsForAppraisee(), and ilBasicSkill\writeUserSkillLevelStatus().

380  {
381  // write raters evaluation
382  $new_levels = $this->determineSkillLevelsForAppraisee($a_app_id);
383  foreach ($new_levels as $nl)
384  {
385  if ($nl["new_level_id"] > 0)
386  {
387  ilBasicSkill::writeUserSkillLevelStatus($nl["new_level_id"],
388  $a_app_id, $this->survey->getRefId(), $nl["tref_id"], ilBasicSkill::ACHIEVED, true);
389  }
390  }
391 
392  // patch optes start
393  // write self evaluation,
394  /*
395  $new_levels = $this->determineSkillLevelsForAppraisee($a_app_id, true);
396  foreach ($new_levels as $nl)
397  {
398  if ($nl["new_level_id"] > 0)
399  {
400  ilBasicSkill::writeUserSkillLevelStatus($nl["new_level_id"],
401  $a_app_id, $this->survey->getRefId(), $nl["tref_id"], ilBasicSkill::ACHIEVED, true, 1);
402  }
403  }*/
404  // patch optes end
405  }
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=0)
Write skill level status.
determineSkillLevelsForAppraisee($a_appraisee_id, $a_self_eval=false)
Determine skill levels for appraisee.
+ Here is the call graph for this function:

Field Documentation

◆ $q_skill

ilSurveySkill::$q_skill = array()
protected

Definition at line 14 of file class.ilSurveySkill.php.


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