first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for quizaccess_timelimit.
*
* @package quizaccess_timelimit
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace quizaccess_timelimit\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for quizaccess_timelimit implementing null_provider.
*
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
@@ -0,0 +1,34 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for the quizaccess_timelimit plugin.
*
* @package quizaccess
* @subpackage timelimit
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$string['confirmstartheader'] = 'Time limit';
$string['confirmstart'] = 'Your attempt will have a time limit of {$a}. When you start, the timer will begin to count down and cannot be paused. You must finish your attempt before it expires. Are you sure you wish to start now?';
$string['pluginname'] = 'Time limit quiz access rule';
$string['privacy:metadata'] = 'The Time limit quiz access rule plugin does not store any personal data.';
$string['quiztimelimit'] = 'Time limit: {$a}';
+76
View File
@@ -0,0 +1,76 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
use mod_quiz\form\preflight_check_form;
use mod_quiz\local\access_rule_base;
use mod_quiz\quiz_settings;
/**
* A rule representing the time limit.
*
* It does not actually restrict access, but we use this
* class to encapsulate some of the relevant code.
*
* @package quizaccess_timelimit
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class quizaccess_timelimit extends access_rule_base {
public static function make(quiz_settings $quizobj, $timenow, $canignoretimelimits) {
if (empty($quizobj->get_quiz()->timelimit) || $canignoretimelimits) {
return null;
}
return new self($quizobj, $timenow);
}
public function description() {
return get_string('quiztimelimit', 'quizaccess_timelimit',
format_time($this->quiz->timelimit));
}
public function end_time($attempt) {
$timedue = $attempt->timestart + $this->quiz->timelimit;
if ($this->quiz->timeclose) {
$timedue = min($timedue, $this->quiz->timeclose);
}
return $timedue;
}
public function time_left_display($attempt, $timenow) {
// If this is a teacher preview after the time limit expires, don't show the time_left
$endtime = $this->end_time($attempt);
if ($attempt->preview && $timenow > $endtime) {
return false;
}
return $endtime - $timenow;
}
public function is_preflight_check_required($attemptid) {
// Warning only required if the attempt is not already started.
return $attemptid === null;
}
public function add_preflight_check_form_fields(preflight_check_form $quizform,
MoodleQuickForm $mform, $attemptid) {
$mform->addElement('header', 'honestycheckheader',
get_string('confirmstartheader', 'quizaccess_timelimit'));
$mform->addElement('static', 'honestycheckmessage', '',
get_string('confirmstart', 'quizaccess_timelimit', format_time($this->quiz->timelimit)));
}
}
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace quizaccess_timelimit;
use mod_quiz\quiz_settings;
use quizaccess_timelimit;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/accessrule/timelimit/rule.php');
/**
* Unit tests for the quizaccess_timelimit plugin.
*
* @package quizaccess_timelimit
* @copyright 2008 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class rule_test extends \basic_testcase {
public function test_time_limit_access_rule(): void {
$quiz = new \stdClass();
$quiz->timeclose = 0;
$quiz->timelimit = 3600;
$cm = new \stdClass();
$cm->id = 0;
$quizobj = new quiz_settings($quiz, $cm, null);
$rule = new quizaccess_timelimit($quizobj, 10000);
$attempt = new \stdClass();
$this->assertEquals($rule->description(),
get_string('quiztimelimit', 'quizaccess_timelimit', format_time(3600)));
$attempt->timestart = 10000;
$attempt->preview = 0;
$this->assertEquals(13600, $rule->end_time($attempt));
$this->assertEquals(3600, $rule->time_left_display($attempt, 10000));
$this->assertEquals(1600, $rule->time_left_display($attempt, 12000));
$this->assertEquals(-400, $rule->time_left_display($attempt, 14000));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
}
/**
* Data provider for test_time_limit_access_rule_with_time_close.
*
* @return array of ($timetoclose, $timelimit, $displaylimit, $actuallimit)
*/
public function time_limit_access_rule_with_time_close_provider() {
return [
'Close time is earlier than time limit' => [1800, 3600, 3600, 1800],
'Close time is on time limit' => [3600, 3600, 3600, 3600],
'Close time is later than time limit' => [3600, 1800, 1800, 1800]
];
}
/**
* Test the time_left_display method of the quizaccess_timelimit class.
*
* @param int $timetoclose The number of seconds that is left to the quiz' closing time
* @param int $timelimit Time limit of the quiz
* @param int $displaylimit The limit that is displayed on the quiz page
* @param int $actuallimit The actual limit that is being applied
* @dataProvider time_limit_access_rule_with_time_close_provider
*/
public function test_time_limit_access_rule_with_time_close($timetoclose, $timelimit, $displaylimit, $actuallimit): void {
$timenow = 10000;
$quiz = new \stdClass();
$quiz->timeclose = $timenow + $timetoclose;
$quiz->timelimit = $timelimit;
$cm = new \stdClass();
$cm->id = 0;
$quizobj = new quiz_settings($quiz, $cm, null);
$rule = new quizaccess_timelimit($quizobj, $timenow);
$attempt = new \stdClass();
$this->assertEquals($rule->description(),
get_string('quiztimelimit', 'quizaccess_timelimit', format_time($displaylimit)));
$attempt->timestart = $timenow;
$attempt->preview = 0;
$this->assertEquals($timenow + $actuallimit, $rule->end_time($attempt));
$this->assertEquals($actuallimit, $rule->time_left_display($attempt, $timenow));
$this->assertEquals($actuallimit - 1000, $rule->time_left_display($attempt, $timenow + 1000));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version information for the quizaccess_delaybetweenattempts plugin.
*
* @package quizaccess
* @subpackage timelimit
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2024042200;
$plugin->requires = 2024041600;
$plugin->component = 'quizaccess_timelimit';