18 declare(strict_types=0);
59 private int $it_type = self::TYPE_INITIAL_PLACEMENT_ALL;
60 private int $qt_type = self::TYPE_QUALIFYING_ALL;
81 $this->
logger = $DIC->logger()->crs();
82 $this->db = $DIC->database();
83 $this->tree = $DIC->repositoryTree();
84 $this->container_id = $a_cont_id;
90 if (isset(self::$instances[$a_obj_id])) {
91 return self::$instances[$a_obj_id];
93 return self::$instances[$a_obj_id] =
new ilLOSettings($a_obj_id);
98 $this->it_type = $a_type;
113 $this->qt_type = $a_type;
118 $this->it_start = $a_type;
128 $this->qt_start = $a_type;
167 $ilDB = $DIC->database();
169 $query =
'SELECT obj_id FROM loc_settings ' .
170 'WHERE itest = ' .
$ilDB->quote($a_trst_ref_id,
'integer') .
' ' .
171 'OR qtest = ' .
$ilDB->quote($a_trst_ref_id,
'integer');
179 public static function cloneSettings(
int $a_copy_id,
int $a_container_id,
int $a_new_container_id): void
182 $mappings = $options->getMappings();
184 $settings = self::getInstanceByObjId($a_container_id);
185 $new_settings = self::getInstanceByObjId($a_new_container_id);
187 $new_settings->setType($settings->getType());
188 $new_settings->setInitialTestType($settings->getInitialTestType());
189 $new_settings->setQualifyingTestType($settings->getQualifyingTestType());
190 $new_settings->resetResults($settings->isResetResultsEnabled());
191 $new_settings->setPassedObjectiveMode($settings->getPassedObjectiveMode());
193 if ($settings->getInitialTest() && array_key_exists($settings->getInitialTest(), $mappings)) {
194 $new_settings->setInitialTest($mappings[$settings->getInitialTest()]);
195 $new_settings->setInitialTestAsStart($new_settings->isInitialTestStart());
198 if ($settings->getQualifiedTest() && array_key_exists($settings->getQualifiedTest(), $mappings)) {
199 $new_settings->setQualifiedTest($mappings[$settings->getQualifiedTest()]);
200 $new_settings->setQualifyingTestAsStart($settings->isQualifyingTestStart());
204 $new_settings->update();
235 $this->passed_objective_mode = $a_mode;
257 $this->type = $a_type;
268 case self::TYPE_TEST_INITIAL:
271 case self::TYPE_TEST_QUALIFIED:
297 $this->initial_test = $a_id;
307 $this->qualified_test = $a_id;
317 $this->reset_results = $a_status;
327 $query =
'INSERT INTO loc_settings ' .
328 '(obj_id, it_type,itest,qtest,it_start,qt_type,qt_start,reset_results,passed_obj_mode) VALUES ( ' .
329 $this->db->quote($this->
getObjId(),
'integer') .
', ' .
339 $this->db->manipulate($query);
340 $this->entry_exists =
true;
345 if (!$this->entry_exists) {
350 $query =
'UPDATE loc_settings ' .
' ' .
352 'itest = ' . $this->db->quote($this->
getInitialTest(),
'integer') .
', ' .
353 'qtest = ' . $this->db->quote($this->
getQualifiedTest(),
'integer') .
', ' .
359 'WHERE obj_id = ' . $this->db->quote($this->
getObjId(),
'integer');
361 $this->db->manipulate($query);
372 if ($start->
exists($this->getQualifiedTest())) {
378 case self::TYPE_INITIAL_PLACEMENT_ALL:
379 case self::TYPE_INITIAL_QUALIFYING_ALL:
382 if (!$start->
exists($this->getInitialTest())) {
386 if ($start->
exists($this->getInitialTest())) {
392 case self::TYPE_INITIAL_NONE:
394 if ($start->
exists($this->getInitialTest())) {
401 $this->
logger->debug(
'Type initial default');
402 if ($start->
exists($this->getInitialTest())) {
403 $this->
logger->debug(
'Old start object exists. Trying to delete');
410 case self::TYPE_QUALIFYING_ALL:
413 if (!$start->
exists($this->getQualifiedTest())) {
420 if ($start->
exists($this->getQualifiedTest())) {
430 protected function read(): void
432 $query =
'SELECT * FROM loc_settings ' .
433 'WHERE obj_id = ' . $this->db->quote($this->
getObjId(),
'integer');
434 $res = $this->db->query($query);
436 $this->entry_exists =
true;
448 if ($this->tree->isDeleted($this->getInitialTest())) {
451 if ($this->tree->isDeleted($this->getQualifiedTest())) {
int $passed_objective_mode
toXml(ilXmlWriter $writer)
worksWithInitialTest()
Check if the loc is configured for initial tests.
setInitialTestAsStart(bool $a_type)
const TYPE_INITIAL_QUALIFYING_SELECTED
isGeneralQualifiedTestVisible()
getTestByType(int $a_type)
updateStartObjects(ilContainerStartObjects $start)
Update start objects Depends on course objective settings.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TYPE_QUALIFYING_ALL
setQualifyingTestType(int $a_type)
deleteItem(int $a_item_ref_id)
setInitialTest(int $a_id)
static _lookupRandomTest(int $obj_id)
const HIDE_PASSED_OBJECTIVE_QST
static _lookupObjId(int $ref_id)
isGeneralInitialTestVisible()
hasSeparateInitialTests()
Check if separate initial test are configured.
__construct(int $a_cont_id)
exists(int $a_item_ref_id)
const MARK_PASSED_OBJECTIVE_QST
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
isInitialTestQualifying()
Check if initial test is qualifying*.
resetResults(bool $a_status)
static isObjectiveTest(int $a_trst_ref_id)
Check if test ref_id is used in an objective course.
static getInstanceByObjId(int $a_obj_id)
const QT_VISIBLE_OBJECTIVE
setPassedObjectiveMode(int $a_mode)
hasSeparateQualifiedTests()
Check if separate qualified tests are configured.
setQualifyingTestAsStart(bool $a_type)
const TYPE_INITIAL_QUALIFYING_ALL
const TYPE_TEST_QUALIFIED
const TYPE_INITIAL_PLACEMENT_ALL
static lookupContainerForTest(int $a_test_ref_id)
static _getInstance(int $a_copy_id)
const TYPE_QUALIFYING_SELECTED
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
isRandomTestType(int $a_type)
worksWithStartObjects()
Check if start objects are enabled.
const TYPE_TEST_UNDEFINED
static cloneSettings(int $a_copy_id, int $a_container_id, int $a_new_container_id)
setInitialTestType(int $a_type)
setQualifiedTest(int $a_id)
const TYPE_INITIAL_PLACEMENT_SELECTED