Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Administration settings definitions for the quiz module. 19 * 20 * @package mod_quiz 21 * @copyright 2010 Petr Skoda 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 require_once($CFG->dirroot . '/mod/quiz/lib.php'); 29 30 // First get a list of quiz reports with there own settings pages. If there none, 31 // we use a simpler overall menu structure. 32 $reports = core_component::get_plugin_list_with_file('quiz', 'settings.php', false); 33 $reportsbyname = array(); 34 foreach ($reports as $report => $reportdir) { 35 $strreportname = get_string($report . 'report', 'quiz_'.$report); 36 $reportsbyname[$strreportname] = $report; 37 } 38 core_collator::ksort($reportsbyname); 39 40 // First get a list of quiz reports with there own settings pages. If there none, 41 // we use a simpler overall menu structure. 42 $rules = core_component::get_plugin_list_with_file('quizaccess', 'settings.php', false); 43 $rulesbyname = array(); 44 foreach ($rules as $rule => $ruledir) { 45 $strrulename = get_string('pluginname', 'quizaccess_' . $rule); 46 $rulesbyname[$strrulename] = $rule; 47 } 48 core_collator::ksort($rulesbyname); 49 50 // Create the quiz settings page. 51 if (empty($reportsbyname) && empty($rulesbyname)) { 52 $pagetitle = get_string('modulename', 'quiz'); 53 } else { 54 $pagetitle = get_string('generalsettings', 'admin'); 55 } 56 $quizsettings = new admin_settingpage('modsettingquiz', $pagetitle, 'moodle/site:config'); 57 58 if ($ADMIN->fulltree) { 59 // Introductory explanation that all the settings are defaults for the add quiz form. 60 $quizsettings->add(new admin_setting_heading('quizintro', '', get_string('configintro', 'quiz'))); 61 62 // Time limit. 63 $setting = new admin_setting_configduration('quiz/timelimit', 64 get_string('timelimit', 'quiz'), get_string('configtimelimitsec', 'quiz'), 65 '0', 60); 66 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 67 $quizsettings->add($setting); 68 69 // What to do with overdue attempts. 70 $quizsettings->add(new mod_quiz_admin_setting_overduehandling('quiz/overduehandling', 71 get_string('overduehandling', 'quiz'), get_string('overduehandling_desc', 'quiz'), 72 array('value' => 'autosubmit', 'adv' => false), null)); 73 74 // Grace period time. 75 $setting = new admin_setting_configduration('quiz/graceperiod', 76 get_string('graceperiod', 'quiz'), get_string('graceperiod_desc', 'quiz'), 77 '86400'); 78 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 79 $quizsettings->add($setting); 80 81 // Minimum grace period used behind the scenes. 82 $quizsettings->add(new admin_setting_configduration('quiz/graceperiodmin', 83 get_string('graceperiodmin', 'quiz'), get_string('graceperiodmin_desc', 'quiz'), 84 60, 1)); 85 86 // Number of attempts. 87 $options = array(get_string('unlimited')); 88 for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) { 89 $options[$i] = $i; 90 } 91 $setting = new admin_setting_configselect('quiz/attempts', 92 get_string('attemptsallowed', 'quiz'), get_string('configattemptsallowed', 'quiz'), 93 0, $options); 94 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 95 $quizsettings->add($setting); 96 97 // Grading method. 98 $quizsettings->add(new mod_quiz_admin_setting_grademethod('quiz/grademethod', 99 get_string('grademethod', 'quiz'), get_string('configgrademethod', 'quiz'), 100 array('value' => QUIZ_GRADEHIGHEST, 'adv' => false), null)); 101 102 // Maximum grade. 103 $quizsettings->add(new admin_setting_configtext('quiz/maximumgrade', 104 get_string('maximumgrade'), get_string('configmaximumgrade', 'quiz'), 10, PARAM_INT)); 105 106 // Questions per page. 107 $perpage = array(); 108 $perpage[0] = get_string('never'); 109 $perpage[1] = get_string('aftereachquestion', 'quiz'); 110 for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) { 111 $perpage[$i] = get_string('afternquestions', 'quiz', $i); 112 } 113 $setting = new admin_setting_configselect('quiz/questionsperpage', 114 get_string('newpageevery', 'quiz'), get_string('confignewpageevery', 'quiz'), 115 1, $perpage); 116 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 117 $quizsettings->add($setting); 118 119 // Navigation method. 120 $setting = new admin_setting_configselect('quiz/navmethod', 121 get_string('navmethod', 'quiz'), get_string('confignavmethod', 'quiz'), 122 QUIZ_NAVMETHOD_FREE, quiz_get_navigation_options()); 123 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 124 $quizsettings->add($setting); 125 126 // Shuffle within questions. 127 $setting = new admin_setting_configcheckbox('quiz/shuffleanswers', 128 get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'), 129 1); 130 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 131 $quizsettings->add($setting); 132 133 // Preferred behaviour. 134 $quizsettings->add(new admin_setting_question_behaviour('quiz/preferredbehaviour', 135 get_string('howquestionsbehave', 'question'), get_string('howquestionsbehave_desc', 'quiz'), 136 'deferredfeedback')); 137 138 // Can redo completed questions. 139 $setting = new admin_setting_configselect('quiz/canredoquestions', 140 get_string('canredoquestions', 'quiz'), get_string('canredoquestions_desc', 'quiz'), 141 0, 142 array(0 => get_string('no'), 1 => get_string('canredoquestionsyes', 'quiz'))); 143 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 144 $quizsettings->add($setting); 145 146 // Each attempt builds on last. 147 $setting = new admin_setting_configcheckbox('quiz/attemptonlast', 148 get_string('eachattemptbuildsonthelast', 'quiz'), 149 get_string('configeachattemptbuildsonthelast', 'quiz'), 150 0); 151 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 152 $quizsettings->add($setting); 153 154 // Review options. 155 $quizsettings->add(new admin_setting_heading('reviewheading', 156 get_string('reviewoptionsheading', 'quiz'), '')); 157 foreach (mod_quiz_admin_review_setting::fields() as $field => $name) { 158 $default = mod_quiz_admin_review_setting::all_on(); 159 $forceduring = null; 160 if ($field == 'attempt') { 161 $forceduring = true; 162 } else if ($field == 'overallfeedback') { 163 $default = $default ^ mod_quiz_admin_review_setting::DURING; 164 $forceduring = false; 165 } 166 $quizsettings->add(new mod_quiz_admin_review_setting('quiz/review' . $field, 167 $name, '', $default, $forceduring)); 168 } 169 170 // Show the user's picture. 171 $quizsettings->add(new mod_quiz_admin_setting_user_image('quiz/showuserpicture', 172 get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'), 173 array('value' => 0, 'adv' => false), null)); 174 175 // Decimal places for overall grades. 176 $options = array(); 177 for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) { 178 $options[$i] = $i; 179 } 180 $setting = new admin_setting_configselect('quiz/decimalpoints', 181 get_string('decimalplaces', 'quiz'), get_string('configdecimalplaces', 'quiz'), 182 2, $options); 183 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 184 $quizsettings->add($setting); 185 186 // Decimal places for question grades. 187 $options = array(-1 => get_string('sameasoverall', 'quiz')); 188 for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) { 189 $options[$i] = $i; 190 } 191 $setting = new admin_setting_configselect('quiz/questiondecimalpoints', 192 get_string('decimalplacesquestion', 'quiz'), 193 get_string('configdecimalplacesquestion', 'quiz'), 194 -1, $options); 195 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 196 $quizsettings->add($setting); 197 198 // Show blocks during quiz attempts. 199 $setting = new admin_setting_configcheckbox('quiz/showblocks', 200 get_string('showblocks', 'quiz'), get_string('configshowblocks', 'quiz'), 201 0); 202 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 203 $quizsettings->add($setting); 204 205 // Password. 206 $setting = new admin_setting_configpasswordunmask('quiz/quizpassword', 207 get_string('requirepassword', 'quiz'), get_string('configrequirepassword', 'quiz'), 208 ''); 209 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 210 $setting->set_required_flag_options(admin_setting_flag::ENABLED, false); 211 $quizsettings->add($setting); 212 213 // IP restrictions. 214 $setting = new admin_setting_configtext('quiz/subnet', 215 get_string('requiresubnet', 'quiz'), get_string('configrequiresubnet', 'quiz'), 216 '', PARAM_TEXT); 217 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 218 $quizsettings->add($setting); 219 220 // Enforced delay between attempts. 221 $setting = new admin_setting_configduration('quiz/delay1', 222 get_string('delay1st2nd', 'quiz'), get_string('configdelay1st2nd', 'quiz'), 223 0, 60); 224 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 225 $quizsettings->add($setting); 226 $setting = new admin_setting_configduration('quiz/delay2', 227 get_string('delaylater', 'quiz'), get_string('configdelaylater', 'quiz'), 228 0, 60); 229 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 230 $quizsettings->add($setting); 231 232 // Browser security. 233 $quizsettings->add(new mod_quiz_admin_setting_browsersecurity('quiz/browsersecurity', 234 get_string('showinsecurepopup', 'quiz'), get_string('configpopup', 'quiz'), 235 array('value' => '-', 'adv' => true), null)); 236 237 $quizsettings->add(new admin_setting_configtext('quiz/initialnumfeedbacks', 238 get_string('initialnumfeedbacks', 'quiz'), get_string('initialnumfeedbacks_desc', 'quiz'), 239 2, PARAM_INT, 5)); 240 241 // Allow user to specify if setting outcomes is an advanced setting. 242 if (!empty($CFG->enableoutcomes)) { 243 $quizsettings->add(new admin_setting_configcheckbox('quiz/outcomes_adv', 244 get_string('outcomesadvanced', 'quiz'), get_string('configoutcomesadvanced', 'quiz'), 245 '0')); 246 } 247 248 // Autosave frequency. 249 $quizsettings->add(new admin_setting_configduration('quiz/autosaveperiod', 250 get_string('autosaveperiod', 'quiz'), get_string('autosaveperiod_desc', 'quiz'), 60, 1)); 251 } 252 253 // Now, depending on whether any reports have their own settings page, add 254 // the quiz setting page to the appropriate place in the tree. 255 if (empty($reportsbyname) && empty($rulesbyname)) { 256 $ADMIN->add('modsettings', $quizsettings); 257 } else { 258 $ADMIN->add('modsettings', new admin_category('modsettingsquizcat', 259 get_string('modulename', 'quiz'), $module->is_enabled() === false)); 260 $ADMIN->add('modsettingsquizcat', $quizsettings); 261 262 // Add settings pages for the quiz report subplugins. 263 foreach ($reportsbyname as $strreportname => $report) { 264 $reportname = $report; 265 266 $settings = new admin_settingpage('modsettingsquizcat'.$reportname, 267 $strreportname, 'moodle/site:config', $module->is_enabled() === false); 268 include($CFG->dirroot . "/mod/quiz/report/$reportname/settings.php"); 269 if (!empty($settings)) { 270 $ADMIN->add('modsettingsquizcat', $settings); 271 } 272 } 273 274 // Add settings pages for the quiz access rule subplugins. 275 foreach ($rulesbyname as $strrulename => $rule) { 276 $settings = new admin_settingpage('modsettingsquizcat' . $rule, 277 $strrulename, 'moodle/site:config', $module->is_enabled() === false); 278 include($CFG->dirroot . "/mod/quiz/accessrule/$rule/settings.php"); 279 if (!empty($settings)) { 280 $ADMIN->add('modsettingsquizcat', $settings); 281 } 282 } 283 } 284 285 $settings = null; // We do not want standard settings link.
title
Description
Body
title
Description
Body
title
Description
Body
title
Body