Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/quiz/accessrule/securewindow/rule.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029 require_once($CFG->dirroot . '/mod/quiz/accessrule/accessrulebase.php');
00030 
00031 
00039 class quizaccess_securewindow extends quiz_access_rule_base {
00041     protected static $popupoptions = array(
00042         'left' => 0,
00043         'top' => 0,
00044         'fullscreen' => true,
00045         'scrollbars' => true,
00046         'resizeable' => false,
00047         'directories' => false,
00048         'toolbar' => false,
00049         'titlebar' => false,
00050         'location' => false,
00051         'status' => false,
00052         'menubar' => false,
00053     );
00054 
00055     public static function make(quiz $quizobj, $timenow, $canignoretimelimits) {
00056 
00057         if ($quizobj->get_quiz()->browsersecurity !== 'securewindow') {
00058             return null;
00059         }
00060 
00061         return new self($quizobj, $timenow);
00062     }
00063 
00064     public function attempt_must_be_in_popup() {
00065         return !$this->quizobj->is_preview_user();
00066     }
00067 
00068     public function get_popup_options() {
00069         return self::$popupoptions;
00070     }
00071 
00072     public function setup_attempt_page($page) {
00073         $page->set_popup_notification_allowed(false); // Prevent message notifications
00074         $page->set_title($this->quizobj->get_course()->shortname . ': ' . $page->title);
00075         $page->set_cacheable(false);
00076         $page->set_pagelayout('popup');
00077 
00078         if ($this->quizobj->is_preview_user()) {
00079             return;
00080         }
00081 
00082         $page->add_body_class('quiz-secure-window');
00083         $page->requires->js_init_call('M.mod_quiz.secure_window.init',
00084                 null, false, quiz_get_js_module());
00085     }
00086 
00091     public static function get_browser_security_choices() {
00092         return array('securewindow' =>
00093                 get_string('popupwithjavascriptsupport', 'quizaccess_securewindow'));
00094     }
00095 }
 All Data Structures Namespaces Files Functions Variables Enumerations