From bb5bc500b4d80cf6697681d7fcb54cffceb14134 Mon Sep 17 00:00:00 2001 From: okaufman Date: Mon, 16 May 2022 17:05:45 +0200 Subject: [PATCH] fix 30658 --- .../classes/class.assLongMenuGUI.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php b/Modules/TestQuestionPool/classes/class.assLongMenuGUI.php index faf7e35ba2c0..73954ff84423 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) {