diff --git a/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php index 0320ddb123fd..c7bbc814eaa4 100755 --- a/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php +++ b/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php @@ -54,6 +54,7 @@ protected function setQuestionSpecificTabs(ilTabsGUI $ilTabs): void protected function callSpecialQuestionCommands(string $cmd): void { if (preg_match('/suggestrange_(\$r\d+)/', $cmd, $matches)) { + $this->addSaveOnEnterOnLoadCode(); $this->suggestRange($matches[1]); } } @@ -738,6 +739,7 @@ private function canUseAdvancedRating($result): bool public function parseQuestion(): void { $this->writePostData(); + $this->addSaveOnEnterOnLoadCode(); $this->editQuestion(); } diff --git a/Modules/TestQuestionPool/classes/class.assQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assQuestionGUI.php index 0c9d697177a1..f4b7226675c6 100755 --- a/Modules/TestQuestionPool/classes/class.assQuestionGUI.php +++ b/Modules/TestQuestionPool/classes/class.assQuestionGUI.php @@ -234,20 +234,11 @@ public function executeCommand() case 'addGIT': $this->$cmd(); break; + case 'save': + case 'saveReturn': case 'editQuestion': - $this->tpl->addOnloadCode(" - let form = document.querySelector('#ilContentContainer form'); - let button = form.querySelector('input[name=\"cmd[save]\"]'); - if (form && button) { - form.addEventListener('keydown', function (e) { - if (e.key === 'Enter' && e.target.type !== 'textarea') { - e.preventDefault(); - form.requestSubmit(button); - } - }) - } - "); - $this->editQuestion(); + $this->addSaveOnEnterOnLoadCode(); + $this->$cmd(); break; default: if (method_exists($this, $cmd)) { @@ -2046,4 +2037,19 @@ public function setInLearningModuleContext(bool $flag): void $this->parent_type_is_lm = $flag; } + protected function addSaveOnEnterOnLoadCode(): void + { + $this->tpl->addOnloadCode(" + let form = document.querySelector('#ilContentContainer form'); + let button = form.querySelector('input[name=\"cmd[save]\"]'); + if (form && button) { + form.addEventListener('keydown', function (e) { + if (e.key === 'Enter' && e.target.type !== 'textarea') { + e.preventDefault(); + form.requestSubmit(button); + } + }) + } + "); + } }