ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilSurveySkill Class Reference

Skill/Competence handling in surveys. More...

+ Collaboration diagram for ilSurveySkill:

Public Member Functions

 __construct (ilObjSurvey $a_survey)
 
 read ()
 
 getSkillForQuestion (int $a_question_id)
 Get skill for question. More...
 
 getQuestionsForSkill (int $a_base_skill_id, int $a_tref_id)
 Get questions for skill. More...
 
 addQuestionSkillAssignment (int $a_question_id, int $a_base_skill_id, int $a_tref_id)
 Add survey question to skill assignment. More...
 
 removeQuestionSkillAssignment (int $a_question_id)
 
 removeUsagesOfSkills (array $a_skills)
 Remove usages of skills This function checks, if the skills are really not in use anymore. More...
 
 isSkillAssignedToQuestion (int $a_skill_id, int $a_tref_id)
 
 getAllAssignedSkillsAsOptions ()
 
 determineSkillLevelsForAppraisee (int $a_appraisee_id, bool $a_self_eval=false, int $finished_id=0)
 Determine skill levels for appraisee. More...
 
 determineMaxScale (int $a_base_skill, int $a_tref_id=0)
 
 writeAndAddAppraiseeSkills (int $user_id)
 Write appraisee skills and add them to user's competence records. More...
 
 writeAndAddIndFeedbackSkills (int $finished_id, int $appr_id, string $rater_id)
 
 writeAndAddSelfEvalSkills (int $user_id)
 Write skills on self evaluation and add them to user's competence records. More...
 

Static Public Member Functions

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

Protected Attributes

ilObjSurvey $survey
 
ilDBInterface $db
 
array $q_skill = array()
 
ilLogger $log
 
ILIAS Skill Service SkillProfileService $skill_profile_service
 
ILIAS Skill Service SkillPersonalService $skill_personal_service
 
ILIAS Skill Service SkillUsageService $skill_usage_service
 

Detailed Description

Skill/Competence handling in surveys.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilSurveySkill::__construct ( ilObjSurvey  $a_survey)

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

40 {
41 global $DIC;
42
43 $this->db = $DIC->database();
44 $this->survey = $a_survey;
45 $this->read();
46 $this->log = ilLoggerFactory::getLogger("svy");
47 $this->skill_profile_service = $DIC->skills()->profile();
48 $this->skill_personal_service = $DIC->skills()->personal();
49 $this->skill_usage_service = $DIC->skills()->usage();
50 }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addQuestionSkillAssignment()

ilSurveySkill::addQuestionSkillAssignment ( int  $a_question_id,
int  $a_base_skill_id,
int  $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 108 of file class.ilSurveySkill.php.

112 : void {
114
115 $ilDB->replace(
116 "svy_quest_skill",
117 array("q_id" => array("integer", $a_question_id)),
118 array(
119 "survey_id" => array("integer", $this->survey->getId()),
120 "base_skill_id" => array("integer", $a_base_skill_id),
121 "tref_id" => array("integer", $a_tref_id)
122 )
123 );
124 $this->q_skill[$a_question_id] = array(
125 "q_id" => $a_question_id,
126 "base_skill_id" => $a_base_skill_id,
127 "tref_id" => $a_tref_id
128 );
129
130 // add usage
131 $this->skill_usage_service->addUsage($this->survey->getId(), $a_base_skill_id, $a_tref_id);
132 }
ilDBInterface $db

◆ determineMaxScale()

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

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

349 : int {
350 $ssk = new ilSurveySkill($this->survey);
351 $question_ids = $ssk->getQuestionsForSkill($a_base_skill, $a_tref_id);
352 $scale_sum = 0;
353 foreach ($question_ids as $q_id) {
355 if (!is_object($q)) {
356 continue;
357 }
358 $cats = $q->getCategories();
359 $max_scale = 0;
360 for ($i = 0; $i < $cats->getCategoryCount(); $i++) {
361 $c = $cats->getCategory($i);
362 $n = (bool) $c->neutral;
363 $s = (int) $c->scale;
364 if (!$n) {
365 if ($s > $max_scale) {
366 $max_scale = $s;
367 }
368 }
369 }
370 $scale_sum += $max_scale;
371 }
372
373 return $scale_sum;
374 }
static _instanciateQuestion(int $question_id)
Get question object.
Skill/Competence handling in surveys.

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

+ Here is the call graph for this function:

◆ determineSkillLevelsForAppraisee()

ilSurveySkill::determineSkillLevelsForAppraisee ( int  $a_appraisee_id,
bool  $a_self_eval = false,
int  $finished_id = 0 
)

Determine skill levels for appraisee.

Returns
array array with lots of information
Todo:
introduce dto

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

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

◆ getAllAssignedSkillsAsOptions()

ilSurveySkill::getAllAssignedSkillsAsOptions ( )
Returns
array skill array

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

234 : array
235 {
236 $skills = array();
237 foreach ($this->q_skill as $sk) {
238 $skills[$sk["base_skill_id"] . ":" . $sk["tref_id"]] = ilBasicSkill::_lookupTitle($sk["base_skill_id"]);
239 }
240 return $skills;
241 }
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)

References ilSkillTreeNode\_lookupTitle().

+ Here is the call graph for this function:

◆ getQuestionsForSkill()

ilSurveySkill::getQuestionsForSkill ( int  $a_base_skill_id,
int  $a_tref_id 
)

Get questions for skill.

Returns
int[]

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

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

◆ getSkillForQuestion()

ilSurveySkill::getSkillForQuestion ( int  $a_question_id)

Get skill for question.

Parameters
int$a_question_idquestion id
Returns
?array{q_id: int, base_skill_id: int, tref_id: int} skill array

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

79 : ?array {
80 return $this->q_skill[$a_question_id] ?? null;
81 }

◆ handleQuestionDeletion()

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

Remove question skill assignment.

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

168 : void {
169 $svy_log = ilLoggerFactory::getLogger("svy");
170
171 $svy_log->debug("delete skill assignment, obj id " . $a_obj_id .
172 ", obj type: " . ilObject::_lookupType($a_obj_id));
173
174 if (ilObject::_lookupType($a_obj_id) === "svy" &&
175 ilObject::_exists($a_obj_id)) {
176 $svy_log->debug("call removeQuestionSkillAssignment.");
177 // mantis 11691
178 $svy = new ilObjSurvey($a_obj_id, false);
179 $svy_skill = new ilSurveySkill($svy);
180 $svy_skill->removeQuestionSkillAssignment($a_question_id);
181 }
182 }
static _lookupType(int $id, bool $reference=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data

Referenced by SurveyQuestion\delete().

+ Here is the caller graph for this function:

◆ isSkillAssignedToQuestion()

ilSurveySkill::isSkillAssignedToQuestion ( int  $a_skill_id,
int  $a_tref_id 
)

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

215 : bool {
217
218 $set = $ilDB->query(
219 "SELECT * FROM svy_quest_skill " .
220 " WHERE base_skill_id = " . $ilDB->quote($a_skill_id, "integer") .
221 " AND tref_id = " . $ilDB->quote($a_tref_id, "integer") .
222 " AND survey_id = " . $ilDB->quote($this->survey->getId(), "integer")
223 );
224 if ($rec = $ilDB->fetchAssoc($set)) {
225 return true;
226 }
227 return false;
228 }

◆ read()

ilSurveySkill::read ( )

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

52 : void
53 {
55
56 $set = $ilDB->query(
57 "SELECT * FROM svy_quest_skill " .
58 " WHERE survey_id = " . $ilDB->quote($this->survey->getId(), "integer")
59 );
60
61 while ($rec = $ilDB->fetchAssoc($set)) {
62 if (SurveyQuestion::_questionExists((int) $rec["q_id"])) {
63 $this->q_skill[(int) $rec["q_id"]] = array(
64 "q_id" => (int) $rec["q_id"],
65 "base_skill_id" => (int) $rec["base_skill_id"],
66 "tref_id" => (int) $rec["tref_id"]
67 );
68 }
69 }
70 }
static _questionExists(int $question_id)

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

Referenced by __construct().

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

◆ removeQuestionSkillAssignment()

ilSurveySkill::removeQuestionSkillAssignment ( int  $a_question_id)

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

136 : void {
138
139 // read skills that are assigned to the quesiton
140 $set = $ilDB->query(
141 "SELECT * FROM svy_quest_skill " .
142 " WHERE q_id = " . $ilDB->quote($a_question_id, "integer")
143 );
144 $skills = array();
145 while ($rec = $ilDB->fetchAssoc($set)) {
146 $skills[] = array(
147 "skill_id" => (int) $rec["base_skill_id"],
148 "tref_id" => (int) $rec["tref_id"]
149 );
150 }
151
152 // remove assignment of question
153 $ilDB->manipulate(
154 "DELETE FROM svy_quest_skill WHERE " .
155 " q_id = " . $ilDB->quote($a_question_id, "integer")
156 );
157 unset($this->q_skill[$a_question_id]);
158
159 $this->removeUsagesOfSkills($skills);
160 }
removeUsagesOfSkills(array $a_skills)
Remove usages of skills This function checks, if the skills are really not in use anymore.

◆ removeUsagesOfSkills()

ilSurveySkill::removeUsagesOfSkills ( array  $a_skills)

Remove usages of skills This function checks, if the skills are really not in use anymore.

Parameters
array$a_skillsarray of arrays with keys "skill_id" and "tref_id"

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

191 : void {
192 $used_skills = array();
193 foreach ($a_skills as $skill) {
194 $skill_id = (int) $skill["skill_id"];
195 $tref_id = (int) $skill["tref_id"];
196 if ($this->isSkillAssignedToQuestion($skill_id, $tref_id)) {
197 $used_skills[] = $skill_id . ":" . $tref_id;
198 }
199 }
200 reset($a_skills);
201
202 // now remove all usages that have been confirmed
203 foreach ($a_skills as $skill) {
204 $skill_id = (int) $skill["skill_id"];
205 $tref_id = (int) $skill["tref_id"];
206 if (!in_array($skill_id . ":" . $tref_id, $used_skills, true)) {
207 $this->skill_usage_service->removeUsage($this->survey->getId(), $skill_id, $tref_id);
208 }
209 }
210 }
isSkillAssignedToQuestion(int $a_skill_id, int $a_tref_id)

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ writeAndAddAppraiseeSkills()

ilSurveySkill::writeAndAddAppraiseeSkills ( int  $user_id)

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

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

381 : void {
382 // write raters evaluation
383 $new_levels = $this->determineSkillLevelsForAppraisee($user_id);
384 foreach ($new_levels as $nl) {
385 if (($nl["new_level_id"] ?? 0) > 0) {
387 (int) $nl["new_level_id"],
388 $user_id,
389 $this->survey->getRefId(),
390 (int) $nl["tref_id"],
392 true,
393 false,
394 "",
395 (float) $nl["next_level_perc"]
396 );
397
398 if (($nl["tref_id"] ?? 0) > 0) {
399 $this->skill_personal_service->addPersonalSkill($user_id, (int) $nl["tref_id"]);
400 } else {
401 $this->skill_personal_service->addPersonalSkill($user_id, (int) $nl["base_skill_id"]);
402 }
403 }
404 }
405
406 //write profile completion entries if fulfilment status has changed
407 $this->skill_profile_service->writeCompletionEntryForAllProfiles($user_id);
408
409 // write self evaluation
411 }
static writeUserSkillLevelStatus(int $a_level_id, int $a_user_id, int $a_trigger_ref_id, int $a_tref_id=0, int $a_status=ilBasicSkill::ACHIEVED, bool $a_force=false, bool $a_self_eval=false, string $a_unique_identifier="", float $a_next_level_fulfilment=0.0, string $trigger_user_id="")
determineSkillLevelsForAppraisee(int $a_appraisee_id, bool $a_self_eval=false, int $finished_id=0)
Determine skill levels for appraisee.
writeAndAddSelfEvalSkills(int $user_id)
Write skills on self evaluation and add them to user's competence records.

References $user_id, ilBasicSkill\ACHIEVED, and ilBasicSkill\writeUserSkillLevelStatus().

+ Here is the call graph for this function:

◆ writeAndAddIndFeedbackSkills()

ilSurveySkill::writeAndAddIndFeedbackSkills ( int  $finished_id,
int  $appr_id,
string  $rater_id 
)

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

417 : void {
418 $new_levels = $this->determineSkillLevelsForAppraisee($appr_id, false, $finished_id);
419 foreach ($new_levels as $nl) {
420 if (($nl["new_level_id"] ?? 0) > 0) {
422 (int) $nl["new_level_id"],
423 $appr_id,
424 $this->survey->getRefId(),
425 (int) $nl["tref_id"],
427 true,
428 false,
429 "",
430 (float) $nl["next_level_perc"],
431 $rater_id
432 );
433
434 if (($nl["tref_id"] ?? 0) > 0) {
435 $this->skill_personal_service->addPersonalSkill($appr_id, (int) $nl["tref_id"]);
436 } else {
437 $this->skill_personal_service->addPersonalSkill($appr_id, (int) $nl["base_skill_id"]);
438 }
439 }
440 }
441 }

References ilBasicSkill\ACHIEVED, 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.

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

448 : void {
449 if ($user_id > 0 && in_array($this->survey->getMode(), [ilObjSurvey::MODE_SELF_EVAL, ilObjSurvey::MODE_360], true)) {
450 $new_levels = $this->determineSkillLevelsForAppraisee($user_id, true);
451 foreach ($new_levels as $nl) {
452 if (($nl["new_level_id"] ?? 0) > 0) {
454 (int) $nl["new_level_id"],
455 $user_id,
456 $this->survey->getRefId(),
457 (int) $nl["tref_id"],
459 true,
460 true,
461 "",
462 (float) $nl["next_level_perc"]
463 );
464
465 if (($nl["tref_id"] ?? 0) > 0) {
466 $this->skill_personal_service->addPersonalSkill($user_id, (int) $nl["tref_id"]);
467 } else {
468 $this->skill_personal_service->addPersonalSkill($user_id, (int) $nl["base_skill_id"]);
469 }
470 }
471 }
472 }
473 }

References $user_id, ilBasicSkill\ACHIEVED, and ilBasicSkill\writeUserSkillLevelStatus().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilSurveySkill::$db
protected

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

Referenced by read().

◆ $log

ilLogger ilSurveySkill::$log
protected

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

◆ $q_skill

array ilSurveySkill::$q_skill = array()
protected

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

◆ $skill_personal_service

ILIAS Skill Service SkillPersonalService ilSurveySkill::$skill_personal_service
protected

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

◆ $skill_profile_service

ILIAS Skill Service SkillProfileService ilSurveySkill::$skill_profile_service
protected

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

◆ $skill_usage_service

ILIAS Skill Service SkillUsageService ilSurveySkill::$skill_usage_service
protected

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

◆ $survey

ilObjSurvey ilSurveySkill::$survey
protected

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


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