Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/ILIAS/Test/classes/class.ilObjTestGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -2764,7 +2764,8 @@ protected function getQuestionsTableActions(): QuestionsTableActions
$this->getTestObject()->getGlobalSettings()->isAdjustingQuestionsWithResultsAllowed(),
$this->getTestObject()->evalTotalPersons() !== 0,
$this->getTestObject()->isRandomTest(),
$this->test_question_set_config_factory
$this->test_question_set_config_factory,
$this->response_handler
);
}
return $this->table_actions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
namespace ILIAS\Test\Questions\Presentation;

use ILIAS\Test\Questions\Properties\Repository as TestQuestionsRepository;
use ILIAS\Test\ResponseHandler;
use ILIAS\UI\Factory as UIFactory;
use ILIAS\UI\Renderer as UIRenderer;
use ILIAS\UI\Component\Table\OrderingRow;
use ILIAS\UI\Component\Table\Action\Action as TableAction;
use ILIAS\UI\Component\MessageBox\MessageBox;
use ILIAS\UI\Component\Modal\Interruptive;
use ILIAS\Data\URI;
use ILIAS\Language\Language;
Expand Down Expand Up @@ -66,7 +68,8 @@ public function __construct(
private readonly bool $is_adjusting_questions_with_results_allowed,
private readonly bool $is_in_test_with_results,
private readonly bool $is_in_test_with_random_question_set,
private readonly \ilTestQuestionSetConfigFactory $test_question_set_config_factory
private readonly \ilTestQuestionSetConfigFactory $test_question_set_config_factory,
private readonly ResponseHandler $test_response
) {
$this->table_id = (string) $test_obj->getId();
}
Expand Down Expand Up @@ -220,10 +223,12 @@ public function handleCommand(
return false;

case self::ACTION_DELETE:
echo $this->ui_renderer->renderAsync(
$this->getDeleteConfirmation(array_filter($row_ids))
$this->test_response->sendAsync(
$this->ui_renderer->renderAsync(
$this->getDeleteConfirmation(array_filter($row_ids))
)
);
exit();
return false;

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

private function getDeleteConfirmation(array $row_ids): Interruptive
private function getDeleteConfirmation(array $row_ids): Interruptive|MessageBox
{
$modal_factory = fn(string $msg): Interruptive =>
$this->ui_factory->modal()->interruptive(
$this->lng->txt('remove'),
$msg,
$this->table_query->getActionURL(self::ACTION_DELETE_CONFIRMED)->__toString()
);

if (array_filter($row_ids) === []) {
$msg = $this->lng->txt('msg_no_questions_selected');
return $modal_factory($msg);
if ($row_ids === []) {
return $this->ui_factory->messageBox()->failure($this->lng->txt('msg_no_questions_selected'));
}

$msg = $this->lng->txt(
$this->is_in_test_with_results
? 'tst_remove_questions_and_results'
: 'tst_remove_questions'
);

$items = [];
foreach ($row_ids as $id) {
$qdata = $this->test_obj->getQuestionDataset($id);
Expand All @@ -354,7 +345,17 @@ private function getDeleteConfirmation(array $row_ids): Interruptive
$type
);
}
return $modal_factory($msg)->withAffectedItems($items);

return $this->ui_factory->modal()->interruptive(
$this->lng->txt('remove'),
$this->lng->txt(
$this->is_in_test_with_results
? 'tst_remove_questions_and_results'
: 'tst_remove_questions'
),
$this->table_query->getActionURL(self::ACTION_DELETE_CONFIRMED)->__toString()
)
->withAffectedItems($items);
}

private function redirectWithQuestionParameters(
Expand Down
Loading