diff --git a/Modules/Test/classes/class.ilMarkSchemaGUI.php b/Modules/Test/classes/class.ilMarkSchemaGUI.php index 35c0f782f32a..eeafecb0a937 100644 --- a/Modules/Test/classes/class.ilMarkSchemaGUI.php +++ b/Modules/Test/classes/class.ilMarkSchemaGUI.php @@ -75,11 +75,7 @@ protected function addMarkStep(): void { $this->ensureMarkSchemaCanBeEdited(); - if ($this->saveMarkSchemaFormData()) { - $this->object->getMarkSchema()->addMarkStep(); - } else { - $this->tpl->setOnScreenMessage('failure', $this->lng->txt('mark_schema_invalid'), true); - } + $this->object->getMarkSchema()->addMarkStep(); $this->showMarkSchema(); } @@ -212,17 +208,19 @@ protected function showMarkSchema(): void $mark_schema_table = new ilMarkSchemaTableGUI($this, 'showMarkSchema', $this->object); if ($this->object->canEditMarks()) { - $create_simple_mark_schema_button = ilSubmitButton::getInstance(); - $create_simple_mark_schema_button->setCaption($this->lng->txt('tst_mark_create_simple_mark_schema'), false); - $create_simple_mark_schema_button->setCommand('addSimpleMarkSchema'); - $this->toolbar->addButtonInstance($create_simple_mark_schema_button); - - $create_new_mark_step_button = ilButton::getInstance(); - $create_new_mark_step_button->setCaption($this->lng->txt('tst_mark_create_new_mark_step'), false); - $create_new_mark_step_button->setButtonType(ilButton::BUTTON_TYPE_SUBMIT); - $create_new_mark_step_button->setForm('form_' . $mark_schema_table->getId()); - $create_new_mark_step_button->setName('addMarkStep'); - $this->toolbar->addButtonInstance($create_new_mark_step_button); + global $DIC; + $button = $DIC->ui()->factory()->button()->standard( + $this->lng->txt('tst_mark_create_simple_mark_schema'), + $this->ctrl->getFormAction($this, 'addSimpleMarkSchema') + ); + $this->toolbar->addComponent($button); + + $button = $DIC->ui()->factory()->button()->standard( + $this->lng->txt('tst_mark_create_new_mark_step'), + $this->ctrl->getFormAction($this, 'addMarkStep') + ); + $this->toolbar->addComponent($button); + } diff --git a/Modules/Test/classes/class.ilObjTest.php b/Modules/Test/classes/class.ilObjTest.php index 06a1090207e1..a4cd6da05c65 100755 --- a/Modules/Test/classes/class.ilObjTest.php +++ b/Modules/Test/classes/class.ilObjTest.php @@ -1010,7 +1010,7 @@ public function getProcessingTimeAsArray(): array { $processing_time = $this->getMainSettings()->getTestBehaviourSettings()->getProcessingTime(); if ($processing_time && $processing_time !== '') { - if (preg_match("/(\d{2}):(\d{2}):(\d{2})/is", $processing_time, $matches)) { + if (preg_match("/(\d{2}):(\d{2}):(\d{2})/is", (string) $processing_time, $matches)) { return array( 'hh' => $matches[1], 'mm' => $matches[2], @@ -1020,6 +1020,17 @@ public function getProcessingTimeAsArray(): array } } + public function getProcessingTimeAsMinutes() + { + if ($this->processing_time !== null) { + if (preg_match("/(\d{2}):(\d{2}):(\d{2})/is", (string)$this->processing_time, $matches)) { + return ($matches[1] * 60) + $matches[2]; + } + } + + return self::DEFAULT_PROCESSING_TIME_MINUTES; + } + /** * Returns the processing time for the test in seconds * @@ -1030,7 +1041,7 @@ public function getProcessingTimeAsArray(): array public function getProcessingTimeInSeconds($active_id = ""): int { $processing_time = $this->getMainSettings()->getTestBehaviourSettings()->getProcessingTime() ?? ''; - if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", $processing_time, $matches)) { + if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", (string)$processing_time, $matches)) { $extratime = $this->getExtraTime($active_id) * 60; return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3] + $extratime; } else { diff --git a/Modules/Test/classes/class.ilObjTestGUI.php b/Modules/Test/classes/class.ilObjTestGUI.php index 9c9c6748c231..89f96a2dbdb5 100755 --- a/Modules/Test/classes/class.ilObjTestGUI.php +++ b/Modules/Test/classes/class.ilObjTestGUI.php @@ -2904,7 +2904,7 @@ public function buildPageViewToolbar($qid = 0) if ($this->create_question_mode) { return; } - +exit; $this->ctrl->saveParameter($this, 'q_mode'); $this->ctrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1); @@ -2942,19 +2942,15 @@ public function buildPageViewToolbar($qid = 0) $this->toolbar->addSeparator(); } - $btn = ilLinkButton::getInstance(); - $btn->setCaption("test_prev_question"); - $btn->setUrl($this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion')); - $this->toolbar->addButtonInstance($btn); + $btn = $this->ui[0]->linkButton()->standard($lng->txt("test_prev_question"), $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion')); + $this->toolbar->addComponent($btn); if (count($options) <= 1 || $optionKeys[0] == $qid) { $btn->setDisabled(true); } - $btn = ilLinkButton::getInstance(); - $btn->setCaption("test_next_question"); - $btn->setUrl($this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion')); - $this->toolbar->addButtonInstance($btn); + $btn = $this->ui[0]->linkButton()->standard($lng->txt("test_next_question"), $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion')); + $this->toolbar->addComponent($btn); if (count($options) <= 1 || $optionKeys[count($optionKeys) - 1] == $qid) { $btn->setDisabled(true); diff --git a/Modules/Test/classes/class.ilParticipantsTestResultsGUI.php b/Modules/Test/classes/class.ilParticipantsTestResultsGUI.php index 3b2138dcaee8..e966888c0961 100644 --- a/Modules/Test/classes/class.ilParticipantsTestResultsGUI.php +++ b/Modules/Test/classes/class.ilParticipantsTestResultsGUI.php @@ -42,6 +42,12 @@ class ilParticipantsTestResultsGUI public const CMD_PERFORM_DELETE_ALL_USER_RESULTS = 'confirmDeleteAllUserResults'; public const CMD_CONFIRM_DELETE_SELECTED_USER_RESULTS = 'deleteSingleUserResults'; public const CMD_PERFORM_DELETE_SELECTED_USER_RESULTS = 'confirmDeleteSelectedUserData'; + private \ILIAS\DI\UIServices $ui; + + /** + * @var ilObjTest + */ + protected $testObj; protected ?ilObjTest $test_obj = null; protected ?ilTestQuestionSetConfig $question_set_config = null; @@ -203,10 +209,8 @@ protected function showParticipantsCmd() protected function addDeleteAllTestResultsButton(ilToolbarGUI $toolbar) { - $delete_all_results_btn = ilLinkButton::getInstance(); - $delete_all_results_btn->setCaption('delete_all_user_data'); - $delete_all_results_btn->setUrl($this->ctrl->getLinkTarget($this, 'deleteAllUserResults')); - $toolbar->addButtonInstance($delete_all_results_btn); + $delete_all_results_btn = $this->ui_factory->button()->standard($this->lng->txt('delete_all_user_data'), $this->ctrl->getLinkTarget($this, 'deleteAllUserResults')); + $toolbar->addComponent($delete_all_results_btn); } /** @@ -362,7 +366,7 @@ protected function showUserResults($show_pass_details, $show_answers, $show_reac } - $template = $this->createUserResults($show_pass_details, $show_answers, $show_reached_points, $show_user_results); + $template = $this->createUserResults($show_pass_details, $show_answers, $show_reached_points, (bool)$show_user_results); if ($template instanceof ilTemplate) { $this->main_tpl->setVariable("ADM_CONTENT", $template->get()); diff --git a/Modules/Test/classes/class.ilTestEvaluationGUI.php b/Modules/Test/classes/class.ilTestEvaluationGUI.php index 79a6f128bd8c..098355030922 100644 --- a/Modules/Test/classes/class.ilTestEvaluationGUI.php +++ b/Modules/Test/classes/class.ilTestEvaluationGUI.php @@ -44,6 +44,7 @@ */ class ilTestEvaluationGUI extends ilTestServiceGUI { + private \ILIAS\DI\UIServices $ui; protected ilTestAccess $testAccess; protected ilTestProcessLockerFactory $processLockerFactory; @@ -60,9 +61,9 @@ class ilTestEvaluationGUI extends ilTestServiceGUI public function __construct(ilObjTest $object) { parent::__construct($object); - + global $DIC; $this->participant_access_filter = new ilTestParticipantAccessFilterFactory($this->access); - + $this->ui = $DIC->ui(); $this->processLockerFactory = new ilTestProcessLockerFactory( new ilSetting('assessment'), $this->db @@ -358,10 +359,8 @@ public function detailedEvaluation() $this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print'); - $backBtn = ilLinkButton::getInstance(); - $backBtn->setCaption('back'); - $backBtn->setUrl($this->ctrl->getLinkTarget($this, 'outEvaluation')); - $this->toolbar->addInputItem($backBtn); + $backBtn = $this->ui->factory()->button()->standard($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'outEvaluation')); + $this->toolbar->addComponent($backBtn); $this->object->setAccessFilteredParticipantList( $this->object->buildStatisticsAccessFilteredParticipantList() diff --git a/Modules/Test/classes/class.ilTestNavigationToolbarGUI.php b/Modules/Test/classes/class.ilTestNavigationToolbarGUI.php index 2296f2fc731c..17a6bd9cdd3d 100644 --- a/Modules/Test/classes/class.ilTestNavigationToolbarGUI.php +++ b/Modules/Test/classes/class.ilTestNavigationToolbarGUI.php @@ -280,62 +280,44 @@ public function getFinishTestModalHTML(): string private function addSuspendTestButton() { - $btn = ilTestPlayerNavButton::getInstance(); - $btn->setNextCommand(ilTestPlayerCommands::SUSPEND_TEST); - $btn->setUrl($this->ctrl->getLinkTarget( - $this->playerGUI, - ilTestPlayerCommands::SUSPEND_TEST - )); - $btn->setCaption('cancel_test'); - //$btn->setDisabled($this->isDisabledStateEnabled()); - $btn->addCSSClass('ilTstNavElem'); - $this->addButtonInstance($btn); + $button = $this->ui->factory()->button()->standard( + $this->lng->txt('cancel_test'), + $this->ctrl->getLinkTarget($this->playerGUI, ilTestPlayerCommands::SUSPEND_TEST) + ); + $this->addComponent($button); } private function addQuestionListButton() { - $btn = ilTestPlayerNavButton::getInstance(); - $btn->setNextCommand(ilTestPlayerCommands::QUESTION_SUMMARY); - $btn->setUrl($this->ctrl->getLinkTarget( - $this->playerGUI, - ilTestPlayerCommands::QUESTION_SUMMARY - )); - $btn->setCaption('question_summary_btn'); - //$btn->setDisabled($this->isDisabledStateEnabled()); - $btn->addCSSClass('ilTstNavElem'); - $this->addButtonInstance($btn); + $button = $this->ui->factory()->button()->standard( + $this->lng->txt('question_summary_btn'), + $this->ctrl->getLinkTarget($this->playerGUI, ilTestPlayerCommands::QUESTION_SUMMARY) + ); + $this->addComponent($button); } private function addQuestionSelectionButton() { - $btn = ilTestPlayerNavButton::getInstance(); - $btn->setNextCommand(ilTestPlayerCommands::SHOW_QUESTION_SELECTION); - $btn->setUrl($this->ctrl->getLinkTarget( - $this->playerGUI, - ilTestPlayerCommands::SHOW_QUESTION_SELECTION - )); - $btn->setCaption('tst_change_dyn_test_question_selection'); - //$btn->setDisabled($this->isDisabledStateEnabled()); - $btn->addCSSClass('ilTstNavElem'); - $this->addButtonInstance($btn); + $button = $this->ui->factory()->button()->standard( + $this->lng->txt('tst_change_dyn_test_question_selection'), + $this->ctrl->getLinkTarget($this->playerGUI, ilTestPlayerCommands::SHOW_QUESTION_SELECTION) + ); + $this->addComponent($button); } private function addQuestionTreeButton() { - $btn = ilTestPlayerNavButton::getInstance(); - $btn->setNextCommand(ilTestPlayerCommands::TOGGLE_SIDE_LIST); - $btn->setUrl($this->ctrl->getLinkTarget( - $this->playerGUI, - ilTestPlayerCommands::TOGGLE_SIDE_LIST - )); if ($this->isQuestionTreeVisible()) { - $btn->setCaption('tst_hide_side_list'); + $btn_cap = $this->lng->txt('tst_hide_side_list'); } else { - $btn->setCaption('tst_show_side_list'); + $btn_cap = $this->lng->txt('tst_show_side_list'); } - //$btn->setDisabled($this->isDisabledStateEnabled()); - $btn->addCSSClass('ilTstNavElem'); - $this->addButtonInstance($btn); + + $button = $this->ui->factory()->button()->standard( + $btn_cap, + $this->ctrl->getLinkTarget($this->playerGUI, ilTestPlayerCommands::TOGGLE_SIDE_LIST) + ); + $this->addComponent($button); } private function addFinishTestButton(): void diff --git a/Modules/Test/classes/class.ilTestOutputGUI.php b/Modules/Test/classes/class.ilTestOutputGUI.php index d7b486362bb0..805a41797d9c 100755 --- a/Modules/Test/classes/class.ilTestOutputGUI.php +++ b/Modules/Test/classes/class.ilTestOutputGUI.php @@ -424,7 +424,7 @@ protected function showQuestionCmd() $this->populateTestNavigationToolbar($navigationToolbarGUI); // fau: testNav - enable the question navigation in edit mode - $this->populateQuestionNavigation($sequence_element, false, $isNextPrimary); + $this->populateQuestionNavigation($sequence_element, $isNextPrimary); // fau. if ($instantResponse) { diff --git a/Modules/Test/classes/class.ilTestParticipantsGUI.php b/Modules/Test/classes/class.ilTestParticipantsGUI.php index 4e2c54fb33da..0ef3faa8618c 100644 --- a/Modules/Test/classes/class.ilTestParticipantsGUI.php +++ b/Modules/Test/classes/class.ilTestParticipantsGUI.php @@ -311,15 +311,23 @@ protected function addUserSearchControls(ilToolbarGUI $toolbar): void $search_btn->setUrl($this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI', 'start')); $toolbar->addSeparator(); - $toolbar->addButtonInstance($search_btn); + + $search_btn = $DIC->ui()->factory()->button()->standard( + $DIC->language()->txt('tst_search_users'), + $DIC->ctrl()->getLinkTargetByClass('ilRepositorySearchGUI', 'start') + ); + $toolbar->addComponent($search_btn); } protected function addFinishAllPassesButton(ilToolbarGUI $toolbar): void { - $finish_all_user_passes_btn = ilLinkButton::getInstance(); - $finish_all_user_passes_btn->setCaption('finish_all_user_passes'); - $finish_all_user_passes_btn->setUrl($this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'finishAllUserPasses')); - $toolbar->addButtonInstance($finish_all_user_passes_btn); + global $DIC; /* @var ILIAS\DI\Container $DIC */ + + $finish_all_user_passes_btn = $DIC->ui()->factory()->button()->standard( + $DIC->language()->txt('finish_all_user_passes'), + $DIC->ctrl()->getLinkTargetByClass('iltestevaluationgui', 'finishAllUserPasses') + ); + $toolbar->addComponent($finish_all_user_passes_btn); } protected function saveClientIpCmd(): void diff --git a/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php b/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php index c2f421d69ecf..293fc98eb01d 100755 --- a/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php +++ b/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php @@ -40,6 +40,7 @@ abstract class ilTestPlayerAbstractGUI extends ilTestServiceGUI public const PRESENTATION_MODE_EDIT = 'edit'; public const FIXED_SHUFFLER_SEED_MIN_LENGTH = 8; + private \ILIAS\DI\UIServices $ui; public bool $maxProcessingTimeReached; public bool $endingTimeReached; @@ -53,9 +54,10 @@ abstract class ilTestPlayerAbstractGUI extends ilTestServiceGUI public function __construct(ilObjTest $object) { parent::__construct($object); - + global $DIC; $this->ref_id = $this->testrequest->getRefId(); $this->passwordChecker = new ilTestPasswordChecker($this->rbac_system, $this->user, $this->object, $this->lng); + $this->ui = $DIC->ui(); } protected function checkReadAccess() @@ -193,104 +195,95 @@ protected function populateTestNavigationToolbar(ilTestNavigationToolbarGUI $too $this->tpl->parseCurrentBlock(); } - protected function populateQuestionNavigation($sequence_element, bool $disabled, $primary_next): void + protected function populateQuestionNavigation($sequence_element, $primary_next): void { if (!$this->isFirstQuestionInSequence($sequence_element)) { - $this->populatePreviousButtons($disabled); + $this->populatePreviousButtons(); } if (!$this->isLastQuestionInSequence($sequence_element)) { - $this->populateNextButtons($disabled, $primary_next); + $this->populateNextButtons($primary_next); } } - protected function populatePreviousButtons(bool $disabled): void + protected function populatePreviousButtons(): void { - $this->populateUpperPreviousButtonBlock($disabled); - $this->populateLowerPreviousButtonBlock($disabled); + $this->populateUpperPreviousButtonBlock(); + $this->populateLowerPreviousButtonBlock(); } - protected function populateNextButtons(bool $disabled, $primary_next): void + protected function populateNextButtons($primary_next): void { - $this->populateUpperNextButtonBlock($disabled, $primary_next); - $this->populateLowerNextButtonBlock($disabled, $primary_next); + $this->populateUpperNextButtonBlock($primary_next); + $this->populateLowerNextButtonBlock($primary_next); } - protected function populateLowerNextButtonBlock(bool $disabled, $primary_next): void + protected function populateLowerNextButtonBlock($primary_next): void { - $button = $this->buildNextButtonInstance($disabled, $primary_next); - $button->setId('bottomnextbutton'); + $button = $this->buildNextButtonInstance($primary_next); $this->tpl->setCurrentBlock("next_bottom"); - $this->tpl->setVariable("BTN_NEXT_BOTTOM", $button->render()); + $this->tpl->setVariable("BTN_NEXT_BOTTOM", $this->ui_renderer->render($button)); $this->tpl->parseCurrentBlock(); } - protected function populateUpperNextButtonBlock($disabled, $primaryNext) + protected function populateUpperNextButtonBlock($primaryNext) { - $button = $this->buildNextButtonInstance($disabled, $primaryNext); - $button->setId('nextbutton'); + $button = $this->buildNextButtonInstance($primaryNext); $this->tpl->setCurrentBlock("next"); - $this->tpl->setVariable("BTN_NEXT", $button->render()); + $this->tpl->setVariable("BTN_NEXT", $this->ui_renderer->render($button)); $this->tpl->parseCurrentBlock(); } - protected function populateLowerPreviousButtonBlock($disabled) + protected function populateLowerPreviousButtonBlock() { - $button = $this->buildPreviousButtonInstance($disabled); - $button->setId('bottomprevbutton'); + $button = $this->buildPreviousButtonInstance(); $this->tpl->setCurrentBlock("prev_bottom"); - $this->tpl->setVariable("BTN_PREV_BOTTOM", $button->render()); + $this->tpl->setVariable("BTN_PREV_BOTTOM", $this->ui_renderer->render($button)); $this->tpl->parseCurrentBlock(); } - protected function populateUpperPreviousButtonBlock($disabled) + protected function populateUpperPreviousButtonBlock() { - $button = $this->buildPreviousButtonInstance($disabled); - $button->setId('prevbutton'); + $button = $this->buildPreviousButtonInstance(); $this->tpl->setCurrentBlock("prev"); - $this->tpl->setVariable("BTN_PREV", $button->render()); + $this->tpl->setVariable("BTN_PREV", $this->ui_renderer->render($button)); $this->tpl->parseCurrentBlock(); } /** - * @param bool $disabled * @param bool $primaryNext - * @return ilButtonBase|ilLinkButton|ilTestPlayerNavButton + * @return \ILIAS\UI\Component\Button\Primary */ - private function buildNextButtonInstance($disabled, $primaryNext) + private function buildNextButtonInstance($primaryNext) { - $button = ilTestPlayerNavButton::getInstance(); - // fau: testNav - set glyphicon and primary - $button->setPrimary($primaryNext); - $button->setRightGlyph('glyphicon glyphicon-arrow-right'); - // fau. - $button->setNextCommand(ilTestPlayerCommands::NEXT_QUESTION); - $button->setUrl($this->ctrl->getLinkTarget($this, ilTestPlayerCommands::NEXT_QUESTION)); - $button->setCaption('next_question'); - $button->addCSSClass('ilTstNavElem'); - //$button->setDisabled($disabled); + if ($primaryNext) { + $button = $this->ui->factory()->button()->primary( + $this->lng->txt('next_question') . ' ', + $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::NEXT_QUESTION) + ); + } else { + $button = $this->ui->factory()->button()->standard( + $this->lng->txt('next_question') . ' ', + $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::NEXT_QUESTION) + ); + } return $button; } /** * @param $disabled - * @return ilTestPlayerNavButton + * @return \ILIAS\UI\Component\Button\Primary */ - private function buildPreviousButtonInstance($disabled): ilTestPlayerNavButton + private function buildPreviousButtonInstance() { - $button = ilTestPlayerNavButton::getInstance(); - // fau: testNav - set glyphicon and primary - $button->setLeftGlyph('glyphicon glyphicon-arrow-left'); - // fau. - $button->setNextCommand(ilTestPlayerCommands::PREVIOUS_QUESTION); - $button->setUrl($this->ctrl->getLinkTarget($this, ilTestPlayerCommands::PREVIOUS_QUESTION)); - $button->setCaption('previous_question'); - $button->addCSSClass('ilTstNavElem'); - //$button->setDisabled($disabled); + $button = $this->ui->factory()->button()->primary( + $this->lng->txt('previous_question') . ' ', + $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::PREVIOUS_QUESTION) + ); return $button; } @@ -1954,12 +1947,15 @@ protected function populateInstantResponseModal(assQuestionGUI $questionGui, $na $tpl->setVariable('QUESTION_OUTPUT', $pageoutput); + /* $button = ilLinkButton::getInstance(); $button->setId('tst_confirm_feedback'); $button->setUrl($navUrl); $button->setCaption('proceed'); $button->setPrimary(true); - $tpl->setVariable('BUTTON', $button->render()); + */ + $button = $this->ui->factory()->button()->primary($this->lng->txt('proceed'), $navUrl); + $tpl->setVariable('BUTTON', $this->ui->renderer()->render($button)); $modal = ilModalGUI::getInstance(); $modal->setType(ilModalGUI::TYPE_LARGE); @@ -2317,19 +2313,14 @@ protected function populateDiscardSolutionModal() $tpl->setVariable('CONFIRMATION_TEXT', $this->lng->txt('discard_answer_confirmation')); - $button = ilSubmitButton::getInstance(); - $button->setCommand(ilTestPlayerCommands::DISCARD_SOLUTION); - $button->setCaption('discard_answer'); + $button = $this->ui_factory->button()->standard($this->lng->txt('discard_answer'), '#'); $tpl->setCurrentBlock('buttons'); - $tpl->setVariable('BUTTON', $button->render()); + $tpl->setVariable('BUTTON', $this->ui_renderer->render($button)); $tpl->parseCurrentBlock(); - $button = ilLinkButton::getInstance(); - $button->setId('tst_cancel_discard_button'); - $button->setCaption('cancel'); - $button->setPrimary(true); + $button = $this->ui_factory->button()->primary($this->lng->txt('cancel'), '#'); $tpl->setCurrentBlock('buttons'); - $tpl->setVariable('BUTTON', $button->render()); + $tpl->setVariable('BUTTON', $this->ui_renderer->render($button)); $tpl->parseCurrentBlock(); $modal = ilModalGUI::getInstance(); @@ -2362,14 +2353,17 @@ protected function populateNavWhenChangedModal() } $tpl->setVariable('CONFIRMATION_TEXT', $text); - + /* $button = ilLinkButton::getInstance(); $button->setId('tst_save_on_navigation_button'); $button->setUrl('#'); $button->setCaption('tst_save_and_proceed'); $button->setPrimary(true); + */ + $button = $this->ui->factory()->button()->primary($this->lng->txt('tst_save_and_proceed'), '#'); + $tpl->setCurrentBlock('buttons'); - $tpl->setVariable('BUTTON', $button->render()); + $tpl->setVariable('BUTTON', $this->ui->renderer()->render($button)); $tpl->parseCurrentBlock(); $button = ilLinkButton::getInstance(); diff --git a/Modules/Test/classes/class.ilTestPlayerConfirmationModal.php b/Modules/Test/classes/class.ilTestPlayerConfirmationModal.php index 21570ad2435d..14937932e6e7 100644 --- a/Modules/Test/classes/class.ilTestPlayerConfirmationModal.php +++ b/Modules/Test/classes/class.ilTestPlayerConfirmationModal.php @@ -28,6 +28,8 @@ */ class ilTestPlayerConfirmationModal { + private \ILIAS\DI\UIServices $ui; + /** * @var string */ @@ -54,7 +56,7 @@ class ilTestPlayerConfirmationModal protected $confirmationCheckboxLabel = ''; /** - * @var ilLinkButton[] + * @var \ILIAS\UI\Component\Button\Standard[] */ protected $buttons = array(); @@ -63,6 +65,12 @@ class ilTestPlayerConfirmationModal */ protected $parameters = array(); + public function __construct() + { + global $DIC; + $this->ui = $DIC->ui(); + } + /** * @return string */ @@ -144,7 +152,7 @@ public function setConfirmationCheckboxLabel($confirmationCheckboxLabel) } /** - * @return ilLinkButton[] + * @return \ILIAS\UI\Component\Button\Standard[] */ public function getButtons(): array { @@ -152,9 +160,9 @@ public function getButtons(): array } /** - * @param ilLinkButton $button + * @param \ILIAS\UI\Component\Button\Standard|ilLinkButton $button */ - public function addButton(ilLinkButton $button) + public function addButton(\ILIAS\UI\Component\Button\Standard|\ILIAS\UI\Implementation\Component\Button\Primary|ilLinkButton $button) { $this->buttons[] = $button; } @@ -205,7 +213,13 @@ public function buildBody(): string foreach ($this->getButtons() as $button) { $tpl->setCurrentBlock('buttons'); - $tpl->setVariable('BUTTON', $button->render()); + if ($button instanceof \ILIAS\UI\Component\Button\Standard || $button instanceof \ILIAS\UI\Implementation\Component\Button\Primary) { + $button_str = $this->ui->renderer()->render($button); + } elseif ($button instanceof ilLinkButton) { + $button_str = $button->render(); + } + + $tpl->setVariable('BUTTON', $button_str); $tpl->parseCurrentBlock(); } @@ -233,7 +247,6 @@ public function getHTML(): string public function buildModalButtonInstance($buttonId): ilLinkButton { $button = ilLinkButton::getInstance(); - $button->setUrl('#'); $button->setId($buttonId); diff --git a/Modules/Test/classes/class.ilTestQuestionNavigationGUI.php b/Modules/Test/classes/class.ilTestQuestionNavigationGUI.php index e705d378f409..b91c4f4124be 100644 --- a/Modules/Test/classes/class.ilTestQuestionNavigationGUI.php +++ b/Modules/Test/classes/class.ilTestQuestionNavigationGUI.php @@ -29,6 +29,7 @@ class ilTestQuestionNavigationGUI public const SHOW_DISABLED_COMMANDS = false; public const CSS_CLASS_SUBMIT_BUTTONS = 'ilc_qsubmit_Submit'; + private \ILIAS\DI\UIServices $ui; /** * @var ilLanguage @@ -120,6 +121,8 @@ class ilTestQuestionNavigationGUI public function __construct(ilLanguage $lng) { $this->lng = $lng; + global $DIC; + $this->ui = $DIC->ui(); } /** @@ -663,13 +666,17 @@ private function renderButtonInstance(ilTemplate $tpl, $button) */ private function renderSubmitButton(ilTemplate $tpl, $command, $label, $primary = false) { - $button = ilSubmitButton::getInstance(); - $button->setCommand($command); - $button->setCaption($label); - $button->setPrimary($primary); - $button->addCSSClass(self::CSS_CLASS_SUBMIT_BUTTONS); - - $this->renderButtonInstance($tpl, $button); + if ($primary) { + $this->renderButtonInstance( + $tpl, + $this->ui->factory()->button()->primary($label, $command) + ); + } else { + $this->renderButtonInstance( + $tpl, + $this->ui->factory()->button()->standard($label, $command) + ); + } } /** @@ -680,27 +687,7 @@ private function renderSubmitButton(ilTemplate $tpl, $command, $label, $primary */ private function renderLinkButton(ilTemplate $tpl, $href, $label) { - $button = ilLinkButton::getInstance(); - $button->setUrl($href); - $button->setCaption($label); - - $this->renderButtonInstance($tpl, $button); - } - - /** - * @param ilTemplate $tpl - * @param $htmlId - * @param $label - * @param $cssClass - */ - private function renderJsLinkedButton(ilTemplate $tpl, $htmlId, $label, $cssClass) - { - $button = ilLinkButton::getInstance(); - $button->setId($htmlId); - $button->addCSSClass($cssClass); - $button->setCaption($label); - - $this->renderButtonInstance($tpl, $button); + $this->renderButtonInstance($tpl, $this->ui->factory()->button()->standard($label, $href)); } /** diff --git a/Modules/Test/classes/class.ilTestResultsGUI.php b/Modules/Test/classes/class.ilTestResultsGUI.php index 16b7394f2e9b..88e57d256208 100644 --- a/Modules/Test/classes/class.ilTestResultsGUI.php +++ b/Modules/Test/classes/class.ilTestResultsGUI.php @@ -42,6 +42,7 @@ class ilTestResultsGUI { public const DEFAULT_CMD = 'show'; + private \ILIAS\DI\UIServices $ui; protected ilTestAccess $testAccess; protected ilTestSession $testSession; @@ -283,10 +284,8 @@ protected function showCmd(): void $validator = new ilCertificateDownloadValidator(); if ($validator->isCertificateDownloadable($this->user->getId(), $this->getTestObj()->getId())) { - $button = ilLinkButton::getInstance(); - $button->setCaption('certificate'); - $button->setUrl($this->ctrl->getFormActionByClass(ilTestEvaluationGUI::class, 'outCertificate')); - $this->toolbar->addButtonInstance($button); + $button = $this->ui->factory()->button()->standard('certficiate', $this->ctrl->getFormActionByClass(ilTestEvaluationGUI::class, 'outCertificate')); + $this->toolbar->addComponent($button); } $this->showNoResultsReportingMessage(); diff --git a/Modules/Test/classes/class.ilTestSequence.php b/Modules/Test/classes/class.ilTestSequence.php index 3830a8aef64f..1888b06748be 100644 --- a/Modules/Test/classes/class.ilTestSequence.php +++ b/Modules/Test/classes/class.ilTestSequence.php @@ -528,27 +528,27 @@ public function getSequenceForQuestion(int $question_id): ?int return array_search($question_id, $this->questions) ?: null; } - public function getFirstSequence(): ?int + public function getFirstSequence(): int { $correctedsequence = $this->getCorrectedSequence(); if (count($correctedsequence)) { return reset($correctedsequence); } - return null; + return 0; } - public function getLastSequence(): ?int + public function getLastSequence(): int { $correctedsequence = $this->getCorrectedSequence(); if (count($correctedsequence)) { return end($correctedsequence); } - return null; + return 0; } - public function getNextSequence(int $sequence): ?int + public function getNextSequence(int $sequence): int { $corrected_sequence = $this->getCorrectedSequence(); $sequence_key = array_search($sequence, $corrected_sequence); @@ -558,10 +558,10 @@ public function getNextSequence(int $sequence): ?int return $corrected_sequence[$next_sequence_key]; } } - return null; + return 0; } - public function getPreviousSequence(int $sequence): ?int + public function getPreviousSequence(int $sequence): int { $correctedsequence = $this->getCorrectedSequence(); $sequencekey = array_search($sequence, $correctedsequence); @@ -572,7 +572,7 @@ public function getPreviousSequence(int $sequence): ?int } } - return null; + return 0; } /** diff --git a/Modules/Test/classes/class.ilTestSubmissionReviewGUI.php b/Modules/Test/classes/class.ilTestSubmissionReviewGUI.php index 1a905d0734bf..e288ad7ffbef 100644 --- a/Modules/Test/classes/class.ilTestSubmissionReviewGUI.php +++ b/Modules/Test/classes/class.ilTestSubmissionReviewGUI.php @@ -33,6 +33,8 @@ public function __construct( ilObjTest $testOBJ, protected ilTestSession $testSession ) { + global $DIC; + $this->ui = $DIC->ui(); parent::__construct($testOBJ); } @@ -93,20 +95,13 @@ protected function buildToolbar($toolbarId): ilToolbarGUI ilTestPlayerCommands::QUESTION_SUMMARY : ilTestPlayerCommands::BACK_FROM_FINISHING ); - $button = ilLinkButton::getInstance(); - $button->setCaption('btn_previous'); - $button->setUrl($backUrl); - $toolbar->addButtonInstance($button); + $toolbar->addComponent($this->ui->factory()->button()->standard('btn_previous', $backUrl)); $this->ctrl->setParameter($this->testOutputGUI, 'reviewed', 1); $nextUrl = $this->ctrl->getLinkTarget($this->testOutputGUI, ilTestPlayerCommands::FINISH_TEST); $this->ctrl->setParameter($this->testOutputGUI, 'reviewed', 0); - $button = ilLinkButton::getInstance(); - $button->setPrimary(true); - $button->setCaption('btn_next'); - $button->setUrl($nextUrl); - $toolbar->addButtonInstance($button); + $toolbar->addComponent($this->ui->factory()->button()->standard('btn_next', $nextUrl)); return $toolbar; } diff --git a/Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php b/Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php index 0b94fb7736e9..eebeadfa43c3 100644 --- a/Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php +++ b/Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php @@ -275,11 +275,7 @@ protected function buildQuestionRemoveButton(array $rowData): string $removeUrl = $this->ctrl->getLinkTarget($this->getParentObject(), $this->getParentCmd()); $this->ctrl->setParameter($this->getParentObject(), 'removeQid', ''); - $button = ilLinkButton::getInstance(); - $button->setCaption('remove_question'); - $button->setUrl($removeUrl); - - return $button->render(); + return $this->ui_renderer->render($this->ui_factory->button()->standard($this->lng->txt('remove_question'), $removeUrl)); } protected function buildQuestionTitleLink(array $rowData): string diff --git a/Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php b/Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php index 0014b2ac0c04..babfca1f3c0b 100644 --- a/Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php +++ b/Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php @@ -65,17 +65,23 @@ public function build(): void if (count($this->getParticipantSelectorOptions())) { $this->addSeparator(); - $sel = new ilSelectInputGUI('', 'active_id'); - $sel->setOptions($this->getParticipantSelectorOptionsWithHintOption()); - $this->addInputItem($sel); - - $link = ilLinkButton::getInstance(); // always returns a new instance - $link->setUrl('#'); - $link->setId('ilTestResultParticipantJumper'); - $link->setCaption($this->lng->txt('tst_res_jump_to_participant_btn'), false); - $this->addButtonInstance($link); - - $this->tpl->addJavaScript('Modules/Test/js/ilTestResultParticipantSelector.js'); + $dropdown = $this->ui->factory()->dropdown() + ->standard($this->getParticipantSelectorOptionsWithHintOption()) + ->withLabel($this->lng->txt('tst_res_jump_to_participant_btn')); + $this->addComponent($dropdown); + /* + $sel = new ilSelectInputGUI('', 'active_id'); + $sel->setOptions($this->getParticipantSelectorOptionsWithHintOption()); + $this->addInputItem($sel); + + $link = ilLinkButton::getInstance(); // always returns a new instance + $link->setUrl('#'); + $link->setId('ilTestResultParticipantJumper'); + $link->setCaption($this->lng->txt('tst_res_jump_to_participant_btn'), false); + $this->addButtonInstance($link); + + $this->tpl->addJavaScript('Modules/Test/js/ilTestResultParticipantSelector.js'); + */ } } diff --git a/Modules/Test/js/ilTestPlayerNavWhileEditModal.js b/Modules/Test/js/ilTestPlayerNavWhileEditModal.js deleted file mode 100644 index 28110e2ab5c8..000000000000 --- a/Modules/Test/js/ilTestPlayerNavWhileEditModal.js +++ /dev/null @@ -1,45 +0,0 @@ -/* fau: testNav - this script is not included anymore and can be deleted. */ -(function($){ - - var show = function(e) - { - e.stopPropagation(); - e.preventDefault(); - - // href of invoked link/button - var nextHref = $(this).attr('href'); - - // next command forwarded to submitSolution - var nextCommand = $(this).attr('data-nextcmd'); - - // possibly the next sequence element for forwarding - var nextSequence = $(this).attr('data-nextseq'); - - $('a#nextCmdLink').attr('href', nextHref); - $('input[name=nextcmd]').val(nextCommand); - if( typeof nextSequence != 'undefined' ) - { - $('input[name=nextseq]').val(nextSequence); - } - - $('#tst_nav_while_edit_modal').modal('show'); - }; - - var hide = function(e) - { - $('a#nextCmdLink').attr('href', ''); - $('input[name=nextcmd]').val(''); - $('input[name=nextseq]').val(''); - - $('#tst_nav_while_edit_modal').modal('hide'); - }; - - $(document).ready( - function() - { - $('.ilTstNavElem').click(show); - $('#tst_cancel_nav_while_edit_button').click(hide); - } - ); - -})(jQuery); diff --git a/Modules/Test/test/ilTestPlayerConfirmationModalTest.php b/Modules/Test/test/ilTestPlayerConfirmationModalTest.php index 81bd6384f0d3..7115f35edacd 100644 --- a/Modules/Test/test/ilTestPlayerConfirmationModalTest.php +++ b/Modules/Test/test/ilTestPlayerConfirmationModalTest.php @@ -71,16 +71,14 @@ public function testConfirmationCheckboxLabel(): void public function testAddButton(): void { $this->addGlobal_lng(); + $this->addGlobal_uiFactory(); + $expected = []; foreach ([51, 291, 15, 681] as $id) { - $button = ilLinkButton::getInstance(); - $button->setId((string) $id); - $expected[] = $button; - } - - foreach ($expected as $button) { + $button = $this->testObj->buildModalButtonInstance((string) $id); $this->testObj->addButton($button); + $expected[] = $button; } $this->assertEquals($expected, $this->testObj->getButtons()); diff --git a/Modules/TestQuestionPool/classes/class.assErrorTextGUI.php b/Modules/TestQuestionPool/classes/class.assErrorTextGUI.php index 334556ada28e..eb1174bdcc1a 100644 --- a/Modules/TestQuestionPool/classes/class.assErrorTextGUI.php +++ b/Modules/TestQuestionPool/classes/class.assErrorTextGUI.php @@ -276,7 +276,7 @@ public function getSolutionOutput( $selections = [ - 'user' => $this->getUsersSolutionFromPreviewOrDatabase($active_id, $pass) + 'user' => $this->getUsersSolutionFromPreviewOrDatabase((int) $active_id, $pass) ]; $selections['best'] = $this->object->getBestSelection(); diff --git a/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php index 20dc49d2d174..1577704755ae 100755 --- a/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php +++ b/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php @@ -847,16 +847,17 @@ protected function getPreviousSolutionConfirmationCheckboxHtml(): string return ''; } - $button = ilLinkButton::getInstance(); - $button->setCaption('use_previous_solution'); - - $button->setUrl(ilUtil::appendUrlParameterString( - $this->ctrl->getLinkTargetByClass($this->getTargetGuiClass(), $this->getQuestionActionCmd()), - $this->buildSelectionParameter($this->object->currentSolution, null) - )); + global $DIC; + $button = $DIC->ui()->factory()->link()->standard( + $this->lng->txt('use_previous_solution'), + ilUtil::appendUrlParameterString( + $this->ctrl->getLinkTargetByClass($this->getTargetGuiClass(), $this->getQuestionActionCmd()), + $this->buildSelectionParameter($this->object->currentSolution, null) + ) + ); $tpl = new ilTemplate('tpl.tst_question_additional_behaviour_checkbox.html', true, true, 'Modules/TestQuestionPool'); - $tpl->setVariable('BUTTON', $button->render()); + $tpl->setVariable('BUTTON', $DIC->ui()->renderer()->render($button)); return $tpl->get(); } diff --git a/Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewToolbarGUI.php b/Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewToolbarGUI.php index 39f6a7971060..4cf0bf132dca 100644 --- a/Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewToolbarGUI.php +++ b/Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewToolbarGUI.php @@ -27,10 +27,13 @@ class ilAssQuestionPreviewToolbarGUI extends ilToolbarGUI private $resetPreviewCmd; private $editQuestionCmd; private $editPageCmd; + private ilCtrlInterface $ilCtrl; public function __construct(ilLanguage $lng) { $this->lng = $lng; + global $DIC; + $this->ilCtrl = $DIC->ctrl(); parent::__construct(); } @@ -39,28 +42,22 @@ public function build(): void { // Edit Question if ($this->getEditQuestionCmd() !== null) { - $button_edit_question = ilLinkButton::getInstance(); - $button_edit_question->setUrl($this->getEditQuestionCmd()); - $button_edit_question->setPrimary(true); - $button_edit_question->setCaption('edit_question'); - $this->addButtonInstance($button_edit_question); + $action = $this->ilCtrl->getLinkTargetByClass(ilAssQuestionPreviewGUI::class, $this->getEditQuestionCmd()); + $button_edit_question = $this->ui->factory()->button()->standard($this->lng->txt('edit_question'), $action); + $this->addComponent($button_edit_question); } // Edit Page if ($this->getEditPageCmd() !== null) { - $button_edit_page = ilLinkButton::getInstance(); - $button_edit_page->setUrl($this->getEditPageCmd()); - $button_edit_page->setCaption('edit_page'); - $this->addButtonInstance($button_edit_page); + $action = $this->ilCtrl->getLinkTargetByClass(ilAssQuestionPreviewGUI::class, $this->getEditPageCmd()); + $button_edit_page = $this->ui->factory()->button()->standard($this->lng->txt('edit_page'), $this->getEditPageCmd()); + $this->addComponent($button_edit_page); } //Reset Preview - $button = \ilSubmitButton::getInstance(); - $button->setCaption("qpl_reset_preview"); - $button->setCommand($this->getResetPreviewCmd()); - $button->setOmitPreventDoubleSubmission(true); - $this->addButtonInstance($button); - //$this->addFormButton($this->lng->txt('qpl_reset_preview'), $this->getResetPreviewCmd(), '', false); + $action = $this->ilCtrl->getLinkTargetByClass(ilAssQuestionPreviewGUI::class, $this->getResetPreviewCmd()); + $button = $this->ui->factory()->button()->standard($this->lng->txt('qpl_reset_preview'), $action); + $this->addComponent($button); } public function setResetPreviewCmd($resetPreviewCmd): void diff --git a/Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php b/Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php index c27e374fb221..54c83e4443b6 100755 --- a/Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php +++ b/Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php @@ -46,6 +46,7 @@ */ class ilObjQuestionPoolGUI extends ilObjectGUI implements ilCtrlBaseClassInterface { + protected \ILIAS\DI\UIServices $ui; private \ILIAS\TestQuestionPool\QuestionInfoService $questioninfo; public ?ilObject $object; protected ILIAS\TestQuestionPool\InternalRequestService $qplrequest; @@ -70,6 +71,7 @@ public function __construct() $this->component_factory = $DIC['component.factory']; $this->component_repository = $DIC['component.repository']; $this->navigation_history = $DIC['ilNavigationHistory']; + $this->ui = $DIC->ui(); $this->questioninfo = $DIC->testQuestionPool()->questionInfo(); $this->qplrequest = $DIC->testQuestionPool()->internal()->request(); parent::__construct('', $this->qplrequest->raw('ref_id'), true, false); @@ -1065,11 +1067,8 @@ public function questionsObject(): void ilSession::set('test_id', ''); $qsa_import_fails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId()); if ($qsa_import_fails->failedImportsRegistered()) { - $button = ilLinkButton::getInstance(); - $button->setUrl($this->ctrl->getLinkTarget($this, 'renoveImportFails')); - $button->setCaption('ass_skl_import_fails_remove_btn'); - - $this->tpl->setOnScreenMessage('failure', $qsa_import_fails->getFailedImportsMessage($this->lng) . '
' . $button->render()); + $button = $this->ui->factory()->button()->standard($this->lng->txt('ass_skl_import_fails_remove_btn'), $this->ctrl->getLinkTarget($this, 'renoveImportFails')); + $this->tpl->setOnScreenMessage('failure', $qsa_import_fails->getFailedImportsMessage($this->lng) . '
' . $this->ui->renderer()->render($button)); } $tax_ids = ilObjTaxonomy::getUsageOfObject($this->object->getId()); @@ -1078,23 +1077,24 @@ public function questionsObject(): void if ($this->rbac_system->checkAccess('write', $this->qplrequest->getRefId())) { $toolbar = new ilToolbarGUI(); - $btn = ilLinkButton::getInstance(); - $btn->setCaption('ass_create_question'); - $btn->setUrl($this->ctrl->getLinkTarget($this, 'createQuestionForm')); - $btn->setPrimary(true); - $toolbar->addButtonInstance($btn); - + $btn = $this->ui->factory()->button()->primary( + $this->lng->txt('ass_create_question'), + $this->ctrl->getLinkTarget($this, 'createQuestionForm') + ); + $toolbar->addComponent($btn); - $btn_import = ilLinkButton::getInstance(); - $btn_import->setCaption('import'); - $btn_import->setUrl($this->ctrl->getLinkTarget($this, 'importQuestions')); - $toolbar->addButtonInstance($btn_import); + $btn_import = $this->ui->factory()->button()->standard( + $this->lng->txt('import'), + $this->ctrl->getLinkTarget($this, 'importQuestions') + ); + $toolbar->addComponent($btn_import); if (ilSession::get('qpl_clipboard') != null && count(ilSession::get('qpl_clipboard'))) { - $btn_paste = ilLinkButton::getInstance(); - $btn_paste->setCaption('paste'); - $btn_paste->setUrl($this->ctrl->getLinkTarget($this, 'paste')); - $toolbar->addButtonInstance($btn_paste); + $btn_paste = $this->ui->factory()->button()->standard( + $this->lng->txt('paste'), + $this->ctrl->getLinkTarget($this, 'paste') + ); + $toolbar->addComponent($btn_paste); } $this->tpl->setContent( diff --git a/Modules/TestQuestionPool/classes/forms/class.ilAssLongmenuCorrectionsInputGUI.php b/Modules/TestQuestionPool/classes/forms/class.ilAssLongmenuCorrectionsInputGUI.php index 706b252784ce..cf842cce907f 100644 --- a/Modules/TestQuestionPool/classes/forms/class.ilAssLongmenuCorrectionsInputGUI.php +++ b/Modules/TestQuestionPool/classes/forms/class.ilAssLongmenuCorrectionsInputGUI.php @@ -26,6 +26,16 @@ */ class ilAssLongmenuCorrectionsInputGUI extends ilAnswerWizardInputGUI { + private \ILIAS\DI\UIServices $ui; + + public function __construct($a_title = "", $a_postvar = "") + { + global $DIC; + $this->ui = $DIC->ui(); + + parent::__construct($a_title, $a_postvar); + } + public function checkInput(): bool { return true; @@ -33,16 +43,25 @@ public function checkInput(): bool public function insert(ilTemplate $a_tpl): void { - $tpl = new ilTemplate('tst.longmenu_corrections_input.html', true, true, 'Modules/TestQuestionPool'); + // Get input + $inp = new ilTextWizardInputGUI('', ''); + $inp->setValues(current($this->values['answers_all'])); + $inp->setDisabled(true); + $message = $inp->render(); - $tpl->setVariable('ANSWERS_MODAL', $this->buildAnswersModal()->getHTML()); + $page = $this->ui->factory()->modal()->lightboxTextPage($message, $this->lng->txt('answer_options')); - $tpl->setVariable('TAG_INPUT', $this->buildTagInput()->render()); + $modal = $this->ui->factory()->modal()->lightbox($page); - $tpl->setVariable('NUM_ANSWERS', $this->values['answers_all_count']); + $button = $this->ui->factory()->button()->standard($this->lng->txt('show'), $modal->getShowSignal()); + + $tpl = new ilTemplate('tst.longmenu_corrections_input.html', true, true, 'Modules/TestQuestionPool'); + $tpl->setVariable('ANSWERS_MODAL', $this->ui->renderer()->render($modal)); + $tpl->setVariable('TAG_INPUT', $this->buildTagInput()->render()); + $tpl->setVariable('NUM_ANSWERS', $this->values['answers_all_count']); + $tpl->setVariable('BTN_SHOW', $this->ui->renderer()->render($button)); $tpl->setVariable('TXT_ANSWERS', $this->lng->txt('answer_options')); - $tpl->setVariable('TXT_SHOW', $this->lng->txt('show')); $tpl->setVariable('TXT_CORRECT_ANSWERS', $this->lng->txt('correct_answers')); $tpl->setVariable('POSTVAR', $this->getPostVar()); @@ -52,27 +71,6 @@ public function insert(ilTemplate $a_tpl): void $a_tpl->parseCurrentBlock(); } - protected function buildAnswersModal(): ilModalGUI - { - $closeButton = ilJsLinkButton::getInstance(); - $closeButton->setCaption('close'); - $closeButton->setTarget(''); - $closeButton->setOnClick("$('#modal_{$this->getPostVar()}').modal('hide');"); - - $modal = ilModalGUI::getInstance(); - $modal->setId('modal_' . $this->getPostVar()); - $modal->setHeading($this->lng->txt('answer_options')); - $modal->addButton($closeButton); - - $inp = new ilTextWizardInputGUI('', ''); - $inp->setValues(current($this->values['answers_all'])); - $inp->setDisabled(true); - - $modal->setBody($inp->render()); - - return $modal; - } - protected function buildTagInput(): ilTagInputGUI { $tagInput = new ilTagInputGUI('', $this->getPostVar() . '_tags'); diff --git a/Modules/TestQuestionPool/templates/default/tst.longmenu_corrections_input.html b/Modules/TestQuestionPool/templates/default/tst.longmenu_corrections_input.html index 7cdb7d74bb0f..fe2de16d48eb 100644 --- a/Modules/TestQuestionPool/templates/default/tst.longmenu_corrections_input.html +++ b/Modules/TestQuestionPool/templates/default/tst.longmenu_corrections_input.html @@ -1,23 +1,6 @@
-

{TXT_ANSWERS}: {NUM_ANSWERS} [{TXT_SHOW}]

+

{TXT_ANSWERS} {NUM_ANSWERS} {BTN_SHOW}

{TXT_CORRECT_ANSWERS}

{TAG_INPUT} {ANSWERS_MODAL} -
-- \ No newline at end of file + \ No newline at end of file