ILIAS  release_8 Revision v8.24
ilSurveySkill Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Skill/Competence handling in surveys

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

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

Constructor & Destructor Documentation

◆ __construct()

ilSurveySkill::__construct ( ilObjSurvey  $a_survey)

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

36 {
37 global $DIC;
38
39 $this->db = $DIC->database();
40 $this->survey = $a_survey;
41 $this->read();
42 $this->log = ilLoggerFactory::getLogger("svy");
43 $this->skill_profile_service = $DIC->skills()->profile();
44 }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: feed.php:28

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

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

◆ determineMaxScale()

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

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

340 : int {
341 $ssk = new ilSurveySkill($this->survey);
342 $question_ids = $ssk->getQuestionsForSkill($a_base_skill, $a_tref_id);
343 $scale_sum = 0;
344 foreach ($question_ids as $q_id) {
346 if (!is_object($q)) {
347 continue;
348 }
349 $cats = $q->getCategories();
350 $max_scale = 0;
351 for ($i = 0; $i < $cats->getCategoryCount(); $i++) {
352 $c = $cats->getCategory($i);
353 $n = $c->neutral;
354 $s = $c->scale;
355 if (!$c->neutral) {
356 if ($c->scale > $max_scale) {
357 $max_scale = $c->scale;
358 }
359 }
360 }
361 $scale_sum += $max_scale;
362 }
363
364 return $scale_sum;
365 }
static _instanciateQuestion(int $question_id)
Get question object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$c
Definition: cli.php:38
$i
Definition: metadata.php:41

References $c, $i, 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 239 of file class.ilSurveySkill.php.

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

225 : array
226 {
227 $skills = array();
228 foreach ($this->q_skill as $sk) {
229 $skills[$sk["base_skill_id"] . ":" . $sk["tref_id"]] = ilBasicSkill::_lookupTitle($sk["base_skill_id"]);
230 }
231 return $skills;
232 }
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 81 of file class.ilSurveySkill.php.

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

◆ 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 71 of file class.ilSurveySkill.php.

73 : ?array {
74 return $this->q_skill[$a_question_id] ?? null;
75 }

◆ handleQuestionDeletion()

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

Remove question skill assignment.

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

162 : void {
163
164 $svy_log = ilLoggerFactory::getLogger("svy");
165
166 $svy_log->debug("delete skill assignment, obj id " . $a_obj_id .
167 ", obj type: " . ilObject::_lookupType($a_obj_id));
168
169 if (ilObject::_lookupType($a_obj_id) === "svy" &&
170 ilObject::_exists($a_obj_id)) {
171 $svy_log->debug("call removeQuestionSkillAssignment.");
172 // mantis 11691
173 $svy = new ilObjSurvey($a_obj_id, false);
174 $svy_skill = new ilSurveySkill($svy);
175 $svy_skill->removeQuestionSkillAssignment($a_question_id);
176 }
177 }
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 203 of file class.ilSurveySkill.php.

206 : bool {
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 }

◆ read()

ilSurveySkill::read ( )

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

46 : void
47 {
49
50 $set = $ilDB->query(
51 "SELECT * FROM svy_quest_skill " .
52 " WHERE survey_id = " . $ilDB->quote($this->survey->getId(), "integer")
53 );
54
55 while ($rec = $ilDB->fetchAssoc($set)) {
56 if (SurveyQuestion::_questionExists($rec["q_id"])) {
57 $this->q_skill[(int) $rec["q_id"]] = array(
58 "q_id" => (int) $rec["q_id"],
59 "base_skill_id" => (int) $rec["base_skill_id"],
60 "tref_id" => (int) $rec["tref_id"]
61 );
62 }
63 }
64 }
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 128 of file class.ilSurveySkill.php.

130 : void {
132
133 // read skills that are assigned to the quesiton
134 $set = $ilDB->query(
135 "SELECT * FROM svy_quest_skill " .
136 " WHERE q_id = " . $ilDB->quote($a_question_id, "integer")
137 );
138 $skills = array();
139 while ($rec = $ilDB->fetchAssoc($set)) {
140 $skills[] = array(
141 "skill_id" => $rec["base_skill_id"],
142 "tref_id" => $rec["tref_id"]
143 );
144 }
145
146 // remove assignment of question
147 $ilDB->manipulate(
148 "DELETE FROM svy_quest_skill WHERE " .
149 " q_id = " . $ilDB->quote($a_question_id, "integer")
150 );
151 unset($this->q_skill[$a_question_id]);
152
153 $this->removeUsagesOfSkills($skills);
154 }
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 184 of file class.ilSurveySkill.php.

186 : void {
187 $used_skills = array();
188 foreach ($a_skills as $skill) {
189 if ($this->isSkillAssignedToQuestion($skill["skill_id"], $skill["tref_id"])) {
190 $used_skills[] = $skill["skill_id"] . ":" . $skill["tref_id"];
191 }
192 }
193 reset($a_skills);
194
195 // now remove all usages that have been confirmed
196 foreach ($a_skills as $skill) {
197 if (!in_array($skill["skill_id"] . ":" . $skill["tref_id"], $used_skills, true)) {
198 ilSkillUsage::setUsage($this->survey->getId(), $skill["skill_id"], $skill["tref_id"], false);
199 }
200 }
201 }
isSkillAssignedToQuestion(int $a_skill_id, int $a_tref_id)

◆ writeAndAddAppraiseeSkills()

ilSurveySkill::writeAndAddAppraiseeSkills ( int  $user_id)

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

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

372 : void {
373 // write raters evaluation
374 $new_levels = $this->determineSkillLevelsForAppraisee($user_id);
375 foreach ($new_levels as $nl) {
376 if (($nl["new_level_id"] ?? 0) > 0) {
378 (int) $nl["new_level_id"],
379 $user_id,
380 $this->survey->getRefId(),
381 (int) $nl["tref_id"],
383 true,
384 false,
385 "",
386 $nl["next_level_perc"]
387 );
388
389 if (($nl["tref_id"] ?? 0) > 0) {
390 ilPersonalSkill::addPersonalSkill($user_id, (int) $nl["tref_id"]);
391 } else {
392 ilPersonalSkill::addPersonalSkill($user_id, (int) $nl["base_skill_id"]);
393 }
394 }
395 }
396
397 //write profile completion entries if fulfilment status has changed
398 $this->skill_profile_service->writeCompletionEntryForAllProfiles($user_id);
399
400 // write self evaluation
401 $this->writeAndAddSelfEvalSkills($user_id);
402 }
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="")
static addPersonalSkill(int $a_user_id, int $a_skill_node_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 ilBasicSkill\ACHIEVED, ilPersonalSkill\addPersonalSkill(), 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 404 of file class.ilSurveySkill.php.

408 : void {
409 $new_levels = $this->determineSkillLevelsForAppraisee($appr_id, false, $finished_id);
410 foreach ($new_levels as $nl) {
411 if (($nl["new_level_id"] ?? 0) > 0) {
413 (int) $nl["new_level_id"],
414 $appr_id,
415 $this->survey->getRefId(),
416 (int) $nl["tref_id"],
418 true,
419 false,
420 "",
421 $nl["next_level_perc"],
422 (int) $rater_id
423 );
424
425 if (($nl["tref_id"] ?? 0) > 0) {
426 ilPersonalSkill::addPersonalSkill($appr_id, (int) $nl["tref_id"]);
427 } else {
428 ilPersonalSkill::addPersonalSkill($appr_id, (int) $nl["base_skill_id"]);
429 }
430 }
431 }
432 }

References ilBasicSkill\ACHIEVED, ilPersonalSkill\addPersonalSkill(), 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 437 of file class.ilSurveySkill.php.

439 : void {
440 if ($user_id > 0 && in_array($this->survey->getMode(), [ilObjSurvey::MODE_SELF_EVAL, ilObjSurvey::MODE_360], true)) {
441 $new_levels = $this->determineSkillLevelsForAppraisee($user_id, true);
442 foreach ($new_levels as $nl) {
443 if (($nl["new_level_id"] ?? 0) > 0) {
445 (int) $nl["new_level_id"],
446 $user_id,
447 $this->survey->getRefId(),
448 (int) $nl["tref_id"],
450 true,
451 1,
452 "",
453 $nl["next_level_perc"]
454 );
455
456 if (($nl["tref_id"] ?? 0) > 0) {
457 ilPersonalSkill::addPersonalSkill($user_id, (int) $nl["tref_id"]);
458 } else {
459 ilPersonalSkill::addPersonalSkill($user_id, (int) $nl["base_skill_id"]);
460 }
461 }
462 }
463 }
464 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilSurveySkill::$db
protected

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

Referenced by read().

◆ $log

ilLogger ilSurveySkill::$log
protected

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

◆ $q_skill

array ilSurveySkill::$q_skill = array()
protected

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

◆ $skill_profile_service

ILIAS Skill Service SkillProfileService ilSurveySkill::$skill_profile_service
protected

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

◆ $survey

ilObjSurvey ilSurveySkill::$survey
protected

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


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