diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php index b944c8691ee..fddedc049ab 100644 --- a/mod/quiz/accessrules.php +++ b/mod/quiz/accessrules.php @@ -160,7 +160,7 @@ class quiz_access_manager { * @param string $title HTML title tag content, passed to printheader. * @param string $headtags extra stuff to go in the HTML head tag, passed to printheader. */ - public function setup_secure_page($title, $headtags) { + public function setup_secure_page($title, $headtags = null) { $this->_securewindowrule->setup_secure_page($title, $headtags); } @@ -243,9 +243,10 @@ class quiz_access_manager { * @param boolean $canpreview This affects whether we have to worry about secure window stuff. */ public function back_to_view_page($canpreview, $message = '') { - global $CFG, $OUTPUT; + global $CFG, $OUTPUT, $PAGE; $url = $this->_quizobj->view_url(); if ($this->securewindow_required($canpreview)) { + $PAGE->set_pagelayout('popup'); echo $OUTPUT->header(); echo $OUTPUT->box_start(); if ($message) { @@ -255,8 +256,8 @@ class quiz_access_manager { echo '
' . get_string('pleaseclose', 'quiz') . '
'; $delay = 0; } - echo $OUTPUT->box_end(); $PAGE->requires->js_function_call('M.mod_quiz.secure_window.close', array($url, $delay)); + echo $OUTPUT->box_end(); echo $OUTPUT->footer(); die(); } else { @@ -668,7 +669,18 @@ class password_access_rule extends quiz_access_rule_base { $output = ''; /// Start the page and print the quiz intro, if any. - echo $OUTPUT->header(); + if ($accessmanager->securewindow_required($canpreview)) { + $accessmanager->setup_secure_page($this->_quizobj->get_course()->shortname . ': ' . + format_string($this->_quizobj->get_quiz_name())); + } else if ($accessmanager->safebrowser_required($canpreview)) { + $PAGE->set_title($this->_quizobj->get_course()->shortname . ': '.format_string($this->_quizobj->get_quiz_name())); + $PAGE->set_cacheable(false); + echo $OUTPUT->header(); + } else { + $PAGE->set_title(format_string($this->_quizobj->get_quiz_name())); + echo $OUTPUT->header(); + } + if (trim(strip_tags($this->_quiz->intro))) { $output .= $OUTPUT->box(format_module_intro('quiz', $this->_quiz, $this->_quizobj->get_cmid()), 'generalbox', 'intro'); } @@ -767,6 +779,7 @@ class securewindow_access_rule extends quiz_access_rule_base { define('MESSAGE_WINDOW', true); $PAGE->set_title($title); $PAGE->set_cacheable(false); + $PAGE->set_pagelayout('popup'); $PAGE->add_body_class('quiz-secure-window'); $PAGE->requires->js_init_call('M.mod_quiz.secure_window.init', null, false, quiz_get_js_module()); diff --git a/mod/quiz/module.js b/mod/quiz/module.js index 5347d8a165b..d75896bb10d 100644 --- a/mod/quiz/module.js +++ b/mod/quiz/module.js @@ -205,9 +205,11 @@ M.mod_quiz.secure_window = { }, prevent_mouse: function(e) { - if (e.button != 1 || !/^(INPUT|TEXTAREA|BUTTON|SELECT)$/i.test(e.target.get('tagName'))) { - alert(M.str.quiz.functiondisabledbysecuremode); + if (e.button == 1 && /^(INPUT|TEXTAREA|BUTTON|SELECT|LABEL|A)$/i.test(e.target.get('tagName'))) { + // Left click on a button or similar. No worries. + return; } + alert(M.str.quiz.functiondisabledbysecuremode); e.halt(); },