Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/quiz/accessrule/safebrowser/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 
00038 class quizaccess_safebrowser extends quiz_access_rule_base {
00039 
00040     public static function make(quiz $quizobj, $timenow, $canignoretimelimits) {
00041 
00042         if ($quizobj->get_quiz()->browsersecurity !== 'safebrowser') {
00043             return null;
00044         }
00045 
00046         return new self($quizobj, $timenow);
00047     }
00048 
00049     public function prevent_access() {
00050         if (!$this->check_safe_browser()) {
00051             return get_string('safebrowsererror', 'quizaccess_safebrowser');
00052         } else {
00053             return false;
00054         }
00055     }
00056 
00057     public function description() {
00058         return get_string('safebrowsernotice', 'quizaccess_safebrowser');
00059     }
00060 
00061     public function setup_attempt_page($page) {
00062         $page->set_title($this->quizobj->get_course()->shortname . ': ' . $page->title);
00063         $page->set_cacheable(false);
00064     }
00065 
00071     public function check_safe_browser() {
00072         return strpos($_SERVER['HTTP_USER_AGENT'], 'SEB') !== false;
00073     }
00074 
00079     public static function get_browser_security_choices() {
00080         global $CFG;
00081 
00082         if (empty($CFG->enablesafebrowserintegration)) {
00083             return array();
00084         }
00085 
00086         return array('safebrowser' =>
00087                 get_string('requiresafeexambrowser', 'quizaccess_safebrowser'));
00088     }
00089 }
 All Data Structures Namespaces Files Functions Variables Enumerations