diff --git a/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php b/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php index 860202b4e218..944438352ad0 100644 --- a/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php +++ b/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php @@ -91,8 +91,8 @@ protected function writePostData($always = false) public function writeQuestionSpecificPostData(ilPropertyFormGUI $form) { $this->object->setLongMenuTextValue(ilUtil::stripSlashesRecursive($_POST['longmenu_text'])); - $this->object->setAnswers(json_decode(ilUtil::stripSlashesRecursive($_POST['hidden_text_files']))); - $this->object->setCorrectAnswers(json_decode(ilUtil::stripSlashesRecursive($_POST['hidden_correct_answers']))); + $this->object->setAnswers($this->trimArrayRecursive(json_decode(ilUtil::stripSlashesRecursive($_POST['hidden_text_files'])))); + $this->object->setCorrectAnswers($this->trimArrayRecursive(json_decode(ilUtil::stripSlashesRecursive($_POST['hidden_correct_answers'])))); $this->object->setAnswerType(ilUtil::stripSlashesRecursive($_POST['long_menu_type'])); $this->object->setQuestion($_POST['question']); $this->object->setLongMenuTextValue($_POST["longmenu_text"]); @@ -101,6 +101,22 @@ public function writeQuestionSpecificPostData(ilPropertyFormGUI $form) $this->saveTaxonomyAssignments(); } + protected function trimArrayRecursive(array $data) + { + if (is_array($data)) { + foreach ($data as $k => $v) { + if (is_array($v)) { + $data[$k] = $this->trimArrayRecursive($v); + } else { + $data[$k] = trim($v); + } + } + } else { + $data = trim($data); + } + return $data; + } + protected function editQuestion(ilPropertyFormGUI $form = null) { if ($form === null) {