MDL-45273 quiz: move admin settings into classes folder.

This commit is contained in:
Tim Hunt
2014-04-29 11:57:27 +01:00
parent eabcd76d4d
commit f57d7f3f95
5 changed files with 176 additions and 88 deletions
@@ -15,8 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This page is the entry page into the quiz UI. Displays information about the
* quiz to students and teachers, and lets students see their previous attempts.
* Admin settings class for the quiz review opitions.
*
* @package mod
* @subpackage quiz
@@ -39,10 +38,10 @@ class mod_quiz_admin_review_setting extends admin_setting {
* @var integer should match the constants defined in {@link mod_quiz_display_options}.
* again, copied for performance reasons.
*/
const DURING = 0x10000;
const DURING = 0x10000;
const IMMEDIATELY_AFTER = 0x01000;
const LATER_WHILE_OPEN = 0x00100;
const AFTER_CLOSE = 0x00010;
const LATER_WHILE_OPEN = 0x00100;
const AFTER_CLOSE = 0x00010;
/**#@-*/
/**
@@ -57,16 +56,26 @@ class mod_quiz_admin_review_setting extends admin_setting {
*/
public static function fields() {
return array(
'attempt' => get_string('theattempt', 'quiz'),
'correctness' => get_string('whethercorrect', 'question'),
'marks' => get_string('marks', 'question'),
'attempt' => get_string('theattempt', 'quiz'),
'correctness' => get_string('whethercorrect', 'question'),
'marks' => get_string('marks', 'question'),
'specificfeedback' => get_string('specificfeedback', 'question'),
'generalfeedback' => get_string('generalfeedback', 'question'),
'rightanswer' => get_string('rightanswer', 'question'),
'overallfeedback' => get_string('overallfeedback', 'quiz'),
'generalfeedback' => get_string('generalfeedback', 'question'),
'rightanswer' => get_string('rightanswer', 'question'),
'overallfeedback' => get_string('overallfeedback', 'quiz'),
);
}
/**
* Constructor.
*
* @param string $name unique ascii name, either 'mysetting' for settings that in config,
* or 'myplugin/mysetting' for ones in config_plugins.
* @param string $visiblename localised name
* @param string $description localised long description
* @param mixed $defaultsetting string or array depending on implementation
* @param bool|null $duringstate
*/
public function __construct($name, $visiblename, $description,
$defaultsetting, $duringstate = null) {
$this->duringstate = $duringstate;
@@ -81,12 +90,15 @@ class mod_quiz_admin_review_setting extends admin_setting {
self::AFTER_CLOSE;
}
/**
* @return array name of all the possible times.
*/
protected static function times() {
return array(
self::DURING => get_string('reviewduring', 'quiz'),
self::DURING => get_string('reviewduring', 'quiz'),
self::IMMEDIATELY_AFTER => get_string('reviewimmediately', 'quiz'),
self::LATER_WHILE_OPEN => get_string('reviewopen', 'quiz'),
self::AFTER_CLOSE => get_string('reviewclosed', 'quiz'),
self::LATER_WHILE_OPEN => get_string('reviewopen', 'quiz'),
self::AFTER_CLOSE => get_string('reviewclosed', 'quiz'),
);
}
@@ -147,75 +159,3 @@ class mod_quiz_admin_review_setting extends admin_setting {
$this->description, true, '', get_string('everythingon', 'quiz'), $query);
}
}
/**
* Admin settings class for the quiz grading method.
*
* Just so we can lazy-load the choices.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_admin_setting_grademethod extends admin_setting_configselect_with_advanced {
public function load_choices() {
global $CFG;
if (is_array($this->choices)) {
return true;
}
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
$this->choices = quiz_get_grading_options();
return true;
}
}
/**
* Admin settings class for the quiz browser security option.
*
* Just so we can lazy-load the choices.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_admin_setting_browsersecurity extends admin_setting_configselect_with_advanced {
public function load_choices() {
global $CFG;
if (is_array($this->choices)) {
return true;
}
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
$this->choices = quiz_access_manager::get_browser_security_choices();
return true;
}
}
/**
* Admin settings class for the quiz overdue attempt handling method.
*
* Just so we can lazy-load the choices.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_admin_setting_overduehandling extends admin_setting_configselect_with_advanced {
public function load_choices() {
global $CFG;
if (is_array($this->choices)) {
return true;
}
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
$this->choices = quiz_get_overdue_handling_options();
return true;
}
}
@@ -0,0 +1,50 @@
<?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/>.
/**
* Admin settings class for the quiz browser security option.
*
* @package mod_quiz
* @copyright 2008 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Admin settings class for the quiz browser security option.
*
* Just so we can lazy-load the choices.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_admin_setting_browsersecurity extends admin_setting_configselect_with_advanced {
public function load_choices() {
global $CFG;
if (is_array($this->choices)) {
return true;
}
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
$this->choices = quiz_access_manager::get_browser_security_choices();
return true;
}
}
@@ -0,0 +1,50 @@
<?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/>.
/**
* Admin settings class for the quiz grading method.
*
* @package mod_quiz
* @copyright 2008 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Admin settings class for the quiz grading method.
*
* Just so we can lazy-load the choices.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_admin_setting_grademethod extends admin_setting_configselect_with_advanced {
public function load_choices() {
global $CFG;
if (is_array($this->choices)) {
return true;
}
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
$this->choices = quiz_get_grading_options();
return true;
}
}
@@ -0,0 +1,50 @@
<?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/>.
/**
* Admin settings class for the quiz overdue attempt handling method.
*
* @package mod_quiz
* @copyright 2008 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Admin settings class for the quiz overdue attempt handling method.
*
* Just so we can lazy-load the choices.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_admin_setting_overduehandling extends admin_setting_configselect_with_advanced {
public function load_choices() {
global $CFG;
if (is_array($this->choices)) {
return true;
}
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
$this->choices = quiz_get_overdue_handling_options();
return true;
}
}
-2
View File
@@ -26,8 +26,6 @@
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/mod/quiz/lib.php');
require_once($CFG->dirroot . '/mod/quiz/settingslib.php');
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
// First get a list of quiz reports with there own settings pages. If there none,