ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 
 writeAndAddAppraiseeSkills (int $user_id)
 Write appraisee skills and add them to user's competence records. More...
 
 writeAndAddSelfEvalSkills (int $user_id)
 Write skills on self evaluation and add them to user's competence records. More...
 

Static Public Member Functions

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

Protected Attributes

 $db
 
 $q_skill = array()
 
 $log
 

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

return

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

33 {
34 global $DIC;
35
36 $this->db = $DIC->database();
37 $this->survey = $a_survey;
38 $this->read();
39 $this->log = ilLoggerFactory::getLogger("svy");
40 }
static getLogger($a_component_id)
Get component logger.
$DIC
Definition: xapitoken.php:46

References $DIC, ilLoggerFactory\getLogger(), and read().

+ 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 106 of file class.ilSurveySkill.php.

107 {
109
110 $ilDB->replace(
111 "svy_quest_skill",
112 array("q_id" => array("integer", $a_question_id)),
113 array(
114 "survey_id" => array("integer", $this->survey->getId()),
115 "base_skill_id" => array("integer", $a_base_skill_id),
116 "tref_id" => array("integer", $a_tref_id)
117 )
118 );
119 $this->q_skill[$a_question_id] = array("q_id" => $a_question_id,
120 "base_skill_id" => $a_base_skill_id,
121 "tref_id" => $a_tref_id);
122
123 // add usage
124 ilSkillUsage::setUsage($this->survey->getId(), $a_base_skill_id, $a_tref_id);
125 }
static setUsage($a_obj_id, $a_skill_id, $a_tref_id, $a_use=true)
Set usage.
global $ilDB

References $db, $ilDB, and ilSkillUsage\setUsage().

+ Here is the call graph for this function:

◆ determineMaxScale()

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

Determine max scales and questions.

Parameters

return

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

329 {
330 $ssk = new ilSurveySkill($this->survey);
331 $question_ids = $ssk->getQuestionsForSkill($a_base_skill, $a_tref_id);
332 $scale_sum = 0;
333 foreach ($question_ids as $q_id) {
335 if (!is_object($q)) {
336 continue;
337 }
338 $cats = $q->getCategories();
339 $max_scale = 0;
340 for ($i = 0; $i <= $cats->getCategoryCount(); $i++) {
341 $c = $cats->getCategory($i);
342 $n = $c->neutral;
343 $s = $c->scale;
344 if (!$c->neutral) {
345 if ($c->scale > $max_scale) {
346 $max_scale = $c->scale;
347 }
348 }
349 }
350 $scale_sum += $max_scale;
351 }
352
353 return $scale_sum;
354 }
$n
Definition: RandomTest.php:85
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
Skill/Competence handling in surveys.
$i
Definition: metadata.php:24

References Vendor\Package\$c, $i, $n, and SurveyQuestion\_instanciateQuestion().

+ 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 244 of file class.ilSurveySkill.php.

245 {
246 $skills = array();
247
248 // get all skills
249 $opts = $this->getAllAssignedSkillsAsOptions();
250 foreach ($opts as $k => $title) {
251 $k = explode(":", $k);
252
253 $bs = new ilBasicSkill((int) $k[0]);
254 $ld = $bs->getLevelData();
255
256 $skills[] = array(
257 "base_skill_id" => (int) $k[0],
258 "tref_id" => (int) $k[1],
259 "skill_title" => $title,
260 "level_data" => $ld
261 );
262 }
263
264 if (!$a_self_eval) {
265 $finished_ids = $this->survey->getFinishedIdsForAppraiseeId($a_appraisee_id, true);
266 } else {
267 $finished_id = $this->survey->getFinishedIdForAppraiseeIdAndRaterId($a_appraisee_id, $a_appraisee_id);
268 if ($finished_id > 0) {
269 $finished_ids = array($finished_id);
270 }
271 }
272
273 if (!is_array($finished_ids)) {
274 $finished_ids = array(-1);
275 }
276
277 $results = $this->survey->getUserSpecificResults($finished_ids);
278 $this->log->debug("Finished IDS: " . print_r($finished_ids, true));
279 foreach ($skills as $k => $s) {
280 $q_ids = $this->getQuestionsForSkill($s["base_skill_id"], $s["tref_id"]);
281 $this->log->debug("Skill: " . $s["base_skill_id"] . ":" . $s["tref_id"] . ", Questions: " . implode(",", $q_ids));
282 $mean_sum = 0;
283 foreach ($q_ids as $q_id) {
284 $qmean = 0;
285 if (is_array($results[$q_id])) {
286 $cnt = 0;
287 $sum = 0;
288 foreach ($results[$q_id] as $uid => $answer) { // answer of user $uid for question $q_id
289 // $answer has the scale values as keys and the answer texts as values.
290 // In case of single choice this is an array with one key => value pair.
291 // For multiple choice questions (currently not supported for being used for competences)
292 // multiple elements may be in the array (in the future).
293 $scale_values = array_keys($answer); // scale values of the answer
294 $this->log->debug("User answer (scale values): " . print_r($scale_values, true));
295 $sum += array_sum($scale_values);
296 $cnt += sizeof($scale_values); // nr of answers (always one in the case of single choice)
297 }
298 if ($cnt > 0) {
299 $qmean = $sum / $cnt;
300 }
301 $this->log->debug("MEAN: " . $qmean);
302 }
303 $mean_sum += $qmean;
304 $this->log->debug("MEAN SUM: " . $mean_sum);
305 }
306 $skills[$k]["mean_sum"] = $mean_sum;
307
308 $skthr = new ilSurveySkillThresholds($this->survey);
309 $thresholds = $skthr->getThresholds();
310 foreach ($skills[$k]["level_data"] as $l) {
311 $t = $thresholds[$l["id"]][$s["tref_id"]];
312 if ($t > 0 && $mean_sum >= $t) {
313 $skills[$k]["new_level"] = $l["title"];
314 $skills[$k]["new_level_id"] = $l["id"];
315 }
316 }
317 }
318 return $skills;
319 }
Skill tresholds for 360 surveys.
getAllAssignedSkillsAsOptions()
Get skill for question.
getQuestionsForSkill($a_base_skill_id, $a_tref_id)
Get questions for skill.
$results

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

Referenced by writeAndAddAppraiseeSkills(), and writeAndAddSelfEvalSkills().

+ 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.

229 {
230 $skills = array();
231 foreach ($this->q_skill as $sk) {
232 $skills[$sk["base_skill_id"] . ":" . $sk["tref_id"]] =
233 ilBasicSkill::_lookupTitle($sk["base_skill_id"]);
234 }
235 return $skills;
236 }
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.

References ilSkillTreeNode\_lookupTitle().

Referenced by determineSkillLevelsForAppraisee().

+ 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

return

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

87 {
88 $q_ids = array();
89 foreach ($this->q_skill as $q_id => $s) {
90 if ($s["base_skill_id"] == $a_base_skill_id &&
91 $s["tref_id"] == $a_tref_id) {
92 $q_ids[] = $q_id;
93 }
94 }
95 return $q_ids;
96 }

Referenced by determineSkillLevelsForAppraisee().

+ 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 72 of file class.ilSurveySkill.php.

73 {
74 if (isset($this->q_skill[$a_question_id])) {
75 return $this->q_skill[$a_question_id];
76 }
77 return false;
78 }

◆ handleQuestionDeletion()

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

Remove question skill assignment.

Parameters
int$a_question_idquestion id

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

163 {
164 global $DIC;
165
166 $ilDB = $DIC->database();
167 if (ilObject::_lookupType($a_obj_id) == "svy") {
168 // mantis 11691
169 $svy = new ilObjSurvey($a_obj_id, false);
170 $svy_skill = new ilSurveySkill($svy);
171 $svy_skill->removeQuestionSkillAssignment($a_question_id);
172 }
173 }
Class ilObjSurvey.
static _lookupType($a_id, $a_reference=false)
lookup object type

References $DIC, $ilDB, and ilObject\_lookupType().

Referenced by SurveyQuestion\delete().

+ 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

return

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

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

References $db, and $ilDB.

Referenced by removeUsagesOfSkills().

+ Here is the caller graph for this function:

◆ read()

ilSurveySkill::read ( )

Read.

Parameters

return

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

49 {
51
52 $set = $ilDB->query(
53 "SELECT * FROM svy_quest_skill " .
54 " WHERE survey_id = " . $ilDB->quote($this->survey->getId(), "integer")
55 );
56
57 while ($rec = $ilDB->fetchAssoc($set)) {
58 if (SurveyQuestion::_questionExists($rec["q_id"])) {
59 $this->q_skill[$rec["q_id"]] = array("q_id" => $rec["q_id"],
60 "base_skill_id" => $rec["base_skill_id"],
61 "tref_id" => $rec["tref_id"]);
62 }
63 }
64 }
static _questionExists($question_id)
Returns true if the question already exists in the database.

References $db, $ilDB, and SurveyQuestion\_questionExists().

Referenced by __construct().

+ 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 132 of file class.ilSurveySkill.php.

133 {
135
136 // read skills that are assigned to the quesiton
137 $set = $ilDB->query(
138 "SELECT * FROM svy_quest_skill " .
139 " WHERE q_id = " . $ilDB->quote($a_question_id, "integer")
140 );
141 $skills = array();
142 while ($rec = $ilDB->fetchAssoc($set)) {
143 $skills[] = array("skill_id" => $rec["base_skill_id"],
144 "tref_id" => $rec["tref_id"]);
145 }
146
147 // remove assignment of question
148 $ilDB->manipulate(
149 "DELETE FROM svy_quest_skill WHERE " .
150 " q_id = " . $ilDB->quote($a_question_id, "integer")
151 );
152 unset($this->q_skill[$a_question_id]);
153
154 $this->removeUsagesOfSkills($skills);
155 }
removeUsagesOfSkills($a_skills)
Remove usages of skills.

References $db, $ilDB, and removeUsagesOfSkills().

+ 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 181 of file class.ilSurveySkill.php.

182 {
183 $used_skills = array();
184 foreach ($a_skills as $skill) {
185 if ($this->isSkillAssignedToQuestion($skill["skill_id"], $skill["tref_id"])) {
186 $used_skills[] = $skill["skill_id"] . ":" . $skill["tref_id"];
187 }
188 }
189 reset($a_skills);
190
191 // now remove all usages that have been confirmed
192 foreach ($a_skills as $skill) {
193 if (!in_array($skill["skill_id"] . ":" . $skill["tref_id"], $used_skills)) {
194 ilSkillUsage::setUsage($this->survey->getId(), $skill["skill_id"], $skill["tref_id"], false);
195 }
196 }
197 }
isSkillAssignedToQuestion($a_skill_id, $a_tref_id)
Is skill assigned to any question?

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

Referenced by removeQuestionSkillAssignment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeAndAddAppraiseeSkills()

ilSurveySkill::writeAndAddAppraiseeSkills ( int  $user_id)

Write appraisee skills and add them to user's competence records.

Parameters
int$user_id

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

362 {
363 // write raters evaluation
364 $new_levels = $this->determineSkillLevelsForAppraisee($user_id);
365 foreach ($new_levels as $nl) {
366 if ($nl["new_level_id"] > 0) {
368 $nl["new_level_id"],
369 $user_id,
370 $this->survey->getRefId(),
371 $nl["tref_id"],
373 true
374 );
375
376 if ($nl["tref_id"] > 0) {
377 ilPersonalSkill::addPersonalSkill($user_id, $nl["tref_id"]);
378 } else {
379 ilPersonalSkill::addPersonalSkill($user_id, $nl["base_skill_id"]);
380 }
381 }
382 }
383
384 // write self evaluation
385 $this->writeAndAddSelfEvalSkills($user_id);
386 }
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.
static addPersonalSkill($a_user_id, $a_skill_node_id)
Add personal skill.
determineSkillLevelsForAppraisee($a_appraisee_id, $a_self_eval=false)
Determine skill levels for appraisee.
writeAndAddSelfEvalSkills(int $user_id)
Write skills on self evaluation and add them to user's competence records.

References ilBasicSkill\ACHIEVED, ilPersonalSkill\addPersonalSkill(), determineSkillLevelsForAppraisee(), writeAndAddSelfEvalSkills(), and ilBasicSkill\writeUserSkillLevelStatus().

+ Here is the call graph for this function:

◆ writeAndAddSelfEvalSkills()

ilSurveySkill::writeAndAddSelfEvalSkills ( int  $user_id)

Write skills on self evaluation and add them to user's competence records.

Parameters
int$user_id

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

394 {
395 if ($user_id > 0 && in_array($this->survey->getMode(), [ilObjSurvey::MODE_SELF_EVAL, ilObjSurvey::MODE_360])) {
396 $new_levels = $this->determineSkillLevelsForAppraisee($user_id, true);
397 foreach ($new_levels as $nl) {
398 if ($nl["new_level_id"] > 0) {
400 $nl["new_level_id"],
401 $user_id,
402 $this->survey->getRefId(),
403 $nl["tref_id"],
405 true,
406 1
407 );
408
409 if ($nl["tref_id"] > 0) {
410 ilPersonalSkill::addPersonalSkill($user_id, $nl["tref_id"]);
411 } else {
412 ilPersonalSkill::addPersonalSkill($user_id, $nl["base_skill_id"]);
413 }
414 }
415 }
416 }
417 }

References ilBasicSkill\ACHIEVED, ilPersonalSkill\addPersonalSkill(), determineSkillLevelsForAppraisee(), ilObjSurvey\MODE_360, ilObjSurvey\MODE_SELF_EVAL, and ilBasicSkill\writeUserSkillLevelStatus().

Referenced by writeAndAddAppraiseeSkills().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilSurveySkill::$db
protected

◆ $log

ilSurveySkill::$log
protected

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

◆ $q_skill

ilSurveySkill::$q_skill = array()
protected

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


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