diff --git a/components/ILIAS/TestQuestionPool/classes/class.assKprimChoice.php b/components/ILIAS/TestQuestionPool/classes/class.assKprimChoice.php index f955ae0516fe..d272979b46ff 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.assKprimChoice.php +++ b/components/ILIAS/TestQuestionPool/classes/class.assKprimChoice.php @@ -241,8 +241,13 @@ public function loadFromDb($questionId): void $this->setOptionLabel($data['opt_label']); } - $this->setCustomTrueOptionLabel($data['custom_true']); - $this->setCustomFalseOptionLabel($data['custom_false']); + if ($data['custom_true'] !== null) { + $this->setCustomTrueOptionLabel($data['custom_true']); + } + + if ($data['custom_false'] !== null) { + $this->setCustomFalseOptionLabel($data['custom_false']); + } if ($data['score_partsol'] !== null) { $this->setScorePartialSolutionEnabled((bool) $data['score_partsol']); diff --git a/components/ILIAS/TestQuestionPool/classes/class.assKprimChoiceGUI.php b/components/ILIAS/TestQuestionPool/classes/class.assKprimChoiceGUI.php index 662e55e82fd7..958b8f2842e5 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.assKprimChoiceGUI.php +++ b/components/ILIAS/TestQuestionPool/classes/class.assKprimChoiceGUI.php @@ -289,20 +289,16 @@ public function writeQuestionSpecificPostData(ilPropertyFormGUI $form): void */ public function populateAnswerSpecificFormPart(ilPropertyFormGUI $form): ilPropertyFormGUI { - $kprimAnswers = new ilKprimChoiceWizardInputGUI($this->lng->txt('answers'), 'kprimanswers'); - $kprimAnswers->setInfo($this->lng->txt('kprim_answers_info')); - $kprimAnswers->setSize(64); - $kprimAnswers->setMaxLength(1000); - $kprimAnswers->setRequired(true); - $kprimAnswers->setAllowMove(true); - $kprimAnswers->setQuestionObject($this->object); - if (!$this->object->getSelfAssessmentEditingMode()) { - $kprimAnswers->setSingleline($this->object->isSingleLineAnswerType($this->object->getAnswerType())); - } else { - $kprimAnswers->setSingleline(false); - } - $kprimAnswers->setValues($this->object->getAnswers()); - $form->addItem($kprimAnswers); + $answers = new ilKprimChoiceWizardInputGUI($this->lng->txt('answers'), 'kprimanswers'); + $answers->setInfo($this->lng->txt('kprim_answers_info')); + $answers->setSize(64); + $answers->setMaxLength(1000); + $answers->setRequired(true); + $answers->setAllowMove(true); + $answers->setQuestionObject($this->object); + $answers->setSingleline($this->object->isSingleLineAnswerType($this->object->getAnswerType())); + $answers->setValues($this->object->getAnswers()); + $form->addItem($answers); return $form; } diff --git a/components/ILIAS/TestQuestionPool/classes/class.assMultipleChoice.php b/components/ILIAS/TestQuestionPool/classes/class.assMultipleChoice.php index 87db6622034a..1907db8270b2 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.assMultipleChoice.php +++ b/components/ILIAS/TestQuestionPool/classes/class.assMultipleChoice.php @@ -55,11 +55,6 @@ public function setIsSingleline(bool $is_singleline): void $this->is_singleline = $is_singleline; } - public function getIsSingleline(): bool - { - return $this->is_singleline; - } - /** * assMultipleChoice constructor * @@ -138,7 +133,7 @@ public function loadFromDb(int $question_id): void if ($data['thumb_size'] !== null && $data['thumb_size'] >= self::MINIMUM_THUMB_SIZE) { $this->setThumbSize($data['thumb_size']); } - $this->is_singleline = $data['allow_images'] === '0'; + $this->is_singleline = $data['allow_images'] === null || $data['allow_images'] === '0'; $this->lastChange = $data['tstamp']; $this->setSelectionLimit((int) $data['selection_limit'] > 0 ? (int) $data['selection_limit'] : null); if (isset($data['feedback_setting'])) { @@ -884,9 +879,9 @@ protected function buildTestPresentationConfig(): ilTestQuestionConfig return $config; } - public function isSingleline() + public function isSingleline(): bool { - return (bool) $this->is_singleline; + return $this->is_singleline; } public function toLog(AdditionalInformationGenerator $additional_info): array diff --git a/components/ILIAS/TestQuestionPool/classes/class.assMultipleChoiceGUI.php b/components/ILIAS/TestQuestionPool/classes/class.assMultipleChoiceGUI.php index 8e8cf5de021d..424ab8563a87 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.assMultipleChoiceGUI.php +++ b/components/ILIAS/TestQuestionPool/classes/class.assMultipleChoiceGUI.php @@ -87,6 +87,10 @@ protected function writePostData(bool $always = false): int */ protected function getEditAnswersSingleLine($checkonly = false): bool { + if ($this->object->getSelfAssessmentEditingMode()) { + return $this->object->isSingleline(); + } + if ($checkonly) { return $this->request->int('types') === 0; } diff --git a/components/ILIAS/TestQuestionPool/classes/class.assSingleChoice.php b/components/ILIAS/TestQuestionPool/classes/class.assSingleChoice.php index cd00aa48a116..8c28538198de 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.assSingleChoice.php +++ b/components/ILIAS/TestQuestionPool/classes/class.assSingleChoice.php @@ -21,7 +21,6 @@ use ILIAS\TestQuestionPool\Questions\QuestionLMExportable; use ILIAS\TestQuestionPool\Questions\QuestionAutosaveable; use ILIAS\TestQuestionPool\ManipulateImagesInChoiceQuestionsTrait; - use ILIAS\Test\Logging\AdditionalInformationGenerator; /** @@ -120,7 +119,7 @@ public function loadFromDb(int $question_id): void if ($data['thumb_size'] !== null && $data['thumb_size'] >= self::MINIMUM_THUMB_SIZE) { $this->setThumbSize($data['thumb_size']); } - $this->is_singleline = $data['allow_images'] === '0'; + $this->is_singleline = $data['allow_images'] === null || $data['allow_images'] === '0'; $this->lastChange = $data['tstamp']; $this->feedback_setting = $data['feedback_setting'] ?? self::FEEDBACK_MODE_SELECTED_ANSWERS; diff --git a/components/ILIAS/TestQuestionPool/classes/class.assSingleChoiceGUI.php b/components/ILIAS/TestQuestionPool/classes/class.assSingleChoiceGUI.php index 8a120cc57940..494e8354ad4a 100755 --- a/components/ILIAS/TestQuestionPool/classes/class.assSingleChoiceGUI.php +++ b/components/ILIAS/TestQuestionPool/classes/class.assSingleChoiceGUI.php @@ -82,6 +82,10 @@ protected function writePostData(bool $always = false): int */ protected function getEditAnswersSingleLine($checkonly = false): bool { + if ($this->object->getSelfAssessmentEditingMode()) { + return $this->object->isSingleline(); + } + if ($checkonly) { return $this->request->int('types') === 0; }