. use mod_quiz\local\access_rule_base; use mod_quiz\quiz_settings; /** * A rule implementing the ipaddress check against the ->subnet setting. * * @package quizaccess_ipaddress * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class quizaccess_ipaddress extends access_rule_base { public static function make(quiz_settings $quizobj, $timenow, $canignoretimelimits) { if (empty($quizobj->get_quiz()->subnet)) { return null; } return new self($quizobj, $timenow); } public function prevent_access() { if (address_in_subnet(getremoteaddr(), $this->quiz->subnet)) { return false; } else { return get_string('subnetwrong', 'quizaccess_ipaddress'); } } }