19declare(strict_types=0);
36 public function __construct(
int $a_container_id,
int $a_objective_id,
int $a_test_type,
int $a_qpl_sequence)
40 $this->db =
$DIC->database();
42 $this->container_id = $a_container_id;
43 $this->objective_id = $a_objective_id;
44 $this->test_type = $a_test_type;
45 $this->qpl_seq = $a_qpl_sequence;
50 public static function lookupLimit(
int $a_container_id,
int $a_objective_id,
int $a_test_type):
int
55 $query =
'SELECT * FROM loc_rnd_qpl ' .
56 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
57 'AND objective_id = ' .
$ilDB->quote($a_objective_id,
'integer') .
' ' .
58 'AND tst_type = ' .
$ilDB->quote($a_test_type,
'integer');
61 return $row->percentage;
66 public static function lookupSequences(
int $a_container_id,
int $a_objective_id,
int $a_test_id): array
71 $query =
'SELECT * FROM loc_rnd_qpl ' .
72 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
73 'AND objective_id = ' .
$ilDB->quote($a_objective_id,
'integer') .
' ' .
74 'AND tst_id = ' .
$ilDB->quote($a_test_id,
'integer');
79 $sequences[] = $row->qp_seq;
93 $query =
'SELECT * FROM loc_rnd_qpl ' .
94 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
95 'AND objective_id = ' .
$ilDB->quote($a_objective_id,
'integer') .
' ' .
96 'AND tst_id = ' .
$ilDB->quote($a_test_id,
'integer') .
' ' .
97 'AND tst_type = ' .
$ilDB->quote($a_test_type,
'integer');
102 $sequences[] = (
int) $row->qp_seq;
112 $query =
'SELECT objective_id FROM loc_rnd_qpl ' .
113 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer') .
' ' .
114 'AND qp_seq = ' .
$ilDB->quote($a_seq_id,
'integer');
116 $objectiveIds = array();
118 $objectiveIds[] = $row->objective_id;
120 return $objectiveIds;
125 $this->container_id = $a_id;
130 return $this->container_id;
135 $this->objective_id = $a_id;
140 return $this->objective_id;
145 $this->test_type = $a_type;
150 return $this->test_type;
155 $this->test_id = $a_id;
160 return $this->test_id;
165 $this->qpl_seq = $a_id;
170 return $this->qpl_seq;
175 $this->limit = $a_id;
183 public function copy(
int $a_copy_id,
int $a_new_course_id,
int $a_new_objective_id): void
186 $mappings = $options->getMappings();
188 foreach (self::lookupSequences(
189 $this->getContainerId(),
190 $this->getContainerId(),
194 $this->setQplSequence($sequence);
201 $mapped_id = $mappings[
$ref_id];
204 ilLoggerFactory::getLogger(
'crs')->debug(
'No test mapping found for random question pool assignment: ' . $this->getTestId() .
' ' . $sequence);
209 $new_question_info = $mappings[$test_ref_id .
'_rndSelDef_' . $this->getQplSequence()];
210 $new_question_arr = explode(
'_', $new_question_info);
211 if (!isset($new_question_arr[2]) || !$new_question_arr[2]) {
223 $this->getTestType(),
226 $new_ass->setTestId($mapped_id);
227 $new_ass->setLimit($this->getLimit());
234 $query =
'SELECT * FROM loc_rnd_qpl ' .
235 'WHERE container_id = ' . $this->db->quote($this->getContainerId(),
'integer') .
' ' .
236 'AND objective_id = ' . $this->db->quote($this->getObjectiveId(),
'integer') .
' ' .
237 'AND tst_type = ' . $this->db->quote($this->getTestType(),
'integer') .
' ' .
238 'AND qp_seq = ' . $this->db->quote($this->getQplSequence(),
'integer');
240 $res = $this->db->query($query);
242 $this->setLimit($row->percentage);
243 $this->setTestId($row->tst_id);
247 public function delete():
void
249 $query =
'DELETE FROM loc_rnd_qpl ' .
250 'WHERE container_id = ' . $this->db->quote($this->getContainerId(),
'integer') .
' ' .
251 'AND objective_id = ' . $this->db->quote($this->getObjectiveId(),
'integer') .
' ' .
252 'AND tst_type = ' . $this->db->quote($this->getTestType(),
'integer') .
' ' .
253 'AND qp_seq = ' . $this->db->quote($this->getQplSequence(),
'integer');
254 $this->db->manipulate($query);
261 $query =
'DELETE FROM loc_rnd_qpl ' .
262 'WHERE container_id = ' . $db->
quote($a_course_id,
'integer') .
' ' .
263 'AND objective_id = ' . $db->
quote($a_objective_id,
'integer') .
' ' .
264 'AND tst_type = ' . $db->
quote($a_tst_type,
'integer');
270 $query =
'INSERT INTO loc_rnd_qpl ' .
271 '(container_id, objective_id, tst_type, tst_id, qp_seq, percentage) ' .
273 $this->db->quote($this->getContainerId(),
'integer') .
', ' .
274 $this->db->quote($this->getObjectiveId(),
'integer') .
', ' .
275 $this->db->quote($this->getTestType(),
'integer') .
', ' .
276 $this->db->quote($this->getTestId(),
'integer') .
', ' .
277 $this->db->quote($this->getQplSequence(),
'integer') .
', ' .
280 $this->db->manipulate($query);
288 $query =
'SELECT * FROM loc_rnd_qpl ' .
289 'WHERE objective_id = ' .
$ilDB->quote($a_objective_id,
'integer');
296 'objId' => $row->tst_id,
297 'testType' => $row->tst_type,
298 'limit' => $row->percentage,
299 'poolId' => $row->qp_seq
static _getInstance(int $a_copy_id)
static toXml(ilXmlWriter $writer, int $a_objective_id)
static lookupLimit(int $a_container_id, int $a_objective_id, int $a_test_type)
setObjectiveId(int $a_id)
setContainerId(int $a_id)
static lookupObjectiveIdsBySequence(int $a_container_id, int $a_seq_id)
static lookupSequences(int $a_container_id, int $a_objective_id, int $a_test_id)
setQplSequence(int $a_id)
static deleteForObjectiveAndTestType(int $a_course_id, int $a_objective_id, int $a_tst_type)
copy(int $a_copy_id, int $a_new_course_id, int $a_new_objective_id)
static lookupSequencesByType(int $a_container_id, int $a_objective_id, int $a_test_id, int $a_test_type)
__construct(int $a_container_id, int $a_objective_id, int $a_test_type, int $a_qpl_sequence)
static getLogger(string $a_component_id)
Get component logger.
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
quote($value, string $type)
manipulate(string $query)
Run a (write) Query on the database.