Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]
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 enforcing open and close dates. 22 * 23 * @package quizaccess_openclosedate 24 * @copyright 2009 Tim Hunt 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 class quizaccess_openclosedate extends access_rule_base { 28 29 public static function make(quiz_settings $quizobj, $timenow, $canignoretimelimits) { 30 // This rule is always used, even if the quiz has no open or close date. 31 return new self($quizobj, $timenow); 32 } 33 34 public function prevent_access() { 35 $message = get_string('notavailable', 'quizaccess_openclosedate'); 36 37 if ($this->timenow < $this->quiz->timeopen) { 38 return $message; 39 } 40 41 if (!$this->quiz->timeclose) { 42 return false; 43 } 44 45 if ($this->timenow <= $this->quiz->timeclose) { 46 return false; 47 } 48 49 if ($this->quiz->overduehandling != 'graceperiod') { 50 return $message; 51 } 52 53 if ($this->timenow <= $this->quiz->timeclose + $this->quiz->graceperiod) { 54 return false; 55 } 56 57 return $message; 58 } 59 60 public function is_finished($numprevattempts, $lastattempt) { 61 return $this->quiz->timeclose && $this->timenow > $this->quiz->timeclose; 62 } 63 64 public function end_time($attempt) { 65 if ($this->quiz->timeclose) { 66 return $this->quiz->timeclose; 67 } 68 return false; 69 } 70 71 public function time_left_display($attempt, $timenow) { 72 // If this is a teacher preview after the close date, do not show 73 // the time. 74 if ($attempt->preview && $timenow > $this->quiz->timeclose) { 75 return false; 76 } 77 // Otherwise, return to the time left until the close date, providing that is 78 // less than QUIZ_SHOW_TIME_BEFORE_DEADLINE. 79 $endtime = $this->end_time($attempt); 80 if ($endtime !== false && $timenow > $endtime - QUIZ_SHOW_TIME_BEFORE_DEADLINE) { 81 return $endtime - $timenow; 82 } 83 return false; 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body