Merge branch 'MDL-45273' of git://github.com/timhunt/moodle

This commit is contained in:
Marina Glancy
2014-05-01 12:16:48 +08:00
8 changed files with 420 additions and 258 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_quiz
* @copyright 2008 Tim Hunt
@@ -34,15 +33,29 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
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.
/**
* @var integer should match the constants defined in
* {@link mod_quiz_display_options}. Copied for performance reasons.
*/
const DURING = 0x10000;
/**
* @var integer should match the constants defined in
* {@link mod_quiz_display_options}. Copied for performance reasons.
*/
const DURING = 0x10000;
const IMMEDIATELY_AFTER = 0x01000;
const LATER_WHILE_OPEN = 0x00100;
const AFTER_CLOSE = 0x00010;
/**#@-*/
/**
* @var integer should match the constants defined in
* {@link mod_quiz_display_options}. Copied for performance reasons.
*/
const LATER_WHILE_OPEN = 0x00100;
/**
* @var integer should match the constants defined in
* {@link mod_quiz_display_options}. Copied for performance reasons.
*/
const AFTER_CLOSE = 0x00010;
/**
* @var boolean|null forced checked / disabled attributes for the during time.
@@ -56,16 +69,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;
@@ -73,6 +96,7 @@ class mod_quiz_admin_review_setting extends admin_setting {
}
/**
* Return the combination that means all times.
* @return int all times.
*/
public static function all_on() {
@@ -80,12 +104,16 @@ class mod_quiz_admin_review_setting extends admin_setting {
self::AFTER_CLOSE;
}
/**
* Get an array of the names of all the possible times.
* @return array an array of time constant => lang string.
*/
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'),
);
}
@@ -146,75 +174,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;
}
}
@@ -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 choices for how to display the user's image
*
* @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 choices for how to display the user's image.
*
* 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_user_image 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_user_image_options();
return true;
}
}
+15 -2
View File
@@ -1126,8 +1126,21 @@ function quiz_get_overdue_handling_options() {
}
/**
* @param string $state one of the state constants like IN_PROGRESS.
* @return string the human-readable state name.
* Get the choices for what size user picture to show.
* @return array string => lang string the options for whether to display the user's picture.
*/
function quiz_get_user_image_options() {
return array(
QUIZ_SHOWIMAGE_NONE => get_string('shownoimage', 'quiz'),
QUIZ_SHOWIMAGE_SMALL => get_string('showsmallimage', 'quiz'),
QUIZ_SHOWIMAGE_LARGE => get_string('showlargeimage', 'quiz'),
);
}
/**
* Get the human-readable name for a quiz attempt state.
* @param string $state one of the state constants like {@link quiz_attempt::IN_PROGRESS}.
* @return string The lang string to describe that state.
*/
function quiz_attempt_state_name($state) {
switch ($state) {
+2 -4
View File
@@ -252,10 +252,8 @@ class mod_quiz_mod_form extends moodleform_mod {
$mform->addElement('header', 'display', get_string('appearance'));
// Show user picture.
$mform->addElement('select', 'showuserpicture', get_string('showuserpicture', 'quiz'), array(
QUIZ_SHOWIMAGE_NONE => get_string('shownoimage', 'quiz'),
QUIZ_SHOWIMAGE_SMALL => get_string('showsmallimage', 'quiz'),
QUIZ_SHOWIMAGE_LARGE => get_string('showlargeimage', 'quiz')));
$mform->addElement('select', 'showuserpicture', get_string('showuserpicture', 'quiz'),
quiz_get_user_image_options());
$mform->addHelpButton('showuserpicture', 'showuserpicture', 'quiz');
$mform->setAdvanced('showuserpicture', $quizconfig->showuserpicture_adv);
$mform->setDefault('showuserpicture', $quizconfig->showuserpicture);
+157 -162
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,
// we use a simpler overall menu structure.
@@ -57,174 +55,171 @@ if (empty($reportsbyname) && empty($rulesbyname)) {
}
$quizsettings = new admin_settingpage('modsettingquiz', $pagetitle, 'moodle/site:config');
// Introductory explanation that all the settings are defaults for the add quiz form.
$quizsettings->add(new admin_setting_heading('quizintro', '', get_string('configintro', 'quiz')));
if ($ADMIN->fulltree) {
// Introductory explanation that all the settings are defaults for the add quiz form.
$quizsettings->add(new admin_setting_heading('quizintro', '', get_string('configintro', 'quiz')));
// Time limit.
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/timelimit',
get_string('timelimitsec', 'quiz'), get_string('configtimelimitsec', 'quiz'),
array('value' => '0', 'adv' => false), PARAM_INT));
// Time limit.
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/timelimit',
get_string('timelimitsec', 'quiz'), get_string('configtimelimitsec', 'quiz'),
array('value' => '0', 'adv' => false), PARAM_INT));
// What to do with overdue attempts.
$quizsettings->add(new mod_quiz_admin_setting_overduehandling('quiz/overduehandling',
get_string('overduehandling', 'quiz'), get_string('overduehandling_desc', 'quiz'),
array('value' => 'autoabandon', 'adv' => false), null));
// What to do with overdue attempts.
$quizsettings->add(new mod_quiz_admin_setting_overduehandling('quiz/overduehandling',
get_string('overduehandling', 'quiz'), get_string('overduehandling_desc', 'quiz'),
array('value' => 'autoabandon', 'adv' => false), null));
// Grace period time.
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/graceperiod',
get_string('graceperiod', 'quiz'), get_string('graceperiod_desc', 'quiz'),
array('value' => '86400', 'adv' => false), PARAM_INT));
// Grace period time.
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/graceperiod',
get_string('graceperiod', 'quiz'), get_string('graceperiod_desc', 'quiz'),
array('value' => '86400', 'adv' => false), PARAM_INT));
// Minimum grace period used behind the scenes.
$quizsettings->add(new admin_setting_configtext('quiz/graceperiodmin',
get_string('graceperiodmin', 'quiz'), get_string('graceperiodmin_desc', 'quiz'),
60, PARAM_INT));
// Minimum grace period used behind the scenes.
$quizsettings->add(new admin_setting_configtext('quiz/graceperiodmin',
get_string('graceperiodmin', 'quiz'), get_string('graceperiodmin_desc', 'quiz'),
60, PARAM_INT));
// Number of attempts.
$options = array(get_string('unlimited'));
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
$options[$i] = $i;
}
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/attempts',
get_string('attemptsallowed', 'quiz'), get_string('configattemptsallowed', 'quiz'),
array('value' => 0, 'adv' => false), $options));
// Grading method.
$quizsettings->add(new mod_quiz_admin_setting_grademethod('quiz/grademethod',
get_string('grademethod', 'quiz'), get_string('configgrademethod', 'quiz'),
array('value' => QUIZ_GRADEHIGHEST, 'adv' => false), null));
// Maximum grade.
$quizsettings->add(new admin_setting_configtext('quiz/maximumgrade',
get_string('maximumgrade'), get_string('configmaximumgrade', 'quiz'), 10, PARAM_INT));
// Shuffle questions.
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shufflequestions',
get_string('shufflequestions', 'quiz'), get_string('configshufflequestions', 'quiz'),
array('value' => 0, 'adv' => false)));
// Questions per page.
$perpage = array();
$perpage[0] = get_string('never');
$perpage[1] = get_string('aftereachquestion', 'quiz');
for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
$perpage[$i] = get_string('afternquestions', 'quiz', $i);
}
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questionsperpage',
get_string('newpageevery', 'quiz'), get_string('confignewpageevery', 'quiz'),
array('value' => 1, 'adv' => false), $perpage));
// Navigation method.
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/navmethod',
get_string('navmethod', 'quiz'), get_string('confignavmethod', 'quiz'),
array('value' => QUIZ_NAVMETHOD_FREE, 'adv' => true), quiz_get_navigation_options()));
// Shuffle within questions.
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shuffleanswers',
get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'),
array('value' => 1, 'adv' => false)));
// Preferred behaviour.
$quizsettings->add(new admin_setting_question_behaviour('quiz/preferredbehaviour',
get_string('howquestionsbehave', 'question'), get_string('howquestionsbehave_desc', 'quiz'),
'deferredfeedback'));
// Each attempt builds on last.
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/attemptonlast',
get_string('eachattemptbuildsonthelast', 'quiz'),
get_string('configeachattemptbuildsonthelast', 'quiz'),
array('value' => 0, 'adv' => true)));
// Review options.
$quizsettings->add(new admin_setting_heading('reviewheading',
get_string('reviewoptionsheading', 'quiz'), ''));
foreach (mod_quiz_admin_review_setting::fields() as $field => $name) {
$default = mod_quiz_admin_review_setting::all_on();
$forceduring = null;
if ($field == 'attempt') {
$forceduring = true;
} else if ($field == 'overallfeedback') {
$default = $default ^ mod_quiz_admin_review_setting::DURING;
$forceduring = false;
// Number of attempts.
$options = array(get_string('unlimited'));
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
$options[$i] = $i;
}
$quizsettings->add(new mod_quiz_admin_review_setting('quiz/review' . $field,
$name, '', $default, $forceduring));
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/attempts',
get_string('attemptsallowed', 'quiz'), get_string('configattemptsallowed', 'quiz'),
array('value' => 0, 'adv' => false), $options));
// Grading method.
$quizsettings->add(new mod_quiz_admin_setting_grademethod('quiz/grademethod',
get_string('grademethod', 'quiz'), get_string('configgrademethod', 'quiz'),
array('value' => QUIZ_GRADEHIGHEST, 'adv' => false), null));
// Maximum grade.
$quizsettings->add(new admin_setting_configtext('quiz/maximumgrade',
get_string('maximumgrade'), get_string('configmaximumgrade', 'quiz'), 10, PARAM_INT));
// Shuffle questions.
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shufflequestions',
get_string('shufflequestions', 'quiz'), get_string('configshufflequestions', 'quiz'),
array('value' => 0, 'adv' => false)));
// Questions per page.
$perpage = array();
$perpage[0] = get_string('never');
$perpage[1] = get_string('aftereachquestion', 'quiz');
for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
$perpage[$i] = get_string('afternquestions', 'quiz', $i);
}
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questionsperpage',
get_string('newpageevery', 'quiz'), get_string('confignewpageevery', 'quiz'),
array('value' => 1, 'adv' => false), $perpage));
// Navigation method.
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/navmethod',
get_string('navmethod', 'quiz'), get_string('confignavmethod', 'quiz'),
array('value' => QUIZ_NAVMETHOD_FREE, 'adv' => true), quiz_get_navigation_options()));
// Shuffle within questions.
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shuffleanswers',
get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'),
array('value' => 1, 'adv' => false)));
// Preferred behaviour.
$quizsettings->add(new admin_setting_question_behaviour('quiz/preferredbehaviour',
get_string('howquestionsbehave', 'question'), get_string('howquestionsbehave_desc', 'quiz'),
'deferredfeedback'));
// Each attempt builds on last.
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/attemptonlast',
get_string('eachattemptbuildsonthelast', 'quiz'),
get_string('configeachattemptbuildsonthelast', 'quiz'),
array('value' => 0, 'adv' => true)));
// Review options.
$quizsettings->add(new admin_setting_heading('reviewheading',
get_string('reviewoptionsheading', 'quiz'), ''));
foreach (mod_quiz_admin_review_setting::fields() as $field => $name) {
$default = mod_quiz_admin_review_setting::all_on();
$forceduring = null;
if ($field == 'attempt') {
$forceduring = true;
} else if ($field == 'overallfeedback') {
$default = $default ^ mod_quiz_admin_review_setting::DURING;
$forceduring = false;
}
$quizsettings->add(new mod_quiz_admin_review_setting('quiz/review' . $field,
$name, '', $default, $forceduring));
}
// Show the user's picture.
$quizsettings->add(new mod_quiz_admin_setting_user_image('quiz/showuserpicture',
get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'),
array('value' => 0, 'adv' => false), $options));
// Decimal places for overall grades.
$options = array();
for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) {
$options[$i] = $i;
}
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/decimalpoints',
get_string('decimalplaces', 'quiz'), get_string('configdecimalplaces', 'quiz'),
array('value' => 2, 'adv' => false), $options));
// Decimal places for question grades.
$options = array(-1 => get_string('sameasoverall', 'quiz'));
for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) {
$options[$i] = $i;
}
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questiondecimalpoints',
get_string('decimalplacesquestion', 'quiz'),
get_string('configdecimalplacesquestion', 'quiz'),
array('value' => -1, 'adv' => true), $options));
// Show blocks during quiz attempts.
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/showblocks',
get_string('showblocks', 'quiz'), get_string('configshowblocks', 'quiz'),
array('value' => 0, 'adv' => true)));
// Password.
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/password',
get_string('requirepassword', 'quiz'), get_string('configrequirepassword', 'quiz'),
array('value' => '', 'adv' => true), PARAM_TEXT));
// IP restrictions.
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/subnet',
get_string('requiresubnet', 'quiz'), get_string('configrequiresubnet', 'quiz'),
array('value' => '', 'adv' => true), PARAM_TEXT));
// Enforced delay between attempts.
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay1',
get_string('delay1st2nd', 'quiz'), get_string('configdelay1st2nd', 'quiz'),
array('value' => 0, 'adv' => true), PARAM_INT));
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay2',
get_string('delaylater', 'quiz'), get_string('configdelaylater', 'quiz'),
array('value' => 0, 'adv' => true), PARAM_INT));
// Browser security.
$quizsettings->add(new mod_quiz_admin_setting_browsersecurity('quiz/browsersecurity',
get_string('showinsecurepopup', 'quiz'), get_string('configpopup', 'quiz'),
array('value' => '-', 'adv' => true), null));
// Allow user to specify if setting outcomes is an advanced setting.
if (!empty($CFG->enableoutcomes)) {
$quizsettings->add(new admin_setting_configcheckbox('quiz/outcomes_adv',
get_string('outcomesadvanced', 'quiz'), get_string('configoutcomesadvanced', 'quiz'),
'0'));
}
// Autosave frequency.
$options = array(
0 => get_string('donotuseautosave', 'quiz'),
60 => get_string('oneminute', 'quiz'),
120 => get_string('numminutes', 'moodle', 2),
300 => get_string('numminutes', 'moodle', 5),
);
$quizsettings->add(new admin_setting_configselect('quiz/autosaveperiod',
get_string('autosaveperiod', 'quiz'), get_string('autosaveperiod_desc', 'quiz'), 0, $options));
}
// Show the user's picture.
$options = array(
QUIZ_SHOWIMAGE_NONE => get_string('shownoimage', 'quiz'),
QUIZ_SHOWIMAGE_SMALL => get_string('showsmallimage', 'quiz'),
QUIZ_SHOWIMAGE_LARGE => get_string('showlargeimage', 'quiz'));
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/showuserpicture',
get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'),
array('value' => QUIZ_SHOWIMAGE_NONE, 'adv' => false), $options));
// Decimal places for overall grades.
$options = array();
for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) {
$options[$i] = $i;
}
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/decimalpoints',
get_string('decimalplaces', 'quiz'), get_string('configdecimalplaces', 'quiz'),
array('value' => 2, 'adv' => false), $options));
// Decimal places for question grades.
$options = array(-1 => get_string('sameasoverall', 'quiz'));
for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) {
$options[$i] = $i;
}
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questiondecimalpoints',
get_string('decimalplacesquestion', 'quiz'),
get_string('configdecimalplacesquestion', 'quiz'),
array('value' => -1, 'adv' => true), $options));
// Show blocks during quiz attempts.
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/showblocks',
get_string('showblocks', 'quiz'), get_string('configshowblocks', 'quiz'),
array('value' => 0, 'adv' => true)));
// Password.
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/password',
get_string('requirepassword', 'quiz'), get_string('configrequirepassword', 'quiz'),
array('value' => '', 'adv' => true), PARAM_TEXT));
// IP restrictions.
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/subnet',
get_string('requiresubnet', 'quiz'), get_string('configrequiresubnet', 'quiz'),
array('value' => '', 'adv' => true), PARAM_TEXT));
// Enforced delay between attempts.
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay1',
get_string('delay1st2nd', 'quiz'), get_string('configdelay1st2nd', 'quiz'),
array('value' => 0, 'adv' => true), PARAM_INT));
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay2',
get_string('delaylater', 'quiz'), get_string('configdelaylater', 'quiz'),
array('value' => 0, 'adv' => true), PARAM_INT));
// Browser security.
$quizsettings->add(new mod_quiz_admin_setting_browsersecurity('quiz/browsersecurity',
get_string('showinsecurepopup', 'quiz'), get_string('configpopup', 'quiz'),
array('value' => '-', 'adv' => true), null));
// Allow user to specify if setting outcomes is an advanced setting
if (!empty($CFG->enableoutcomes)) {
$quizsettings->add(new admin_setting_configcheckbox('quiz/outcomes_adv',
get_string('outcomesadvanced', 'quiz'), get_string('configoutcomesadvanced', 'quiz'),
'0'));
}
// Autosave frequency.
$options = array(
0 => get_string('donotuseautosave', 'quiz'),
60 => get_string('oneminute', 'quiz'),
120 => get_string('numminutes', 'moodle', 2),
300 => get_string('numminutes', 'moodle', 5),
);
$quizsettings->add(new admin_setting_configselect('quiz/autosaveperiod',
get_string('autosaveperiod', 'quiz'), get_string('autosaveperiod_desc', 'quiz'), 0, $options));
// Now, depending on whether any reports have their own settings page, add
// the quiz setting page to the appropriate place in the tree.
if (empty($reportsbyname) && empty($rulesbyname)) {