Skip to content

Commit

Permalink
Preview window add "Close preview" button fix #469.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Aug 16, 2024
1 parent ecd900c commit e049e17
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
19 changes: 19 additions & 0 deletions tests/behat/preview_question.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit e049e17

Please sign in to comment.