From 73465743f94e7e2505db13ace3eb5ce7cd68cdf6 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 28 Feb 2014 08:58:58 +0100 Subject: [PATCH] MDL-44278 Quiz time overrides: use the same step everywhere. On the main form, you could select to the nearest minute. On the override form you could only select to the nearest 5 minutes. --- mod/quiz/mod_form.php | 7 +++++-- mod/quiz/override_form.php | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index 0b904aed554..30eadfb2388 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -37,6 +37,9 @@ require_once($CFG->dirroot . '/mod/quiz/locallib.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class mod_quiz_mod_form extends moodleform_mod { + /** @var array options to be used with date_time_selector fields in the quiz. */ + public static $datefieldoptions = array('optional' => true, 'step' => 1); + protected $_feedbacks; protected static $reviewfields = array(); // Initialised in the constructor. @@ -79,11 +82,11 @@ class mod_quiz_mod_form extends moodleform_mod { // Open and close dates. $mform->addElement('date_time_selector', 'timeopen', get_string('quizopen', 'quiz'), - array('optional' => true, 'step' => 1)); + self::$datefieldoptions); $mform->addHelpButton('timeopen', 'quizopenclose', 'quiz'); $mform->addElement('date_time_selector', 'timeclose', get_string('quizclose', 'quiz'), - array('optional' => true, 'step' => 1)); + self::$datefieldoptions); // Time limit. $mform->addElement('duration', 'timelimit', get_string('timelimit', 'quiz'), diff --git a/mod/quiz/override_form.php b/mod/quiz/override_form.php index 7b1172ac3d4..f526107666f 100644 --- a/mod/quiz/override_form.php +++ b/mod/quiz/override_form.php @@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/formslib.php'); +require_once($CFG->dirroot . '/mod/quiz/mod_form.php'); /** @@ -184,11 +185,11 @@ class quiz_override_form extends moodleform { // Open and close dates. $mform->addElement('date_time_selector', 'timeopen', - get_string('quizopen', 'quiz'), array('optional' => true)); + get_string('quizopen', 'quiz'), mod_quiz_mod_form::$datefieldoptions); $mform->setDefault('timeopen', $this->quiz->timeopen); $mform->addElement('date_time_selector', 'timeclose', - get_string('quizclose', 'quiz'), array('optional' => true)); + get_string('quizclose', 'quiz'), mod_quiz_mod_form::$datefieldoptions); $mform->setDefault('timeclose', $this->quiz->timeclose); // Time limit.