From e2249afe2bd96ad218f2a0bb99bd77a415b920ab Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 26 Aug 2008 01:05:01 +0000 Subject: [PATCH] MDL-7010 Convert mod\quiz\config.html to mod/quiz/settingstree.php using the new admin tree system. --- admin/settings/plugins.php | 4 - lang/en_utf8/quiz.php | 19 ++ lang/en_utf8/quiz_analysis.php | 1 + lang/en_utf8/quiz_grading.php | 1 + lang/en_utf8/quiz_overview.php | 1 + lang/en_utf8/quiz_responses.php | 1 + lang/en_utf8/quiz_statistics.php | 1 + lib/adminlib.php | 286 ++++++++++++++++++++-- mod/quiz/config.html | 391 ------------------------------- mod/quiz/db/upgrade.php | 16 ++ mod/quiz/defaults.php | 70 +++--- mod/quiz/edit.php | 2 +- mod/quiz/lib.php | 20 ++ mod/quiz/locallib.php | 21 -- mod/quiz/mod_form.php | 103 ++++---- mod/quiz/reviewoptions.html | 88 ------- mod/quiz/settingstree.php | 170 ++++++++++++++ mod/quiz/version.php | 2 +- theme/standard/styles_layout.css | 21 +- 19 files changed, 604 insertions(+), 614 deletions(-) delete mode 100644 mod/quiz/config.html delete mode 100644 mod/quiz/reviewoptions.html create mode 100644 mod/quiz/settingstree.php diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index 1c0aa66861..631005bb31 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -29,10 +29,6 @@ if ($hassiteconfig) { include($CFG->dirroot.'/mod/'.$modulename.'/settings.php'); } $ADMIN->add('modsettings', $settings); - } else if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/config.html')) { - //TODO this branch should be deleted as soon as quiz/config.html has been - //migrated to settings.php - $ADMIN->add('modsettings', new admin_externalpage('modsetting'.$modulename, $strmodulename, "$CFG->wwwroot/$CFG->admin/module.php?module=$modulename", 'moodle/site:config', !$module->visible)); } } } diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php index 01b1220bd9..47c9afe40f 100644 --- a/lang/en_utf8/quiz.php +++ b/lang/en_utf8/quiz.php @@ -124,6 +124,24 @@ $string['comment'] = 'Comment'; $string['commentorgrade'] = 'Make comment or override grade'; $string['comments'] = 'Comments'; $string['completedon'] = 'Completed on'; +$string['configintro'] = 'The values you set here define the default values that are used in the settings form when you create a new quiz. You can also configure which quiz settings are considered advanced.'; +$string['configadaptive'] = 'If you choose Yes for this option then the student will be allowed multiple responses to a question even within the same attempt at the quiz.'; +$string['configattemptsallowed'] = 'Restriction on the number of attempts students are allowed at the quiz.'; +$string['configdecimaldigits'] = 'Number of digits that should be shown after the decimal point when displaying grades.'; +$string['configdelay1'] = 'If you set a time delay, then a student has to wait for that time before they can attempt a quiz after the first attempt.'; +$string['configdelay2'] = 'If you set a time delay here, then a student has to wait for that time before they can attempt their third or later attempts.'; +$string['configeachattemptbuildsonthelast'] = 'If multiple attempts are allowed then each new attempt contains the results of the previous attempt.'; +$string['configgrademethod'] = 'When multiple attempts are allowed, which method should be used to calculate the student\'s final grade for the quiz.'; +$string['configmaximumgrade'] = 'The default grade that the quiz grade is scaled to be out of.'; +$string['confignewpageevery'] = 'When adding questions to the quiz page breaks will automatically be inserted according to the setting you choose here.'; +$string['configpenaltyscheme'] = 'Penalty subtracted for each wrong response in adaptive mode.'; +$string['configpopup'] = 'Use JavaScript tricks to try to restrict copy and paste, etc. during quiz attempts.'; +$string['configrequirepassword'] = 'Students must enter this password before they can attempt the quiz.'; +$string['configrequiresubnet'] = 'Students can only attempt the quiz from these computers.'; +$string['configreviewoptions'] = 'These options control what information users can see when they review a quiz attempt or look at the quiz reports.'; +$string['configshufflequestions'] = 'If you enable this option, then the order of questions in the quiz will be randomly shuffled each time a student attempts the quiz.'; +$string['configshufflewithin'] = 'If you enable this option, then the parts making up the individual questions will be randomly shuffled each time a student starts an attempt at this quiz, provided the option is also enabled in the question settings.'; +$string['configtimelimit'] = 'Default time limit for quizzes in minutes. 0 mean no time limit.'; $string['confirmclose'] = 'You are about to close this attempt. Once you close the attempt you will no longer be able to change your answers.'; $string['confirmserverdelete'] = 'Are you sure you want to remove the server $a from the list?'; $string['confirmstartattemptlimit'] = 'This quiz is limited to $a attempt(s). You are about to start a new attempt. Do you wish to proceed?'; @@ -232,6 +250,7 @@ $string['event6'] = 'Close&Grade'; $string['event7'] = 'Submit'; $string['event8'] = 'Close'; $string['event9'] = 'Manual Grade'; +$string['everythingon'] = 'Everything on'; $string['examview'] = 'Examview'; $string['export'] = 'Export'; $string['exporterror'] = 'An error occurred during export processing'; diff --git a/lang/en_utf8/quiz_analysis.php b/lang/en_utf8/quiz_analysis.php index 29fe81ce74..6ab9189dc8 100644 --- a/lang/en_utf8/quiz_analysis.php +++ b/lang/en_utf8/quiz_analysis.php @@ -3,6 +3,7 @@ $string['analysis'] = 'Item analysis'; +$string['analysisreport'] = 'Item analysis report'; $string['analysisdownload'] = 'Analysis download'; $string['analysisoptions'] = 'Analysis options'; $string['analysistitle'] = 'Item Analysis Table'; diff --git a/lang/en_utf8/quiz_grading.php b/lang/en_utf8/quiz_grading.php index 907f81a819..d4f2bd5231 100644 --- a/lang/en_utf8/quiz_grading.php +++ b/lang/en_utf8/quiz_grading.php @@ -4,6 +4,7 @@ $string['essayonly'] = 'The following questions need to be graded manually'; $string['grading'] = 'Manual grading'; +$string['gradingreport'] = 'Manual grading report'; $string['gradeall'] = 'Grade all $a attempts'; $string['graded'] = '(graded)'; $string['gradeungraded'] = 'Grade all $a ungraded attempts'; diff --git a/lang/en_utf8/quiz_overview.php b/lang/en_utf8/quiz_overview.php index 7e06b16033..b4ac517536 100644 --- a/lang/en_utf8/quiz_overview.php +++ b/lang/en_utf8/quiz_overview.php @@ -25,6 +25,7 @@ $string['optnoattemptsonly'] = '$a who have not attempted the quiz'; $string['optonlygradedattempts'] = 'that are graded for each user ($a)'; $string['optonlyregradedattempts'] = 'that have been regraded / are marked as needing regrading'; $string['overview'] = 'Grades'; +$string['overviewreport'] = 'Grades report'; $string['overviewdownload'] = 'Overview download'; $string['overviewdownload'] = 'Overview download'; $string['overviewreportgraph'] = 'Overall Number of Students Achieving Grade Ranges'; diff --git a/lang/en_utf8/quiz_responses.php b/lang/en_utf8/quiz_responses.php index ca90ac34ed..eed3483793 100644 --- a/lang/en_utf8/quiz_responses.php +++ b/lang/en_utf8/quiz_responses.php @@ -5,5 +5,6 @@ $string['responsestitle'] = 'Detailed responses'; $string['pagesize'] = 'Page Size'; $string['reportresponses'] = 'Responses'; $string['responses'] = 'Responses'; +$string['responses report'] = 'Responses report'; $string['responsesdownload'] = 'Responses download'; ?> \ No newline at end of file diff --git a/lang/en_utf8/quiz_statistics.php b/lang/en_utf8/quiz_statistics.php index 016f6ee5b7..2642cec492 100644 --- a/lang/en_utf8/quiz_statistics.php +++ b/lang/en_utf8/quiz_statistics.php @@ -3,6 +3,7 @@ $string['statistics'] = 'Statistics'; +$string['statisticsreport'] = 'Statistics report'; $string['calculatefrom'] = 'Calculate statistics from'; diff --git a/lib/adminlib.php b/lib/adminlib.php index 0332b83c28..a83bddcfe0 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -2557,41 +2557,61 @@ class admin_setting_configselect extends admin_setting { return ($this->config_write($this->name, $data) ? '' : get_string('errorsetting', 'admin')); } - function output_html($data, $query='') { + /** + * Ensure the options are loaded, and generate the HTML for the select + * element and any warning message. Separating this out from output_html + * makes it easier to subclass this class. + * + * @param string $data the option to show as selected. + * @param string $current the currently selected option in the database, null if none. + * @param string $default the default selected option. + * @return array the HTML for the select element, and a warning message. + */ + function output_select_html($data, $current, $default, $extraname = '') { if (!$this->load_choices() or empty($this->choices)) { - return ''; - } - $default = $this->get_defaultsetting(); - - if (!is_null($default) and array_key_exists($default, $this->choices)) { - $defaultinfo = $this->choices[$default]; - } else { - $defaultinfo = NULL; + return array('', ''); } - $current = $this->get_setting(); $warning = ''; if (is_null($current)) { - //first run + // first run } else if (empty($current) and (array_key_exists('', $this->choices) or array_key_exists(0, $this->choices))) { // no warning } else if (!array_key_exists($current, $this->choices)) { $warning = get_string('warningcurrentsetting', 'admin', s($current)); - if (!is_null($default) and $data==$current) { + if (!is_null($default) and $data == $current) { $data = $default; // use default instead of first value when showing the form } } - $return = '
'; foreach ($this->choices as $key => $value) { // the string cast is needed because key may be integer - 0 is equal to most strings! - $return .= ''; + $selecthtml .= ''; + } + $selecthtml .= ''; + return array($selecthtml, $warning); + } + + function output_html($data, $query='') { + $default = $this->get_defaultsetting(); + $current = $this->get_setting(); + + list($selecthtml, $warning) = $this->output_select_html($data, $current, $default); + if (!$selecthtml) { + return ''; + } + + if (!is_null($default) and array_key_exists($default, $this->choices)) { + $defaultinfo = $this->choices[$default]; + } else { + $defaultinfo = NULL; } - $return .= '
'; + + $return = '
' . $selecthtml . '
'; return format_admin_setting($this, $this->visiblename, $return, $this->description, true, $warning, $defaultinfo, $query); } - } /** @@ -3629,6 +3649,240 @@ class admin_setting_pickroles extends admin_setting_configmulticheckbox { } } +/** + * Text field linked to config_plugins for the quiz, with an advanced checkbox. + */ +class admin_setting_quiz_text extends admin_setting_configtext { + function __construct($name, $visiblename, $description, $defaultsetting, $paramtype) { + $this->plugin = 'quiz'; + parent::admin_setting_configtext($name, $visiblename, $description, + $defaultsetting, $paramtype); + } + + function get_setting() { + $value = parent::get_setting(); + $fix = $this->config_read('fix_' . $this->name); + if (is_null($value) or is_null($fix)) { + return NULL; + } + return array('value' => $value, 'fix' => $fix); + } + + function write_setting($data) { + $error = parent::write_setting($data['value']); + if (!$error) { + if (empty($data['fix'])) { + $ok = $this->config_write('fix_' . $this->name, 0); + } else { + $ok = $this->config_write('fix_' . $this->name, 1); + } + if (!$ok) { + $error = get_string('errorsetting', 'admin'); + } + } + return $error; + } + + function output_html($data, $query='') { + $default = $this->get_defaultsetting(); + $defaultinfo = array(); + if (isset($this->choices[$default['value']])) { + $defaultinfo[] = $default['value']; + } + if (!empty($default['fix'])) { + $defaultinfo[] = get_string('advanced'); + } + $defaultinfo = implode(', ', $defaultinfo); + + $fix = !empty($data['fix']); + $return = '
' . + '' . + ' ' . + '
'; + + return format_admin_setting($this, $this->visiblename, $return, + $this->description, true, '', $defaultinfo, $query); + } +} + +/** + * Dropdown menu linked to config_plugins for the quiz, with an advanced checkbox. + */ +class admin_setting_quiz_combo extends admin_setting_configselect { + function __construct($name, $visiblename, $description, $defaultsetting, $choices) { + $this->plugin = 'quiz'; + parent::admin_setting_configselect($name, $visiblename, $description, + $defaultsetting, $choices); + } + + function get_setting() { + $value = parent::get_setting(); + $fix = $this->config_read('fix_' . $this->name); + if (is_null($value) or is_null($fix)) { + return NULL; + } + return array('value' => $value, 'fix' => $fix); + } + + function write_setting($data) { + $error = parent::write_setting($data['value']); + if (!$error) { + if (empty($data['fix'])) { + $ok = $this->config_write('fix_' . $this->name, 0); + } else { + $ok = $this->config_write('fix_' . $this->name, 1); + } + if (!$ok) { + $error = get_string('errorsetting', 'admin'); + } + } + return $error; + } + + function output_html($data, $query='') { + $default = $this->get_defaultsetting(); + $current = $this->get_setting(); + + list($selecthtml, $warning) = $this->output_select_html($data['value'], + $current['value'], $default['value'], '[value]'); + if (!$selecthtml) { + return ''; + } + + if (!is_null($default) and array_key_exists($default['value'], $this->choices)) { + $defaultinfo = array(); + if (isset($this->choices[$default['value']])) { + $defaultinfo[] = $this->choices[$default['value']]; + } + if (!empty($default['fix'])) { + $defaultinfo[] = get_string('advanced'); + } + $defaultinfo = implode(', ', $defaultinfo); + } else { + $defaultinfo = ''; + } + + $fix = !empty($data['fix']); + $return = '
' . $selecthtml . + ' ' . + '
'; + + return format_admin_setting($this, $this->visiblename, $return, $this->description, true, $warning, $defaultinfo, $query); + } +} + +class admin_setting_quiz_reviewoptions extends admin_setting { + private static $times = array( + QUIZ_REVIEW_IMMEDIATELY => 'reviewimmediately', + QUIZ_REVIEW_OPEN => 'reviewopen', + QUIZ_REVIEW_CLOSED => 'reviewclosed'); + private static $things = array( + QUIZ_REVIEW_RESPONSES => 'responses', + QUIZ_REVIEW_ANSWERS => 'answers', + QUIZ_REVIEW_FEEDBACK => 'feedback', + QUIZ_REVIEW_GENERALFEEDBACK => 'generalfeedback', + QUIZ_REVIEW_SCORES => 'scores', + QUIZ_REVIEW_OVERALLFEEDBACK => 'overallfeedback'); + + function __construct($name, $visiblename, $description, $defaultsetting) { + $this->plugin = 'quiz'; + parent::admin_setting($name, $visiblename, $description, $defaultsetting); + } + + private function normalise_data($data) { + $value = 0; + foreach (admin_setting_quiz_reviewoptions::$times as $timemask => $timestring) { + foreach (admin_setting_quiz_reviewoptions::$things as $thingmask => $thingstring) { + if (!empty($data[$timemask][$thingmask])) { + $value += $timemask & $thingmask; + } + } + } + return $value; + } + + function get_setting() { + $value = $this->config_read($this->name); + $fix = $this->config_read('fix_' . $this->name); + if (is_null($value) or is_null($fix)) { + return NULL; + } + return array('value' => $value, 'fix' => $fix); + } + + function write_setting($data) { + if (!isset($data['value'])) { + $data['value'] = $this->normalise_data($data); + } + $ok = $this->config_write($this->name, $data['value']); + if ($ok) { + if (empty($data['fix'])) { + $ok = $this->config_write('fix_' . $this->name, 0); + } else { + $ok = $this->config_write('fix_' . $this->name, 1); + } + } + if (!$ok) { + return get_string('errorsetting', 'admin'); + } + return ''; + } + + function output_html($data, $query='') { + if (!isset($data['value'])) { + $data['value'] = $this->normalise_data($data); + } + + $return = '
' . "\n"; + foreach (admin_setting_quiz_reviewoptions::$times as $timemask => $timestring) { + $return .= '
' . get_string($timestring, 'quiz') . "
\n"; + $nameprefix = $this->get_full_name() . '[' . $timemask . ']'; + $idprefix = $this->get_id(). '_' . $timemask . '_'; + foreach (admin_setting_quiz_reviewoptions::$things as $thingmask => $thingstring) { + $id = $idprefix . $thingmask; + $state = ''; + if ($data['value'] & $timemask & $thingmask) { + $state = 'checked="checked" '; + } + $return .= ' \n"; + } + $return .= "
\n"; + } + $return .= "
\n"; + + $fix = !empty($data['fix']); + $return .= '' . + ' '; + + return format_admin_setting($this, $this->visiblename, $return, + $this->description, true, '', get_string('everythingon', 'quiz'), $query); + } +} + +/** + * Specialisation of admin_setting_quiz_combo for easy yes/no choices. + */ +class admin_setting_quiz_yesno extends admin_setting_quiz_combo { + function __construct($name, $visiblename, $description, $defaultsetting) { + $this->plugin = 'quiz'; + parent::__construct($name, $visiblename, $description, + $defaultsetting, array(get_string('no'), get_string('yes'))); + } +} + /** * Graded roles in gradebook */ diff --git a/mod/quiz/config.html b/mod/quiz/config.html deleted file mode 100644 index 5df78765d9..0000000000 --- a/mod/quiz/config.html +++ /dev/null @@ -1,391 +0,0 @@ -dirroot . '/mod/quiz/locallib.php'); - - if (!isset($form->timeopen)) { - $form->timeopen = ""; - } - if (!isset($form->timeclose)) { - $form->timeclose = ""; - } - if (!isset($form->attempts)) { - $form->attempts = $CFG->quiz_attempts; - } - if (!isset($form->attemptonlast)) { - $form->attemptonlast = $CFG->quiz_attemptonlast; - } - if (!isset($form->grademethod)) { - $form->grademethod = $CFG->quiz_grademethod; - } - if (!isset($form->decimalpoints)) { - $form->decimalpoints = $CFG->quiz_decimalpoints; - } - if (!isset($form->review)) { - $form->review = $CFG->quiz_review; - } - if (!isset($form->questionsperpage)) { - $form->questionsperpage = $CFG->quiz_questionsperpage; - } - if (!isset($form->shufflequestions)) { - $form->shufflequestions = $CFG->quiz_shufflequestions; - } - if (!isset($form->shuffleanswers)) { - $form->shuffleanswers = $CFG->quiz_shuffleanswers; - } - if (!isset($form->grade)) { - $form->grade = $CFG->quiz_maximumgrade; - } - if (!isset($form->questions)) { - $form->questions = ""; - } - if (!isset($form->password)) { - $form->quizpassword = $CFG->quiz_password; - } - if (!isset($form->subnet)) { - $form->subnet = $CFG->quiz_subnet; - } - if (!isset($form->timelimit)) { - $form->timelimit = $CFG->quiz_timelimit; - } - if (!isset($form->popup)) { - $form->popup = $CFG->quiz_popup; - } - if (!isset($form->optionflags)) { - $form->optionflags = $CFG->quiz_optionflags; - } - if (!isset($form->penaltyscheme)) { - $form->penaltyscheme = $CFG->quiz_penaltyscheme; - } - if (!isset($form->maximumgrade)) { - $form->maximumgrade = $CFG->quiz_maximumgrade; - } - //enforced delay attempt between quiz - if (!isset($form->delay1)) { - $form->delay1 = $CFG->quiz_delay1; - } - if (!isset($form->delay2)) { - $form->delay2 = $CFG->quiz_delay2; - } - //enforced time delay between quiz attempts add-on - $timedelayoptions = array(); - $timedelayoptions[0] = get_string('none'); - $timedelayoptions[1800] = get_string('numminutes', '', 30); - $timedelayoptions[3600] = get_string('numminutes', '', 60); - for($i=2; $i<=23; $i++) { - $seconds = $i*3600; - $timedelayoptions[$seconds] = get_string('numhours', '', $i); - } - $timedelayoptions[86400] = get_string('numhours', '', 24); - for($i=2; $i<=7; $i++) { - $seconds = $i*86400; - $timedelayoptions[$seconds] = get_string('numdays', '', $i); - } -?> - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - dirroot . '/mod/quiz/reviewoptions.html'); ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  - - - -
: - timelimit) echo 'checked="checked"' ?> /> - - - - - - quiz_fix_timelimit ? 'checked="checked"' : ''; ?> /> -
: - questionsperpage, ''); - helpbutton('questionsperpage', get_string('newpageevery', 'quiz'), 'quiz'); - ?> - - - quiz_fix_questionsperpage ? 'checked="checked"' : ''; ?> /> -
: - shufflequestions, "", "", ""); - helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz"); - ?> - - - quiz_fix_shufflequestions ? 'checked="checked"' : ''; ?> /> -
: - shuffleanswers, "", "", ""); - helpbutton("shufflewithin", get_string("shufflewithin","quiz"), "quiz"); - ?> - - - quiz_fix_shuffleanswers ? 'checked="checked"' : ''; ?> /> -
: - attempts, "", "", ""); - helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz"); - ?> - - - quiz_fix_attempts ? 'checked="checked"' : ''; ?> /> -
: - attemptonlast, "", "", ""); - helpbutton("repeatattempts", get_string("eachattemptbuildsonthelast", "quiz"), "quiz"); - ?> - - - quiz_fix_attemptonlast ? 'checked="checked"' : ''; ?> /> -
: - grademethod, "", "", ""); - helpbutton("grademethod", get_string("grademethod","quiz"), "quiz"); - ?> - - - quiz_fix_grademethod ? 'checked="checked"' : ''; ?> /> -
: - quiz_optionflags & QUESTION_ADAPTIVE) ? 1 : 0, ""); - helpbutton("adaptive", get_string("adaptive","quiz"), "quiz"); - ?> - - - quiz_fix_adaptive ? 'checked="checked"' : ''; ?> /> -
: - penaltyscheme", ""); - helpbutton("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz"); - ?> - - - quiz_fix_penaltyscheme ? 'checked="checked"' : ''; ?> /> -
: - decimalpoints, "", "", ""); - helpbutton("decimalpoints", get_string("decimaldigits","quiz"), "quiz"); - ?> - - - quiz_fix_decimalpoints ? 'checked="checked"' : ''; ?> /> -
- - quiz_fix_review ? 'checked="checked"' : ''; ?> /> -
: - popup, "", "", ""); - helpbutton("popup", get_string("popup","quiz"), "quiz"); - ?> - - - quiz_fix_popup ? 'checked="checked"' : ''; ?> /> -
: - delay1, "", "", "" ); - helpbutton('timedelay1', get_string('delay1','quiz'), 'quiz'); - ?> - - - quiz_fix_delay1 ? 'checked="checked"' : ''; ?> /> -
: - delay2, "", "", ""); - helpbutton('timedelay2', get_string('delay2','quiz'), 'quiz'); - ?> - - - quiz_fix_delay2 ? 'checked="checked"' : ''; ?> /> -
: - - - - - quiz_fix_password ? 'checked="checked"' : ''; ?> /> -
: - - - - - quiz_fix_subnet ? 'checked="checked"' : ''; ?> /> -
: - =1; $i--) { - $grades[$i] = $i; - } - $grades[0] = get_string("nograde"); - choose_from_menu ($grades, "maximumgrade", $form->maximumgrade, "", "", ""); - helpbutton("maxgrade", get_string("maximumgrade"), "quiz"); - ?> -
- - " /> -
-
-
- - diff --git a/mod/quiz/db/upgrade.php b/mod/quiz/db/upgrade.php index d3ec9b890d..bc0bee07b1 100644 --- a/mod/quiz/db/upgrade.php +++ b/mod/quiz/db/upgrade.php @@ -170,6 +170,22 @@ function xmldb_quiz_upgrade($oldversion) { upgrade_mod_savepoint($result, 2008081507, 'quiz'); } + /// Move all of the quiz config settings from $CFG to the config_plugins table. + if ($result && $oldversion < 2008082200) { + foreach (get_object_vars($CFG) as $name => $value) { + if (strpos($name, 'quiz_') === 0) { + $shortname = substr($name, 5); + if ($shortname == 'fix_adaptive') { + // Special case - remove old inconsistency. + $shortname == 'fix_optionflags'; + } + $result = $result && set_config($shortname, $value, 'quiz'); + $result = $result && unset_config($name); + } + } + upgrade_mod_savepoint($result, 2008082200, 'quiz'); + } + return $result; } diff --git a/mod/quiz/defaults.php b/mod/quiz/defaults.php index cb80ab3b84..0e3e2dfcca 100644 --- a/mod/quiz/defaults.php +++ b/mod/quiz/defaults.php @@ -3,42 +3,42 @@ // This file is generally only included from upgrade_activity_modules() // It defines default values for any important configuration variables - $defaults = array ( - 'quiz_review' => 0xffffff, - 'quiz_attemptonlast' => 0, - 'quiz_attempts' => 0, - 'quiz_grademethod' => '', - 'quiz_decimalpoints' => 2, - 'quiz_maximumgrade' => 10, - 'quiz_password' => '', - 'quiz_popup' => 0, - 'quiz_questionsperpage' => 0, - 'quiz_shuffleanswers' => 1, - 'quiz_shufflequestions' => 0, - 'quiz_subnet' => '', - 'quiz_timelimit' => 0, - 'quiz_optionflags' => 1, - 'quiz_penaltyscheme' => 1, - 'quiz_delay1' => 0, - 'quiz_delay2' => 0, + $defaults = array ( + '_use_config_plugins' => true, - 'quiz_fix_review' => 0, - 'quiz_fix_attemptonlast' => 0, - 'quiz_fix_attempts' => 0, - 'quiz_fix_grademethod' => 0, - 'quiz_fix_decimalpoints' => 0, - 'quiz_fix_password' => 0, - 'quiz_fix_popup' => 0, - 'quiz_fix_questionsperpage' => 0, - 'quiz_fix_shuffleanswers' => 0, - 'quiz_fix_shufflequestions' => 0, - 'quiz_fix_subnet' => 0, - 'quiz_fix_timelimit' => 0, - 'quiz_fix_adaptive' => 0, - 'quiz_fix_penaltyscheme' => 0, - 'quiz_fix_delay1' => 0, - 'quiz_fix_delay2' => 0, + 'review' => 0x3fffffff, + 'attemptonlast' => 0, + 'attempts' => 0, + 'grademethod' => QUIZ_GRADEHIGHEST, + 'decimalpoints' => 2, + 'maximumgrade' => 10, + 'password' => '', + 'popup' => 0, + 'questionsperpage' => 0, + 'shuffleanswers' => 1, + 'shufflequestions' => 0, + 'subnet' => '', + 'timelimit' => 0, + 'optionflags' => 1, + 'penaltyscheme' => 1, + 'delay1' => 0, + 'delay2' => 0, + 'fix_review' => 0, + 'fix_attemptonlast' => 0, + 'fix_attempts' => 0, + 'fix_grademethod' => 0, + 'fix_decimalpoints' => 0, + 'fix_password' => 0, + 'fix_popup' => 0, + 'fix_questionsperpage' => 0, + 'fix_shuffleanswers' => 0, + 'fix_shufflequestions' => 0, + 'fix_subnet' => 0, + 'fix_timelimit' => 0, + 'fix_optionflags' => 0, + 'fix_penaltyscheme' => 0, + 'fix_delay1' => 0, + 'fix_delay2' => 0, ); - ?> diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 0313b76aec..e5831376f2 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -94,7 +94,7 @@ if ($quiz_showbreaks > -1) { $thispageurl->param('showbreaks', $quiz_showbreaks); } else { - $quiz_showbreaks = ($CFG->quiz_questionsperpage < 2) ? 0 : 1; + $quiz_showbreaks = get_config('quiz', 'questionsperpage') > 1; } if ($quiz_reordertool != 0) { $thispageurl->param('reordertool', $quiz_reordertool); diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 6492cd9702..3d966e5cea 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -15,6 +15,16 @@ require_once($CFG->libdir.'/eventslib.php'); /// CONSTANTS /////////////////////////////////////////////////////////////////// +/**#@+ + * Options determining how the grades from individual attempts are combined to give + * the overall grade for a user + */ +define("QUIZ_GRADEHIGHEST", "1"); +define("QUIZ_GRADEAVERAGE", "2"); +define("QUIZ_ATTEMPTFIRST", "3"); +define("QUIZ_ATTEMPTLAST", "4"); +/**#@-*/ + /**#@+ * The different review options are stored in the bits of $quiz->review * These constants help to extract the options @@ -459,6 +469,16 @@ function quiz_grade_item_delete($quiz) { return grade_update('mod/quiz', $quiz->course, 'mod', 'quiz', $quiz->id, 0, NULL, array('deleted'=>1)); } +/** + * @return the options for calculating the quiz grade from the individual attempt grades. + */ +function quiz_get_grading_options() { + return array ( + QUIZ_GRADEHIGHEST => get_string('gradehighest', 'quiz'), + QUIZ_GRADEAVERAGE => get_string('gradeaverage', 'quiz'), + QUIZ_ATTEMPTFIRST => get_string('attemptfirst', 'quiz'), + QUIZ_ATTEMPTLAST => get_string('attemptlast', 'quiz')); +} function quiz_get_participants($quizid) { /// Returns an array of users who have data in a given quiz diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index 457e6f9532..61565909ed 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -31,16 +31,6 @@ require_once($CFG->libdir . '/eventslib.php'); /// Constants /////////////////////////////////////////////////////////////////// -/**#@+ - * Options determining how the grades from individual attempts are combined to give - * the overall grade for a user - */ -define("QUIZ_GRADEHIGHEST", "1"); -define("QUIZ_GRADEAVERAGE", "2"); -define("QUIZ_ATTEMPTFIRST", "3"); -define("QUIZ_ATTEMPTLAST", "4"); -/**#@-*/ - /**#@+ * Constants to describe the various states a quiz attempt can be in. */ @@ -649,17 +639,6 @@ function quiz_calculate_best_attempt($quiz, $attempts) { } } -/** - * @return the options for calculating the quiz grade from the individual attempt grades. - */ -function quiz_get_grading_options() { - return array ( - QUIZ_GRADEHIGHEST => get_string('gradehighest', 'quiz'), - QUIZ_GRADEAVERAGE => get_string('gradeaverage', 'quiz'), - QUIZ_ATTEMPTFIRST => get_string('attemptfirst', 'quiz'), - QUIZ_ATTEMPTLAST => get_string('attemptlast', 'quiz')); -} - /** * @param int $option one of the values QUIZ_GRADEHIGHEST, QUIZ_GRADEAVERAGE, QUIZ_ATTEMPTFIRST or QUIZ_ATTEMPTLAST. * @return the lang string for that option. diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index 993e9c5e99..c762193290 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -9,6 +9,7 @@ class mod_quiz_mod_form extends moodleform_mod { function definition() { global $COURSE, $CFG, $DB; + $quizconfig = get_config('quiz'); $mform =& $this->_form; //------------------------------------------------------------------------------- @@ -44,10 +45,10 @@ class mod_quiz_mod_form extends moodleform_mod { $timelimitgrprules['timelimit'][] = array(null, 'numeric', null, 'client'); $mform->addGroupRule('timelimitgrp', $timelimitgrprules); $mform->disabledIf('timelimitgrp', 'timelimitenable'); - $mform->setAdvanced('timelimitgrp', $CFG->quiz_fix_timelimit); + $mform->setAdvanced('timelimitgrp', $quizconfig->fix_timelimit); $mform->setHelpButton('timelimitgrp', array("timelimit", get_string("quiztimer","quiz"), "quiz")); - $mform->setDefault('timelimit', $CFG->quiz_timelimit); - $mform->setDefault('timelimitenable', !empty($CFG->quiz_timelimit)); + $mform->setDefault('timelimit', $quizconfig->timelimit); + $mform->setDefault('timelimitenable', !empty($quizconfig->timelimit)); //enforced time delay between quiz attempts add-on @@ -66,13 +67,13 @@ class mod_quiz_mod_form extends moodleform_mod { } $mform->addElement('select', 'delay1', get_string("delay1", "quiz"), $timedelayoptions); $mform->setHelpButton('delay1', array("timedelay1", get_string("delay1", "quiz"), "quiz")); - $mform->setAdvanced('delay1', $CFG->quiz_fix_delay1); - $mform->setDefault('delay1', $CFG->quiz_delay1); + $mform->setAdvanced('delay1', $quizconfig->fix_delay1); + $mform->setDefault('delay1', $quizconfig->delay1); $mform->addElement('select', 'delay2', get_string("delay2", "quiz"), $timedelayoptions); $mform->setHelpButton('delay2', array("timedelay2", get_string("delay2", "quiz"), "quiz")); - $mform->setAdvanced('delay2', $CFG->quiz_fix_delay2); - $mform->setDefault('delay2', $CFG->quiz_delay2); + $mform->setAdvanced('delay2', $quizconfig->fix_delay2); + $mform->setDefault('delay2', $quizconfig->delay2); //------------------------------------------------------------------------------- $mform->addElement('header', 'displayhdr', get_string('display', 'form')); @@ -84,18 +85,18 @@ class mod_quiz_mod_form extends moodleform_mod { } $mform->addElement('select', 'questionsperpage', get_string('newpageevery', 'quiz'), $perpage); $mform->setHelpButton('questionsperpage', array('questionsperpage', get_string('newpageevery', 'quiz'), 'quiz')); - $mform->setAdvanced('questionsperpage', $CFG->quiz_fix_questionsperpage); - $mform->setDefault('questionsperpage', $CFG->quiz_questionsperpage); + $mform->setAdvanced('questionsperpage', $quizconfig->fix_questionsperpage); + $mform->setDefault('questionsperpage', $quizconfig->questionsperpage); $mform->addElement('selectyesno', 'shufflequestions', get_string("shufflequestions", "quiz")); $mform->setHelpButton('shufflequestions', array("shufflequestions", get_string("shufflequestions","quiz"), "quiz")); - $mform->setAdvanced('shufflequestions', $CFG->quiz_fix_shufflequestions); - $mform->setDefault('shufflequestions', $CFG->quiz_shufflequestions); + $mform->setAdvanced('shufflequestions', $quizconfig->fix_shufflequestions); + $mform->setDefault('shufflequestions', $quizconfig->shufflequestions); $mform->addElement('selectyesno', 'shuffleanswers', get_string("shufflewithin", "quiz")); $mform->setHelpButton('shuffleanswers', array("shufflewithin", get_string("shufflewithin","quiz"), "quiz")); - $mform->setAdvanced('shuffleanswers', $CFG->quiz_fix_shuffleanswers); - $mform->setDefault('shuffleanswers', $CFG->quiz_shuffleanswers); + $mform->setAdvanced('shuffleanswers', $quizconfig->fix_shuffleanswers); + $mform->setDefault('shuffleanswers', $quizconfig->shuffleanswers); //------------------------------------------------------------------------------- $mform->addElement('header', 'attemptshdr', get_string('attempts', 'quiz')); @@ -107,31 +108,31 @@ class mod_quiz_mod_form extends moodleform_mod { } $mform->addElement('select', 'attempts', get_string("attemptsallowed", "quiz"), $attemptoptions); $mform->setHelpButton('attempts', array("attempts", get_string("attemptsallowed","quiz"), "quiz")); - $mform->setAdvanced('attempts', $CFG->quiz_fix_attempts); - $mform->setDefault('attempts', $CFG->quiz_attempts); + $mform->setAdvanced('attempts', $quizconfig->fix_attempts); + $mform->setDefault('attempts', $quizconfig->attempts); $mform->addElement('selectyesno', 'attemptonlast', get_string("eachattemptbuildsonthelast", "quiz")); $mform->setHelpButton('attemptonlast', array("repeatattempts", get_string("eachattemptbuildsonthelast", "quiz"), "quiz")); - $mform->setAdvanced('attemptonlast', $CFG->quiz_fix_attemptonlast); - $mform->setDefault('attemptonlast', $CFG->quiz_attemptonlast); + $mform->setAdvanced('attemptonlast', $quizconfig->fix_attemptonlast); + $mform->setDefault('attemptonlast', $quizconfig->attemptonlast); $mform->addElement('selectyesno', 'adaptive', get_string("adaptive", "quiz")); $mform->setHelpButton('adaptive', array("adaptive", get_string("adaptive","quiz"), "quiz")); - $mform->setAdvanced('adaptive', $CFG->quiz_fix_adaptive); - $mform->setDefault('adaptive', $CFG->quiz_optionflags & QUESTION_ADAPTIVE); + $mform->setAdvanced('adaptive', $quizconfig->fix_optionflags); + $mform->setDefault('adaptive', $quizconfig->optionflags & QUESTION_ADAPTIVE); //------------------------------------------------------------------------------- $mform->addElement('header', 'gradeshdr', get_string('grades', 'grades')); $mform->addElement('select', 'grademethod', get_string("grademethod", "quiz"), quiz_get_grading_options()); $mform->setHelpButton('grademethod', array("grademethod", get_string("grademethod","quiz"), "quiz")); - $mform->setAdvanced('grademethod', $CFG->quiz_fix_grademethod); - $mform->setDefault('grademethod', $CFG->quiz_grademethod); + $mform->setAdvanced('grademethod', $quizconfig->fix_grademethod); + $mform->setDefault('grademethod', $quizconfig->grademethod); $mform->addElement('selectyesno', 'penaltyscheme', get_string("penaltyscheme", "quiz")); $mform->setHelpButton('penaltyscheme', array("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz")); - $mform->setAdvanced('penaltyscheme', $CFG->quiz_fix_penaltyscheme); - $mform->setDefault('penaltyscheme', $CFG->quiz_penaltyscheme); + $mform->setAdvanced('penaltyscheme', $quizconfig->fix_penaltyscheme); + $mform->setDefault('penaltyscheme', $quizconfig->penaltyscheme); $options = array( 0 => '0', @@ -140,15 +141,15 @@ class mod_quiz_mod_form extends moodleform_mod { 3 => '3'); $mform->addElement('select', 'decimalpoints', get_string("decimaldigits", "quiz"), $options); $mform->setHelpButton('decimalpoints', array("decimalpoints", get_string("decimaldigits","quiz"), "quiz")); - $mform->setAdvanced('decimalpoints', $CFG->quiz_fix_decimalpoints); - $mform->setDefault('decimalpoints', $CFG->quiz_decimalpoints); + $mform->setAdvanced('decimalpoints', $quizconfig->fix_decimalpoints); + $mform->setDefault('decimalpoints', $quizconfig->decimalpoints); - $mform->addElement('hidden', 'grade', $CFG->quiz_maximumgrade); + $mform->addElement('hidden', 'grade', $quizconfig->maximumgrade); //------------------------------------------------------------------------------- $mform->addElement('header', 'reviewoptionshdr', get_string('reviewoptionsheading', 'quiz')); $mform->setHelpButton('reviewoptionshdr', array('reviewoptions', get_string('reviewoptionsheading','quiz'), 'quiz')); - $mform->setAdvanced('reviewoptionshdr', $CFG->quiz_fix_review); + $mform->setAdvanced('reviewoptionshdr', $quizconfig->fix_review); $immediatelyoptionsgrp=array(); $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'responsesimmediately', '', get_string('responses', 'quiz')); @@ -158,12 +159,12 @@ class mod_quiz_mod_form extends moodleform_mod { $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'scoreimmediately', '', get_string('scores', 'quiz')); $immediatelyoptionsgrp[] = &$mform->createElement('checkbox', 'overallfeedbackimmediately', '', get_string('overallfeedback', 'quiz')); $mform->addGroup($immediatelyoptionsgrp, 'immediatelyoptionsgrp', get_string("reviewimmediately", "quiz"), null, false); - $mform->setDefault('responsesimmediately', $CFG->quiz_review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_IMMEDIATELY); - $mform->setDefault('answersimmediately', $CFG->quiz_review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_IMMEDIATELY); - $mform->setDefault('feedbackimmediately', $CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY); - $mform->setDefault('generalfeedbackimmediately', $CFG->quiz_review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_IMMEDIATELY); - $mform->setDefault('scoreimmediately', $CFG->quiz_review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_IMMEDIATELY); - $mform->setDefault('overallfeedbackimmediately', $CFG->quiz_review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_IMMEDIATELY); + $mform->setDefault('responsesimmediately', $quizconfig->review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_IMMEDIATELY); + $mform->setDefault('answersimmediately', $quizconfig->review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_IMMEDIATELY); + $mform->setDefault('feedbackimmediately', $quizconfig->review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY); + $mform->setDefault('generalfeedbackimmediately', $quizconfig->review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_IMMEDIATELY); + $mform->setDefault('scoreimmediately', $quizconfig->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_IMMEDIATELY); + $mform->setDefault('overallfeedbackimmediately', $quizconfig->review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_IMMEDIATELY); $openoptionsgrp=array(); $openoptionsgrp[] = &$mform->createElement('checkbox', 'responsesopen', '', get_string('responses', 'quiz')); @@ -173,12 +174,12 @@ class mod_quiz_mod_form extends moodleform_mod { $openoptionsgrp[] = &$mform->createElement('checkbox', 'scoreopen', '', get_string('scores', 'quiz')); $openoptionsgrp[] = &$mform->createElement('checkbox', 'overallfeedbackopen', '', get_string('overallfeedback', 'quiz')); $mform->addGroup($openoptionsgrp, 'openoptionsgrp', get_string("reviewopen", "quiz"), array(' '), false); - $mform->setDefault('responsesopen', $CFG->quiz_review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_OPEN); - $mform->setDefault('answersopen', $CFG->quiz_review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_OPEN); - $mform->setDefault('feedbackopen', $CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN); - $mform->setDefault('generalfeedbackopen', $CFG->quiz_review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_OPEN); - $mform->setDefault('scoreopen', $CFG->quiz_review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN); - $mform->setDefault('overallfeedbackopen', $CFG->quiz_review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_OPEN); + $mform->setDefault('responsesopen', $quizconfig->review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_OPEN); + $mform->setDefault('answersopen', $quizconfig->review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_OPEN); + $mform->setDefault('feedbackopen', $quizconfig->review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN); + $mform->setDefault('generalfeedbackopen', $quizconfig->review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_OPEN); + $mform->setDefault('scoreopen', $quizconfig->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN); + $mform->setDefault('overallfeedbackopen', $quizconfig->review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_OPEN); $closedoptionsgrp=array(); @@ -189,32 +190,32 @@ class mod_quiz_mod_form extends moodleform_mod { $closedoptionsgrp[] = &$mform->createElement('checkbox', 'scoreclosed', '', get_string('scores', 'quiz')); $closedoptionsgrp[] = &$mform->createElement('checkbox', 'overallfeedbackclosed', '', get_string('overallfeedback', 'quiz')); $mform->addGroup($closedoptionsgrp, 'closedoptionsgrp', get_string("reviewclosed", "quiz"), array(' '), false); - $mform->setDefault('responsesclosed', $CFG->quiz_review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_CLOSED); - $mform->setDefault('answersclosed', $CFG->quiz_review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_CLOSED); - $mform->setDefault('feedbackclosed', $CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED); - $mform->setDefault('generalfeedbackclosed', $CFG->quiz_review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_CLOSED); - $mform->setDefault('scoreclosed', $CFG->quiz_review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED); - $mform->setDefault('overallfeedbackclosed', $CFG->quiz_review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_CLOSED); + $mform->setDefault('responsesclosed', $quizconfig->review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_CLOSED); + $mform->setDefault('answersclosed', $quizconfig->review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_CLOSED); + $mform->setDefault('feedbackclosed', $quizconfig->review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED); + $mform->setDefault('generalfeedbackclosed', $quizconfig->review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_CLOSED); + $mform->setDefault('scoreclosed', $quizconfig->review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED); + $mform->setDefault('overallfeedbackclosed', $quizconfig->review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_CLOSED); //------------------------------------------------------------------------------- $mform->addElement('header', 'security', get_string('security', 'form')); $mform->addElement('selectyesno', 'popup', get_string("popup", "quiz")); $mform->setHelpButton('popup', array("popup", get_string("popup", "quiz"), "quiz")); - $mform->setAdvanced('popup', $CFG->quiz_fix_popup); - $mform->setDefault('popup', $CFG->quiz_popup); + $mform->setAdvanced('popup', $quizconfig->fix_popup); + $mform->setDefault('popup', $quizconfig->popup); $mform->addElement('passwordunmask', 'quizpassword', get_string("requirepassword", "quiz")); $mform->setType('quizpassword', PARAM_TEXT); $mform->setHelpButton('quizpassword', array("requirepassword", get_string("requirepassword", "quiz"), "quiz")); - $mform->setAdvanced('quizpassword', $CFG->quiz_fix_password); - $mform->setDefault('quizpassword', $CFG->quiz_password); + $mform->setAdvanced('quizpassword', $quizconfig->fix_password); + $mform->setDefault('quizpassword', $quizconfig->password); $mform->addElement('text', 'subnet', get_string("requiresubnet", "quiz")); $mform->setType('subnet', PARAM_TEXT); $mform->setHelpButton('subnet', array("requiresubnet", get_string("requiresubnet", "quiz"), "quiz")); - $mform->setAdvanced('subnet', $CFG->quiz_fix_subnet); - $mform->setDefault('subnet', $CFG->quiz_subnet); + $mform->setAdvanced('subnet', $quizconfig->fix_subnet); + $mform->setDefault('subnet', $quizconfig->subnet); //------------------------------------------------------------------------------- $features = new stdClass; diff --git a/mod/quiz/reviewoptions.html b/mod/quiz/reviewoptions.html deleted file mode 100644 index 48ce800195..0000000000 --- a/mod/quiz/reviewoptions.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - -
:
:
:
:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_IMMEDIATELY) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_IMMEDIATELY) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_IMMEDIATELY) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_IMMEDIATELY) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_IMMEDIATELY) ? 'checked="checked"' : '' ?> /> -
- review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_OPEN) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_OPEN) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_OPEN) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_OPEN) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_OPEN) ? 'checked="checked"' : '' ?> /> -
- review & QUIZ_REVIEW_RESPONSES & QUIZ_REVIEW_CLOSED) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_ANSWERS & QUIZ_REVIEW_CLOSED) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_GENERALFEEDBACK & QUIZ_REVIEW_CLOSED) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_SCORES & QUIZ_REVIEW_CLOSED) ? 'checked="checked"' : '' ?> /> - - review & QUIZ_REVIEW_OVERALLFEEDBACK & QUIZ_REVIEW_CLOSED) ? 'checked="checked"' : '' ?> /> -
- - - - diff --git a/mod/quiz/settingstree.php b/mod/quiz/settingstree.php new file mode 100644 index 0000000000..671cf6e618 --- /dev/null +++ b/mod/quiz/settingstree.php @@ -0,0 +1,170 @@ +dirroot . '/mod/quiz/lib.php'); + +// First get a list of quiz reports with there own settings pages. If there none, +// we use a simpler overall menu structure. +$reportsbyname = array(); +if ($reports = get_list_of_plugins('mod/quiz/report')) { + foreach ($reports as $report) { + if (file_exists($CFG->dirroot . "/mod/quiz/report/$report/settings.php")) { + $strreportname = get_string($report . 'report', 'quiz_'.$report); + // Deal with reports which are lacking the language string + if ($strreportname[0] == '[') { + $textlib = textlib_get_instance(); + $strreportname = $textlib->strtotitle($report . ' report'); + } + $reportsbyname[$strreportname] = $report; + } + } + ksort($reportsbyname); +} + +// Create the quiz settings page. +if (empty($reportsbyname)) { + $pagetitle = get_string('modulename', 'quiz'); +} else { + $pagetitle = get_string('generalsettings', 'admin'); +} +$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'))); + +// timelimit +$quizsettings->add(new admin_setting_quiz_text('timelimit', + get_string('timelimit', 'quiz'), get_string('configtimelimit', 'quiz'), + array('value' => '0', 'fix' => false), PARAM_INT)); + +// delay1 and delay2 +$timedelayoptions = array(); +$timedelayoptions[0] = get_string('none'); +$timedelayoptions[1800] = get_string('numminutes', '', 30); +$timedelayoptions[3600] = get_string('numminutes', '', 60); +for($i=2; $i<=23; $i++) { + $seconds = $i*3600; + $timedelayoptions[$seconds] = get_string('numhours', '', $i); +} +$timedelayoptions[86400] = get_string('numhours', '', 24); +for($i=2; $i<=7; $i++) { + $seconds = $i*86400; + $timedelayoptions[$seconds] = get_string('numdays', '', $i); +} +$quizsettings->add(new admin_setting_quiz_combo('delay1', + get_string('delay1', 'quiz'), get_string('configdelay1', 'quiz'), + array('value' => 0, 'fix' => false), $timedelayoptions)); +$quizsettings->add(new admin_setting_quiz_combo('delay2', + get_string('delay2', 'quiz'), get_string('configdelay2', 'quiz'), + array('value' => 0, 'fix' => false), $timedelayoptions)); + +// questionsperpage +$perpage = array(); +$perpage[0] = get_string('never'); +$perpage[1] = get_string('aftereachquestion', 'quiz'); +for ($i = 2; $i <= 50; ++$i) { + $perpage[$i] = get_string('afternquestions', 'quiz', $i); +} +$quizsettings->add(new admin_setting_quiz_combo('questionsperpage', + get_string('newpageevery', 'quiz'), get_string('confignewpageevery', 'quiz'), + array('value' => 1, 'fix' => false), $perpage)); + +// shufflequestions +$quizsettings->add(new admin_setting_quiz_yesno('shufflequestions', + get_string('shufflequestions', 'quiz'), get_string('configshufflequestions', 'quiz'), + array('value' => 0, 'fix' => false))); + +// shuffleanswers +$quizsettings->add(new admin_setting_quiz_yesno('shuffleanswers', + get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'), + array('value' => 1, 'fix' => false))); + +// attempts +$options = array(get_string('unlimited')); +for ($i = 1; $i <= 6; $i++) { + $options[$i] = $i; +} +$quizsettings->add(new admin_setting_quiz_combo('attempts', + get_string('attemptsallowed', 'quiz'), get_string('configattemptsallowed', 'quiz'), + array('value' => 0, 'fix' => false), $options)); + +// attemptonlast +$quizsettings->add(new admin_setting_quiz_yesno('attemptonlast', + get_string('eachattemptbuildsonthelast', 'quiz'), get_string('configeachattemptbuildsonthelast', 'quiz'), + array('value' => 0, 'fix' => false))); + +// optionflags +$quizsettings->add(new admin_setting_quiz_yesno('optionflags', + get_string('adaptive', 'quiz'), get_string('configadaptive', 'quiz'), + array('value' => 1, 'fix' => false))); + +// maximumgrade +$maxgradesetting = new admin_setting_configtext('maximumgrade', + get_string('maximumgrade'), get_string('configmaximumgrade', 'quiz'), 10, PARAM_INT); +$maxgradesetting->plugin = 'quiz'; +$quizsettings->add($maxgradesetting); + +// grademethod +$quizsettings->add(new admin_setting_quiz_combo('grademethod', + get_string('grademethod', 'quiz'), get_string('configgrademethod', 'quiz'), + array('value' => QUIZ_GRADEHIGHEST, 'fix' => false), quiz_get_grading_options())); + +// penaltyscheme +$quizsettings->add(new admin_setting_quiz_yesno('penaltyscheme', + get_string('penaltyscheme', 'quiz'), get_string('configpenaltyscheme', 'quiz'), + array('value' => 1, 'fix' => false))); + +// decimalpoints +$options = array(); +for ($i = 0; $i <= 5; $i++) { + $options[$i] = $i; +} +$quizsettings->add(new admin_setting_quiz_combo('decimalpoints', + get_string('decimaldigits', 'quiz'), get_string('configdecimaldigits', 'quiz'), + array('value' => 2, 'fix' => false), $options)); + +// review +$quizsettings->add(new admin_setting_quiz_reviewoptions('review', + get_string('reviewoptions', 'quiz'), get_string('configreviewoptions', 'quiz'), + array('value' => 0x3fffffff, 'fix' => false))); + +// popup +$quizsettings->add(new admin_setting_quiz_yesno('popup', + get_string('popup', 'quiz'), get_string('configpopup', 'quiz'), + array('value' => 0, 'fix' => false))); + +// quizpassword +$quizsettings->add(new admin_setting_quiz_text('password', + get_string('requirepassword', 'quiz'), get_string('configrequirepassword', 'quiz'), + array('value' => '', 'fix' => false), PARAM_TEXT)); + +// subnet +$quizsettings->add(new admin_setting_quiz_text('subnet', + get_string('requiresubnet', 'quiz'), get_string('configrequiresubnet', 'quiz'), + array('value' => '', 'fix' => false), PARAM_TEXT)); + +/// 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)) { + $ADMIN->add('modsettings', $quizsettings); +} else { + $ADMIN->add('modsettings', new admin_category('modsettingsquizcat', get_string('modulename', 'quiz'), !$module->visible)); + $ADMIN->add('modsettingsquizcat', $quizsettings); + +/// Add the report pages for the settings.php files in sub directories of mod/quiz/report + foreach ($reportsbyname as $strreportname => $report) { + $reportname = $report; + $settings = new admin_settingpage('modsettingsquizcat'.$reportname, $strreportname, 'moodle/site:config', !$module->visible); + if ($ADMIN->fulltree) { + include($CFG->dirroot."/mod/quiz/report/$reportname/settings.php"); + } + $ADMIN->add('modsettingsquizcat', $settings); + } +} +?> diff --git a/mod/quiz/version.php b/mod/quiz/version.php index 5d214239f9..a4756d62f1 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -5,7 +5,7 @@ // This fragment is called by moodle_needs_upgrading() and /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2008081507; // The (date) version of this module +$module->version = 2008082200; // The (date) version of this module $module->requires = 2008072401; // Requires this Moodle version $module->cron = 0; // How often should cron check this module (seconds)? diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index ca64e01c2f..5a4cdf6dab 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -3954,28 +3954,37 @@ table.quizreviewsummary td.cell { text-align: left; } -#mod-quiz-mod #reviewoptionshdr .fitem { +#mod-quiz-mod #reviewoptionshdr .fitem, +#adminquizreviewoptions .group { float: left; + width: 33%; + clear: none; +} +#mod-quiz-mod #reviewoptionshdr .fitem { width: 30%; margin-left: 10px; - clear: none; } -#mod-quiz-mod #reviewoptionshdr .fitemtitle { +#mod-quiz-mod #reviewoptionshdr .fitemtitle, +#adminquizreviewoptions .fitemtitle { width: 100%; font-weight: bold; text-align: left; height: 2.5em; - margin-left: 0; + margin-left: 0; } #mod-quiz-mod #reviewoptionshdr fieldset.fgroup { width: 100%; text-align: left; - margin-left: 0; + margin-left: 0; } -#mod-quiz-mod #reviewoptionshdr fieldset.fgroup span { +#mod-quiz-mod #reviewoptionshdr fieldset.fgroup span, +#adminquizreviewoptions span { float: left; clear: left; } +#adminquizreviewoptions { + margin-bottom: 0.5em; +} #mod-quiz-edit #page .controls, #mod-quiz-edit #page .quizattemptcounts -- 2.39.5