3 declare(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 54 $ilDB = $DIC->database();
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
70 $ilDB = $DIC->database();
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;
92 $ilDB = $DIC->database();
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;
111 $ilDB = $DIC->database();
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;
135 $this->objective_id = $a_id;
145 $this->test_type = $a_type;
155 $this->test_id = $a_id;
165 $this->qpl_seq = $a_id;
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(
201 $mapped_id = $mappings[
$ref_id];
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]) {
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');
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) ' .
275 $this->db->quote($this->
getTestType(),
'integer') .
', ' .
276 $this->db->quote($this->
getTestId(),
'integer') .
', ' .
280 $this->db->manipulate(
$query);
287 $ilDB = $DIC->database();
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 lookupLimit(int $a_container_id, int $a_objective_id, int $a_test_type)
static lookupSequences(int $a_container_id, int $a_objective_id, int $a_test_id)
setContainerId(int $a_id)
static lookupObjectiveIdsBySequence(int $a_container_id, int $a_seq_id)
static getLogger(string $a_component_id)
Get component logger.
__construct(int $a_container_id, int $a_objective_id, int $a_test_type, int $a_qpl_sequence)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
quote($value, string $type)
static toXml(ilXmlWriter $writer, int $a_objective_id)
setQplSequence(int $a_id)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
setObjectiveId(int $a_id)
static lookupSequencesByType(int $a_container_id, int $a_objective_id, int $a_test_id, int $a_test_type)
copy(int $a_copy_id, int $a_new_course_id, int $a_new_objective_id)
static _getInstance(int $a_copy_id)
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
manipulate(string $query)
Run a (write) Query on the database.
static deleteForObjectiveAndTestType(int $a_course_id, int $a_objective_id, int $a_tst_type)