ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
 
ILIAS Skill Service SkillPersonalService $skill_personal_service
 
ILIAS Skill Service SkillUsageService $skill_usage_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 37 of file class.ilSurveySkill.php.

38 {
39 global $DIC;
40
41 $this->db = $DIC->database();
42 $this->survey = $a_survey;
43 $this->read();
44 $this->log = ilLoggerFactory::getLogger("svy");
45 $this->skill_profile_service = $DIC->skills()->profile();
46 $this->skill_personal_service = $DIC->skills()->personal();
47 $this->skill_usage_service = $DIC->skills()->usage();
48 }
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 106 of file class.ilSurveySkill.php.

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

◆ determineMaxScale()

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

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

343 : int {
344 $ssk = new ilSurveySkill($this->survey);
345 $question_ids = $ssk->getQuestionsForSkill($a_base_skill, $a_tref_id);
346 $scale_sum = 0;
347 foreach ($question_ids as $q_id) {
349 if (!is_object($q)) {
350 continue;
351 }
352 $cats = $q->getCategories();
353 $max_scale = 0;
354 for ($i = 0; $i < $cats->getCategoryCount(); $i++) {
355 $c = $cats->getCategory($i);
356 $n = $c->neutral;
357 $s = $c->scale;
358 if (!$c->neutral) {
359 if ($c->scale > $max_scale) {
360 $max_scale = $c->scale;
361 }
362 }
363 }
364 $scale_sum += $max_scale;
365 }
366
367 return $scale_sum;
368 }
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: deliver.php:25
$q
Definition: shib_logout.php:23

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

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

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

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

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

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

◆ handleQuestionDeletion()

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

Remove question skill assignment.

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

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

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

◆ read()

ilSurveySkill::read ( )

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

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

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

189 : void {
190 $used_skills = array();
191 foreach ($a_skills as $skill) {
192 if ($this->isSkillAssignedToQuestion($skill["skill_id"], $skill["tref_id"])) {
193 $used_skills[] = $skill["skill_id"] . ":" . $skill["tref_id"];
194 }
195 }
196 reset($a_skills);
197
198 // now remove all usages that have been confirmed
199 foreach ($a_skills as $skill) {
200 if (!in_array($skill["skill_id"] . ":" . $skill["tref_id"], $used_skills, true)) {
201 $this->skill_usage_service->removeUsage($this->survey->getId(), $skill["skill_id"], $skill["tref_id"]);
202 }
203 }
204 }
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 373 of file class.ilSurveySkill.php.

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

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

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

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

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 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_personal_service

ILIAS Skill Service SkillPersonalService ilSurveySkill::$skill_personal_service
protected

Definition at line 34 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.

◆ $skill_usage_service

ILIAS Skill Service SkillUsageService ilSurveySkill::$skill_usage_service
protected

Definition at line 35 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: