diff --git a/lib/adminlib.php b/lib/adminlib.php index a921eaa0143..dee44e08140 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -3414,10 +3414,36 @@ class admin_setting_configduration extends admin_setting { } +/** + * Seconds duration setting with an advanced checkbox, that controls a additional + * $name.'_adv' setting. + * + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2014 The Open University + */ +class admin_setting_configduration_with_advanced extends admin_setting_configduration { + /** + * 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 array $defaultsetting array of int value, and bool whether it is + * is advanced by default. + * @param int $defaultunit - day, week, etc. (in seconds) + */ + public function __construct($name, $visiblename, $description, $defaultsetting, $defaultunit = 86400) { + parent::__construct($name, $visiblename, $description, $defaultsetting['value'], $defaultunit); + $this->set_advanced_flag_options(admin_setting_flag::ENABLED, !empty($defaultsetting['adv'])); + } +} + + /** * Used to validate a textarea used for ip addresses * * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2011 Petr Skoda (http://skodak.org) */ class admin_setting_configiplist extends admin_setting_configtextarea { diff --git a/mod/quiz/lang/en/deprecated.txt b/mod/quiz/lang/en/deprecated.txt index 4646a943ebe..8162c480c32 100644 --- a/mod/quiz/lang/en/deprecated.txt +++ b/mod/quiz/lang/en/deprecated.txt @@ -1,8 +1,10 @@ -invalidnumericanswer,mod_quiz -multiplier,mod_quiz -invalidnumerictolerance,mod_quiz -unusedcategorydeleted,mod_quiz categories,mod_quiz -import,mod_quiz -export,mod_quiz category,mod_quiz +export,mod_quiz +import,mod_quiz +invalidnumericanswer,mod_quiz +invalidnumerictolerance,mod_quiz +multiplier,mod_quiz +timelimitmin,mod_quiz +timelimitsec,mod_quiz +unusedcategorydeleted,mod_quiz diff --git a/mod/quiz/lang/en/quiz.php b/mod/quiz/lang/en/quiz.php index f17d5fb5af7..967d6ca9f69 100644 --- a/mod/quiz/lang/en/quiz.php +++ b/mod/quiz/lang/en/quiz.php @@ -103,8 +103,8 @@ $string['attemptsonly'] = 'Show only students with attempts'; $string['attemptstate'] = 'State'; $string['attemptstillinprogress'] = 'Attempt still in progress'; $string['attemptsunlimited'] = 'Unlimited attempts'; -$string['autosaveperiod'] = 'Auto-save period'; -$string['autosaveperiod_desc'] = 'Students\' responses can be saved automatically every few minutes during quiz attempts. This involves a trade-off: saving the responses increases the server load, but reduces the chance that students lose their work.'; +$string['autosaveperiod'] = 'Auto-save delay'; +$string['autosaveperiod_desc'] = 'Responses can be saved automatically during quiz attempts. The responses are saved whenever one is changed, and then after this delay. There is a trade-off: a shorter delay increases the server load, but reduces the chance that students lose their work. If you are going to make this delay much shorter, you should change the value gradually and monitor the server load. If the load gets too high, make the delay longer again. Setting the delay to 0 turns off auto-saving.'; $string['back'] = 'Back to preview question'; $string['backtocourse'] = 'Back to the course'; $string['backtoquestionlist'] = 'Back to question list'; @@ -368,10 +368,10 @@ $string['functiondisabledbysecuremode'] = 'That functionality is currently disab $string['generalfeedback'] = 'General feedback'; $string['generalfeedback_help'] = 'General feedback is text which is shown after a question has been attempted. Unlike feedback for a specific question which depends on the response given, the same general feedback is always shown.'; $string['graceperiod'] = 'Submission grace period'; -$string['graceperiod_desc'] = 'If what to do when time expires is set to \'Allow a grace period to submit, but not change any responses\', the default amount of extra time that is allowed, in seconds.'; -$string['graceperiod_help'] = 'If what to do when time expires is set to \'Allow a grace period to submit, but not change any responses\', the amount of extra time that is allowed.'; +$string['graceperiod_desc'] = 'If what to do when time expires is set to \'Allow a grace period to submit, but not change any responses\', this is the default amount of extra time that is allowed.'; +$string['graceperiod_help'] = 'If what to do when time expires is set to \'Allow a grace period to submit, but not change any responses\', this is the amount of extra time that is allowed.'; $string['graceperiodmin'] = 'Last submission grace period'; -$string['graceperiodmin_desc'] = 'There is a potential problem right at the end of the quiz. On the one hand, we want to let students continue working right up until the last second - with the help of the timer that automatically submits the quiz when time runs out. On the other hand, the server may then be overloaded, and take some time to get to process the responses. Therefore, we will accept responses for up to this many seconds after time expires, so they are not penalised for the server being slow. However, the student could cheat and get this many seconds to answer the quiz. You have to make a trade-off based on how much you trust the performance of your server during quizzes.'; +$string['graceperiodmin_desc'] = 'There is a potential problem right at the end of the quiz. On the one hand, we want to let students continue working right up until the last second - with the help of the timer that automatically submits the quiz when time runs out. On the other hand, the server may then be overloaded, and take some time to get to process the responses. Therefore, we will accept responses for up to this long after time expires, so they are not penalised for the server being slow. However, the student could cheat and get this many seconds to answer the quiz. You have to make a trade-off based on how much you trust the performance of your server during quizzes.'; $string['graceperiodtoosmall'] = 'The grace period must be more than {$a}.'; $string['grade'] = 'Grade'; $string['gradeall'] = 'Grade all'; diff --git a/mod/quiz/settings.php b/mod/quiz/settings.php index 3a73b705180..fc4a28fd6b5 100644 --- a/mod/quiz/settings.php +++ b/mod/quiz/settings.php @@ -60,9 +60,9 @@ if ($ADMIN->fulltree) { $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)); + $quizsettings->add(new admin_setting_configduration_with_advanced('quiz/timelimit', + get_string('timelimit', 'quiz'), get_string('configtimelimitsec', 'quiz'), + array('value' => '0', 'adv' => false), 60)); // What to do with overdue attempts. $quizsettings->add(new mod_quiz_admin_setting_overduehandling('quiz/overduehandling', @@ -70,14 +70,14 @@ if ($ADMIN->fulltree) { array('value' => 'autosubmit', 'adv' => false), null)); // Grace period time. - $quizsettings->add(new admin_setting_configtext_with_advanced('quiz/graceperiod', + $quizsettings->add(new admin_setting_configduration_with_advanced('quiz/graceperiod', get_string('graceperiod', 'quiz'), get_string('graceperiod_desc', 'quiz'), - array('value' => '86400', 'adv' => false), PARAM_INT)); + array('value' => '86400', 'adv' => false))); // Minimum grace period used behind the scenes. - $quizsettings->add(new admin_setting_configtext('quiz/graceperiodmin', + $quizsettings->add(new admin_setting_configduration('quiz/graceperiodmin', get_string('graceperiodmin', 'quiz'), get_string('graceperiodmin_desc', 'quiz'), - 60, PARAM_INT)); + 60, 1)); // Number of attempts. $options = array(get_string('unlimited')); @@ -190,12 +190,12 @@ if ($ADMIN->fulltree) { array('value' => '', 'adv' => true), PARAM_TEXT)); // Enforced delay between attempts. - $quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay1', + $quizsettings->add(new admin_setting_configduration_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', + array('value' => 0, 'adv' => true), 60)); + $quizsettings->add(new admin_setting_configduration_with_advanced('quiz/delay2', get_string('delaylater', 'quiz'), get_string('configdelaylater', 'quiz'), - array('value' => 0, 'adv' => true), PARAM_INT)); + array('value' => 0, 'adv' => true), 60)); // Browser security. $quizsettings->add(new mod_quiz_admin_setting_browsersecurity('quiz/browsersecurity', @@ -210,14 +210,8 @@ if ($ADMIN->fulltree) { } // 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'), 120, $options)); + $quizsettings->add(new admin_setting_configduration('quiz/autosaveperiod', + get_string('autosaveperiod', 'quiz'), get_string('autosaveperiod_desc', 'quiz'), 60, 1)); } // Now, depending on whether any reports have their own settings page, add