Separate save and save-and-close actions

This commit is contained in:
Wojtek
2026-10-15 21:33:19 +02:00
parent 8446e4a84a
commit eac29077fc
5 changed files with 24 additions and 7 deletions
@@ -0,0 +1 @@
-- No database changes required for version 1.28.0.
@@ -13,6 +13,26 @@ use Joomla\CMS\Session\Session;
class ResultController extends BaseController
{
public function save(): void
{
$this->saveAssessment();
$id = Factory::getApplication()->getInput()->post->getInt('id');
$this->setRedirect(
Route::_('index.php?option=com_testquestions&view=result&id=' . $id, false),
Text::_('COM_TESTQUESTIONS_RESULT_SAVED')
);
}
public function save2close(): void
{
$this->saveAssessment();
$this->setRedirect(
Route::_('index.php?option=com_testquestions&view=results', false),
Text::_('COM_TESTQUESTIONS_RESULT_SAVED')
);
}
private function saveAssessment(): void
{
if (!Session::checkToken()) {
throw new \RuntimeException(Text::_('JINVALID_TOKEN'), 403);
@@ -27,10 +47,5 @@ class ResultController extends BaseController
if (!$model->saveAssessment($id, $points, $comments)) {
throw new \RuntimeException(Text::_('COM_TESTQUESTIONS_RESULT_NOT_FOUND'));
}
$this->setRedirect(
Route::_('index.php?option=com_testquestions&view=result&id=' . $id, false),
Text::_('COM_TESTQUESTIONS_RESULT_SAVED')
);
}
}
@@ -22,6 +22,7 @@ class HtmlView extends BaseHtmlView
ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_RESULT_PREVIEW'));
ToolbarHelper::save('result.save', 'JTOOLBAR_SAVE');
ToolbarHelper::save2close('result.save2close', 'JTOOLBAR_SAVE_AND_CLOSE');
ToolbarHelper::link('index.php?option=com_testquestions&view=results', 'COM_TESTQUESTIONS_RESULTS', 'back');
return parent::display($tpl);