From 24c36654301fdc48f4d3c36904c0e7af148fdd81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Sat, 21 Oct 2023 20:26:52 +0200 Subject: [PATCH] Preview window add "Close preview" button fix #469. --- preview.php | 6 ++++++ tests/behat/preview_question.feature | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/preview.php b/preview.php index 2d1fb37f..9127ddf2 100644 --- a/preview.php +++ b/preview.php @@ -158,6 +158,12 @@ echo $quba->render_question($slot, $options, 'i'); + $returnurl = new moodle_url('/mod/studentquiz/view.php', ['id' => $cmid]); + echo html_writer::start_div('controls input-group', ['id' => 'previewcontrols']); + echo html_writer::link($returnurl, get_string('closepreview', 'question'), + ['class' => 'btn btn-secondary mr-1 mb-1', 'role' => 'button']); + echo html_writer::end_div(); + $PAGE->requires->js_module('core_question_engine'); $PAGE->requires->strings_for_js(array( 'closepreview', diff --git a/tests/behat/preview_question.feature b/tests/behat/preview_question.feature index 054f820f..97e5cabd 100644 --- a/tests/behat/preview_question.feature +++ b/tests/behat/preview_question.feature @@ -113,3 +113,22 @@ Feature: Preview a question as a student And I should see "Change state from Approved to:" And I set the field "statetype" to "Approved" And the "Change state" "button" should be disabled + + @javascript @_switch_window + Scenario: Preview question close window. + When I am on the "StudentQuiz 1" "mod_studentquiz > View" page logged in as "admin" + And I click on "Create new question" "button" + And I set the field "item_qtype_truefalse" to "1" + And I click on "Add" "button" in the "Choose a question type to add" "dialogue" + Then I should see "Adding a True/False question" + And I set the field "Question name" to "TF 01" + And I set the field "Question text" to "The correct answer is true" + And I press "id_submitbutton" + + And I log out + And I am on the "StudentQuiz 1" "mod_studentquiz > View" page logged in as "admin" + And I choose "Preview" action for "TF 01" in the question bank + And I switch to "questionpreview" window + And I should see "Close preview" + And I click on "Close preview" "button" + Then I should see "Create new question"