Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 use mod_quiz\local\access_rule_base; 18 use mod_quiz\quiz_settings; 19 20 /** 21 * A rule for ensuring that the quiz is opened in a popup, with some JavaScript 22 * to prevent copying and pasting, etc. 23 * 24 * @package quizaccess_securewindow 25 * @copyright 2009 Tim Hunt 26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 27 */ 28 class quizaccess_securewindow extends access_rule_base { 29 /** @var array options that should be used for opening the secure popup. */ 30 protected static $popupoptions = [ 31 'left' => 0, 32 'top' => 0, 33 'fullscreen' => true, 34 'scrollbars' => true, 35 'resizeable' => false, 36 'directories' => false, 37 'toolbar' => false, 38 'titlebar' => false, 39 'location' => false, 40 'status' => false, 41 'menubar' => false, 42 ]; 43 44 public static function make(quiz_settings $quizobj, $timenow, $canignoretimelimits) { 45 46 if ($quizobj->get_quiz()->browsersecurity !== 'securewindow') { 47 return null; 48 } 49 50 return new self($quizobj, $timenow); 51 } 52 53 public function attempt_must_be_in_popup() { 54 return !$this->quizobj->is_preview_user(); 55 } 56 57 public function get_popup_options() { 58 return self::$popupoptions; 59 } 60 61 public function setup_attempt_page($page) { 62 $page->set_popup_notification_allowed(false); // Prevent message notifications. 63 $page->set_title($this->quizobj->get_course()->shortname . ': ' . $page->title); 64 $page->set_pagelayout('secure'); 65 66 if ($this->quizobj->is_preview_user()) { 67 return; 68 } 69 70 $page->add_body_class('quiz-secure-window'); 71 $page->requires->js_init_call('M.mod_quiz.secure_window.init', 72 null, false, quiz_get_js_module()); 73 } 74 75 /** 76 * @return array key => lang string any choices to add to the quiz Browser 77 * security settings menu. 78 */ 79 public static function get_browser_security_choices() { 80 return ['securewindow' => 81 get_string('popupwithjavascriptsupport', 'quizaccess_securewindow')]; 82 } 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body