Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview window add "Close preview" button resolves #469. #506

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
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
3 changes: 2 additions & 1 deletion tests/behat/comment_area_create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,8 @@ Feature: Create comment as an user
And I switch to "questionpreview" window
And I set the field "statetype" to "Approved"
And I click on "Change state" "button"
And I press "Close"
And I click on "OK" "button" in the ".modal-dialog" "css_element"
And I press "Close preview"
And I am on the "StudentQuiz 3" "mod_studentquiz > View" page logged in as "student1"
And I choose "Preview" action for "Question of Student 1" in the question bank
And I switch to "questionpreview" window
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"
Loading