Skip to content

Commit 952d6c6

Browse files
committed
Preview window add "Close preview" button fix #469.
1 parent afa3345 commit 952d6c6

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

preview.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@
145145

146146
echo $quba->render_question($slot, $options, 'i');
147147

148+
$returnurl = new moodle_url('/mod/studentquiz/view.php', ['id' => $cmid]);
149+
echo html_writer::start_div('controls input-group', ['id' => 'previewcontrols']);
150+
echo html_writer::link($returnurl, get_string('closepreview', 'question'),
151+
['class' => 'btn btn-secondary mr-1 mb-1', 'role' => 'button']);
152+
echo html_writer::end_div();
153+
148154
$PAGE->requires->js_module('core_question_engine');
149155
$PAGE->requires->strings_for_js(array(
150156
'closepreview',

tests/behat/comment_area_create.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,8 @@ Feature: Create comment as an user
589589
And I switch to "questionpreview" window
590590
And I set the field "statetype" to "Approved"
591591
And I click on "Change state" "button"
592-
And I press "Close"
592+
And I click on "OK" "button" in the ".modal-dialog" "css_element"
593+
And I press "Close preview"
593594
And I am on the "StudentQuiz 3" "mod_studentquiz > View" page logged in as "student1"
594595
And I choose "Preview" action for "Question of Student 1" in the question bank
595596
And I switch to "questionpreview" window

tests/behat/preview_question.feature

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,22 @@ Feature: Preview a question as a student
113113
And I should see "Change state from Approved to:"
114114
And I set the field "statetype" to "Approved"
115115
And the "Change state" "button" should be disabled
116+
117+
@javascript @_switch_window
118+
Scenario: Preview question close window.
119+
When I am on the "StudentQuiz 1" "mod_studentquiz > View" page logged in as "admin"
120+
And I click on "Create new question" "button"
121+
And I set the field "item_qtype_truefalse" to "1"
122+
And I click on "Add" "button" in the "Choose a question type to add" "dialogue"
123+
Then I should see "Adding a True/False question"
124+
And I set the field "Question name" to "TF 01"
125+
And I set the field "Question text" to "The correct answer is true"
126+
And I press "id_submitbutton"
127+
128+
And I log out
129+
And I am on the "StudentQuiz 1" "mod_studentquiz > View" page logged in as "admin"
130+
And I choose "Preview" action for "TF 01" in the question bank
131+
And I switch to "questionpreview" window
132+
And I should see "Close preview"
133+
And I click on "Close preview" "button"
134+
Then I should see "Create new question"

0 commit comments

Comments
 (0)