Skip to content

Commit d4629d1

Browse files
authored
Test 46663: Inline Error for Empty Question Delete (#11453)
* Test: Inline Error for Empty Question Delete See: https://mantis.ilias.de/view.php?id=46663 `QuestionsTableActions` now receives `ResponseHandler`: the delete action renders the async payload through it and returns instead of calling `exit()`. `getDeleteConfirmation()` returns a failure `MessageBox` with `msg_no_questions_selected` when no question rows are selected, otherwise the interruptive modal. The ordering-table async-message area in `tpl.orderingtable.html` uses a native `<dialog>` and a `formmethod="dialog"` close control so that message payload displays correctly; `OrderingRendererTest` expectations were updated.
1 parent 9c6c829 commit d4629d1

2 files changed

Lines changed: 25 additions & 23 deletions

File tree

components/ILIAS/Test/classes/class.ilObjTestGUI.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2766,7 +2766,8 @@ protected function getQuestionsTableActions(): QuestionsTableActions
27662766
$this->getTestObject()->getGlobalSettings()->isAdjustingQuestionsWithResultsAllowed(),
27672767
$this->getTestObject()->evalTotalPersons() !== 0,
27682768
$this->getTestObject()->isRandomTest(),
2769-
$this->test_question_set_config_factory
2769+
$this->test_question_set_config_factory,
2770+
$this->response_handler
27702771
);
27712772
}
27722773
return $this->table_actions;

components/ILIAS/Test/src/Questions/Presentation/QuestionsTableActions.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
namespace ILIAS\Test\Questions\Presentation;
2222

2323
use ILIAS\Test\Questions\Properties\Repository as TestQuestionsRepository;
24+
use ILIAS\Test\ResponseHandler;
2425
use ILIAS\UI\Factory as UIFactory;
2526
use ILIAS\UI\Renderer as UIRenderer;
2627
use ILIAS\UI\Component\Table\OrderingRow;
2728
use ILIAS\UI\Component\Table\Action\Action as TableAction;
29+
use ILIAS\UI\Component\MessageBox\MessageBox;
2830
use ILIAS\UI\Component\Modal\Interruptive;
2931
use ILIAS\Data\URI;
3032
use ILIAS\Language\Language;
@@ -66,7 +68,8 @@ public function __construct(
6668
private readonly bool $is_adjusting_questions_with_results_allowed,
6769
private readonly bool $is_in_test_with_results,
6870
private readonly bool $is_in_test_with_random_question_set,
69-
private readonly \ilTestQuestionSetConfigFactory $test_question_set_config_factory
71+
private readonly \ilTestQuestionSetConfigFactory $test_question_set_config_factory,
72+
private readonly ResponseHandler $test_response
7073
) {
7174
$this->table_id = (string) $test_obj->getId();
7275
}
@@ -220,10 +223,12 @@ public function handleCommand(
220223
return false;
221224

222225
case self::ACTION_DELETE:
223-
echo $this->ui_renderer->renderAsync(
224-
$this->getDeleteConfirmation(array_filter($row_ids))
226+
$this->test_response->sendAsync(
227+
$this->ui_renderer->renderAsync(
228+
$this->getDeleteConfirmation(array_filter($row_ids))
229+
)
225230
);
226-
exit();
231+
return false;
227232

228233
case self::ACTION_DELETE_CONFIRMED:
229234
$row_ids = $this->request->getParsedBody()['interruptive_items'] ?? [];
@@ -320,26 +325,12 @@ function (array $c, Types $v): array {
320325
}
321326
}
322327

323-
private function getDeleteConfirmation(array $row_ids): Interruptive
328+
private function getDeleteConfirmation(array $row_ids): Interruptive|MessageBox
324329
{
325-
$modal_factory = fn(string $msg): Interruptive =>
326-
$this->ui_factory->modal()->interruptive(
327-
$this->lng->txt('remove'),
328-
$msg,
329-
$this->table_query->getActionURL(self::ACTION_DELETE_CONFIRMED)->__toString()
330-
);
331-
332-
if (array_filter($row_ids) === []) {
333-
$msg = $this->lng->txt('msg_no_questions_selected');
334-
return $modal_factory($msg);
330+
if ($row_ids === []) {
331+
return $this->ui_factory->messageBox()->failure($this->lng->txt('msg_no_questions_selected'));
335332
}
336333

337-
$msg = $this->lng->txt(
338-
$this->is_in_test_with_results
339-
? 'tst_remove_questions_and_results'
340-
: 'tst_remove_questions'
341-
);
342-
343334
$items = [];
344335
foreach ($row_ids as $id) {
345336
$qdata = $this->test_obj->getQuestionDataset($id);
@@ -354,7 +345,17 @@ private function getDeleteConfirmation(array $row_ids): Interruptive
354345
$type
355346
);
356347
}
357-
return $modal_factory($msg)->withAffectedItems($items);
348+
349+
return $this->ui_factory->modal()->interruptive(
350+
$this->lng->txt('remove'),
351+
$this->lng->txt(
352+
$this->is_in_test_with_results
353+
? 'tst_remove_questions_and_results'
354+
: 'tst_remove_questions'
355+
),
356+
$this->table_query->getActionURL(self::ACTION_DELETE_CONFIRMED)->__toString()
357+
)
358+
->withAffectedItems($items);
358359
}
359360

360361
private function redirectWithQuestionParameters(

0 commit comments

Comments
 (0)