From e66bf8a5c1d46660585dc91e56589469a2fcaa1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Wed, 5 May 2021 00:18:22 +0200 Subject: [PATCH] MDL-71187 quizaccess_seb: Change "Launch Safe Exam Browser" to a href. In order to allow for correct seb:// or sebs:// calls without browser warnings of insecure links, it is not possible to send a get request with an attached cmid parameter to the unknown seb:// or sebs:// URL via a form button. We've got to use a link outside a form to circumvent browsers warning of an insecure link and call Safe Exam Browser correctly. --- mod/quiz/accessrule/seb/rule.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mod/quiz/accessrule/seb/rule.php b/mod/quiz/accessrule/seb/rule.php index 54a7c2f2e00..9b5ed7a329c 100644 --- a/mod/quiz/accessrule/seb/rule.php +++ b/mod/quiz/accessrule/seb/rule.php @@ -530,11 +530,15 @@ class quizaccess_seb extends quiz_access_rule_base { * @return string A link to launch Safe Exam Browser. */ private function get_launch_seb_button() : string { - global $OUTPUT; - + // Rendering as a href and not as button in a form to circumvent browser warnings for sending to URL with unknown protocol. $seblink = \quizaccess_seb\link_generator::get_link($this->quiz->cmid, true, is_https()); - return $OUTPUT->single_button($seblink, get_string('seblinkbutton', 'quizaccess_seb'), 'get'); + $buttonlink = html_writer::start_tag('div', array('class' => 'singlebutton')); + $buttonlink .= html_writer::link($seblink, get_string('seblinkbutton', 'quizaccess_seb'), + ['class' => 'btn btn-secondary', 'title' => get_string('seblinkbutton', 'quizaccess_seb')]); + $buttonlink .= html_writer::end_tag('div'); + + return $buttonlink; } /** @@ -543,11 +547,15 @@ class quizaccess_seb extends quiz_access_rule_base { * @return string A link to launch Safe Exam Browser. */ private function get_download_config_button() : string { - global $OUTPUT; - + // Rendering as a href and not as button in a form to circumvent browser warnings for sending to URL with unknown protocol. $httplink = \quizaccess_seb\link_generator::get_link($this->quiz->cmid, false, is_https()); - return $OUTPUT->single_button($httplink, get_string('httplinkbutton', 'quizaccess_seb'), 'get'); + $buttonlink = html_writer::start_tag('div', array('class' => 'singlebutton')); + $buttonlink .= html_writer::link($httplink, get_string('httplinkbutton', 'quizaccess_seb'), + ['class' => 'btn btn-secondary', 'title' => get_string('httplinkbutton', 'quizaccess_seb')]); + $buttonlink .= html_writer::end_tag('div'); + + return $buttonlink; } /**