From d4c979ad1e8f50f0d9a88d6f3fc8418ef8455be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Wed, 8 May 2024 13:21:11 +0200 Subject: [PATCH] MDL-81827 quizaccess: Open Download Safe Exam Browser in new tab. --- mod/quiz/accessrule/seb/rule.php | 7 +++- .../seb/tests/behat/attempt_quiz.feature | 36 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 mod/quiz/accessrule/seb/tests/behat/attempt_quiz.feature diff --git a/mod/quiz/accessrule/seb/rule.php b/mod/quiz/accessrule/seb/rule.php index b419f703b23..a61d282ea26 100644 --- a/mod/quiz/accessrule/seb/rule.php +++ b/mod/quiz/accessrule/seb/rule.php @@ -534,7 +534,12 @@ class quizaccess_seb extends access_rule_base { $button = ''; if (!empty($this->get_seb_download_url())) { - $button = $OUTPUT->single_button($this->get_seb_download_url(), get_string('sebdownloadbutton', 'quizaccess_seb')); + $sebdownloadlink = $this->get_seb_download_url(); + $button = html_writer::start_tag('div', ['class' => 'singlebutton']); + $button .= html_writer::link($sebdownloadlink, get_string('sebdownloadbutton', 'quizaccess_seb'), + ['class' => 'btn btn-secondary', 'target' => '_blank']); + $button .= html_writer::end_tag('div'); + } return $button; diff --git a/mod/quiz/accessrule/seb/tests/behat/attempt_quiz.feature b/mod/quiz/accessrule/seb/tests/behat/attempt_quiz.feature new file mode 100644 index 00000000000..6854d6d4028 --- /dev/null +++ b/mod/quiz/accessrule/seb/tests/behat/attempt_quiz.feature @@ -0,0 +1,36 @@ +@javascript @mod_quiz @quizaccess @quizaccess_seb +Feature: Quiz start with Safe Exam Browser access rule + + Background: + Given the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + | student1 | Student | 1 | student1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And the following "activities" exist: + | activity | course | section | name | + | quiz | C1 | 1 | Quiz 1 | + And the following "question categories" exist: + | contextlevel | reference | name | + | Course | C1 | Test questions | + And the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | TF1 | First question | + And quiz "Quiz 1" contains the following questions: + | question | page | maxmark | + | TF1 | 1 | | + + Scenario: Start a quiz as student with Safe Exam Browser quiz access rule + When I am on the "Quiz 1" "quiz activity editing" page logged in as teacher1 + And I expand all fieldsets + And I set the following fields to these values: + | seb_requiresafeexambrowser | 1 | + And I press "Save and return to course" + And I am on the "Quiz 1" "mod_quiz > View" page logged in as "student1" + Then the "target" attribute of "a[title='Download Safe Exam Browser']" "css_element" should contain "_blank"