39 $this->db = $DIC->database();
40 $this->survey = $a_survey;
43 $this->skill_profile_service = $DIC->skills()->profile();
46 public function read(): void
51 "SELECT * FROM svy_quest_skill " .
52 " WHERE survey_id = " .
$ilDB->quote($this->survey->getId(),
"integer")
55 while ($rec =
$ilDB->fetchAssoc($set)) {
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"]
74 return $this->q_skill[$a_question_id] ?? null;
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) {
104 int $a_base_skill_id,
111 array(
"q_id" => array(
"integer", $a_question_id)),
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)
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
135 "SELECT * FROM svy_quest_skill " .
136 " WHERE q_id = " .
$ilDB->quote($a_question_id,
"integer")
139 while ($rec =
$ilDB->fetchAssoc($set)) {
141 "skill_id" => $rec[
"base_skill_id"],
142 "tref_id" => $rec[
"tref_id"]
148 "DELETE FROM svy_quest_skill WHERE " .
149 " q_id = " .
$ilDB->quote($a_question_id,
"integer")
151 unset($this->q_skill[$a_question_id]);
166 $svy_log->debug(
"delete skill assignment, obj id " . $a_obj_id .
171 $svy_log->debug(
"call removeQuestionSkillAssignment.");
175 $svy_skill->removeQuestionSkillAssignment($a_question_id);
187 $used_skills = array();
188 foreach ($a_skills as $skill) {
190 $used_skills[] = $skill[
"skill_id"] .
":" . $skill[
"tref_id"];
196 foreach ($a_skills as $skill) {
197 if (!in_array($skill[
"skill_id"] .
":" . $skill[
"tref_id"], $used_skills,
true)) {
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")
215 if ($rec =
$ilDB->fetchAssoc($set)) {
228 foreach ($this->q_skill as $sk) {
241 bool $a_self_eval =
false,
248 foreach ($opts as $k => $title) {
249 $k = explode(
":", $k);
252 $ld = $bs->getLevelData();
255 "base_skill_id" => (
int) $k[0],
256 "tref_id" => (
int) $k[1],
257 "skill_title" => $title,
264 if ($finished_id > 0) {
265 $finished_ids = array($finished_id);
267 $finished_ids = $this->survey->getFinishedIdsForAppraiseeId($a_appraisee_id,
true);
270 $finished_id = $this->survey->getFinishedIdForAppraiseeIdAndRaterId($a_appraisee_id, $a_appraisee_id);
271 if ($finished_id > 0) {
272 $finished_ids = array($finished_id);
281 $results = $this->survey->getUserSpecificResults($finished_ids);
282 $this->log->debug(
"Finished IDS: " . print_r($finished_ids,
true));
283 foreach ($skills as $k => $s) {
285 $this->log->debug(
"Skill: " . $s[
"base_skill_id"] .
":" . $s[
"tref_id"] .
", Questions: " . implode(
",", $q_ids));
287 foreach ($q_ids as $q_id) {
292 foreach (
$results[$q_id] as $uid => $answer) {
297 $scale_values = array_keys($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);
303 $qmean = $sum / $cnt;
305 $this->log->debug(
"MEAN: " . $qmean);
308 $this->log->debug(
"MEAN SUM: " . $mean_sum);
310 $skills[$k][
"mean_sum"] = $mean_sum;
313 $thresholds = $skthr->getThresholds();
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) {
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);
329 $previous = $l[
"id"];
342 $question_ids = $ssk->getQuestionsForSkill($a_base_skill, $a_tref_id);
344 foreach ($question_ids as $q_id) {
346 if (!is_object($q)) {
349 $cats = $q->getCategories();
351 for (
$i = 0;
$i < $cats->getCategoryCount();
$i++) {
352 $c = $cats->getCategory(
$i);
356 if (
$c->scale > $max_scale) {
357 $max_scale =
$c->scale;
361 $scale_sum += $max_scale;
375 foreach ($new_levels as $nl) {
376 if (($nl[
"new_level_id"] ?? 0) > 0) {
378 (
int) $nl[
"new_level_id"],
380 $this->survey->getRefId(),
381 (
int) $nl[
"tref_id"],
386 $nl[
"next_level_perc"]
389 if (($nl[
"tref_id"] ?? 0) > 0) {
398 $this->skill_profile_service->writeCompletionEntryForAllProfiles($user_id);
410 foreach ($new_levels as $nl) {
411 if (($nl[
"new_level_id"] ?? 0) > 0) {
413 (
int) $nl[
"new_level_id"],
415 $this->survey->getRefId(),
416 (
int) $nl[
"tref_id"],
421 $nl[
"next_level_perc"],
425 if (($nl[
"tref_id"] ?? 0) > 0) {
442 foreach ($new_levels as $nl) {
443 if (($nl[
"new_level_id"] ?? 0) > 0) {
445 (
int) $nl[
"new_level_id"],
447 $this->survey->getRefId(),
448 (
int) $nl[
"tref_id"],
453 $nl[
"next_level_perc"]
456 if (($nl[
"tref_id"] ?? 0) > 0) {
static getLogger(string $a_component_id)
Get component logger.
writeAndAddAppraiseeSkills(int $user_id)
Write appraisee skills and add them to user's competence records.
addQuestionSkillAssignment(int $a_question_id, int $a_base_skill_id, int $a_tref_id)
Add survey question to skill assignment.
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
__construct(ilObjSurvey $a_survey)
static setUsage(int $a_obj_id, int $a_skill_id, int $a_tref_id, bool $a_use=true)
determineSkillLevelsForAppraisee(int $a_appraisee_id, bool $a_self_eval=false, int $finished_id=0)
Determine skill levels for appraisee.
writeAndAddIndFeedbackSkills(int $finished_id, int $appr_id, string $rater_id)
static handleQuestionDeletion(int $a_question_id, int $a_obj_id)
Remove question skill assignment.
writeAndAddSelfEvalSkills(int $user_id)
Write skills on self evaluation and add them to user's competence records.
getSkillForQuestion(int $a_question_id)
Get skill for question.
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...
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
determineMaxScale(int $a_base_skill, int $a_tref_id=0)
removeQuestionSkillAssignment(int $a_question_id)
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="")
getQuestionsForSkill(int $a_base_skill_id, int $a_tref_id)
Get questions for skill.
removeUsagesOfSkills(array $a_skills)
Remove usages of skills This function checks, if the skills are really not in use anymore...
getAllAssignedSkillsAsOptions()
static addPersonalSkill(int $a_user_id, int $a_skill_node_id)
isSkillAssignedToQuestion(int $a_skill_id, int $a_tref_id)
ILIAS Skill Service SkillProfileService $skill_profile_service
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _instanciateQuestion(int $question_id)
Get question object.
static _questionExists(int $question_id)