ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSurveySkillThresholds.php
Go to the documentation of this file.
1<?php
2
24{
26 protected ilDBInterface $db;
28 protected array $threshold = [];
29
30 public function __construct(ilObjSurvey $a_survey)
31 {
32 global $DIC;
33
34 $this->db = $DIC->database();
35 $this->survey = $a_survey;
36 $this->read();
37 }
38
39 public function read(): void
40 {
42
43 $set = $ilDB->query(
44 "SELECT * FROM svy_skill_threshold " .
45 " WHERE survey_id = " . $ilDB->quote($this->survey->getId(), "integer")
46 );
47 while ($rec = $ilDB->fetchAssoc($set)) {
48 $this->threshold[(int) $rec['level_id']][(int) $rec['tref_id']] = (int) $rec['threshold'];
49 }
50 }
51
55 public function getThresholds(): array
56 {
57 return $this->threshold;
58 }
59
60 public function writeThreshold(
61 int $a_base_skill_id,
62 int $a_tref_id,
63 int $a_level_id,
64 int $a_threshold
65 ): void {
66 $ilDB = $this->db;
67
68 $ilDB->replace(
69 "svy_skill_threshold",
70 array("survey_id" => array("integer", $this->survey->getId()),
71 "base_skill_id" => array("integer", $a_base_skill_id),
72 "tref_id" => array("integer", $a_tref_id),
73 "level_id" => array("integer", $a_level_id)
74 ),
75 array("threshold" => array("integer", $a_threshold))
76 );
77 }
78
79 public function cloneTo(ilObjSurvey $target_survey, array $mapping): void
80 {
81 $target_thresholds = new self($target_survey);
82 $set = $this->db->queryF(
83 "SELECT * FROM svy_skill_threshold " .
84 " WHERE survey_id = %s ",
85 ["integer"],
86 [$this->survey->getId()]
87 );
88 while ($rec = $this->db->fetchAssoc($set)) {
89 $target_thresholds->writeThreshold(
90 (int) $rec["base_skill_id"],
91 (int) $rec["tref_id"],
92 (int) $rec["level_id"],
93 (int) $rec["threshold"]
94 );
95 }
96 }
97}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
cloneTo(ilObjSurvey $target_survey, array $mapping)
writeThreshold(int $a_base_skill_id, int $a_tref_id, int $a_level_id, int $a_threshold)
Interface ilDBInterface.
global $DIC
Definition: shib_login.php:26