Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 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 use mod_quiz\admin\review_setting; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 require_once($CFG->dirroot . '/mod/quiz/lib.php'); 30 31 // First get a list of quiz reports with there own settings pages. If there none, 32 // we use a simpler overall menu structure. 33 $reports = core_component::get_plugin_list_with_file('quiz', 'settings.php', false); 34 $reportsbyname = []; 35 foreach ($reports as $report => $reportdir) { 36 $strreportname = get_string($report . 'report', 'quiz_'.$report); 37 $reportsbyname[$strreportname] = $report; 38 } 39 core_collator::ksort($reportsbyname); 40 41 // First get a list of quiz reports with there own settings pages. If there none, 42 // we use a simpler overall menu structure. 43 $rules = core_component::get_plugin_list_with_file('quizaccess', 'settings.php', false); 44 $rulesbyname = []; 45 foreach ($rules as $rule => $ruledir) { 46 $strrulename = get_string('pluginname', 'quizaccess_' . $rule); 47 $rulesbyname[$strrulename] = $rule; 48 } 49 core_collator::ksort($rulesbyname); 50 51 // Create the quiz settings page. 52 if (empty($reportsbyname) && empty($rulesbyname)) { 53 $pagetitle = get_string('modulename', 'quiz'); 54 } else { 55 $pagetitle = get_string('generalsettings', 'admin'); 56 } 57 $quizsettings = new admin_settingpage('modsettingquiz', $pagetitle, 'moodle/site:config'); 58 59 if ($ADMIN->fulltree) { 60 // Introductory explanation that all the settings are defaults for the add quiz form. 61 $quizsettings->add(new admin_setting_heading('quizintro', '', get_string('configintro', 'quiz'))); 62 63 // Time limit. 64 $setting = new admin_setting_configduration('quiz/timelimit', 65 get_string('timelimit', 'quiz'), get_string('configtimelimitsec', 'quiz'), 66 '0', 60); 67 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 68 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 69 $quizsettings->add($setting); 70 71 // Delay to notify graded attempts. 72 $quizsettings->add(new admin_setting_configduration('quiz/notifyattemptgradeddelay', 73 get_string('attemptgradeddelay', 'quiz'), get_string('attemptgradeddelay_desc', 'quiz'), 5 * HOURSECS, HOURSECS)); 74 75 // What to do with overdue attempts. 76 $setting = new \mod_quiz\admin\overdue_handling_setting('quiz/overduehandling', 77 get_string('overduehandling', 'quiz'), get_string('overduehandling_desc', 'quiz'), 78 ['value' => 'autosubmit', 'adv' => false], null); 79 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 80 $quizsettings->add($setting); 81 82 // Grace period time. 83 $setting = new admin_setting_configduration('quiz/graceperiod', 84 get_string('graceperiod', 'quiz'), get_string('graceperiod_desc', 'quiz'), 85 '86400'); 86 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 87 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 88 $quizsettings->add($setting); 89 90 // Minimum grace period used behind the scenes. 91 $quizsettings->add(new admin_setting_configduration('quiz/graceperiodmin', 92 get_string('graceperiodmin', 'quiz'), get_string('graceperiodmin_desc', 'quiz'), 93 60, 1)); 94 95 // Number of attempts. 96 $options = [get_string('unlimited')]; 97 for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) { 98 $options[$i] = $i; 99 } 100 $setting = new admin_setting_configselect('quiz/attempts', 101 get_string('attemptsallowed', 'quiz'), get_string('configattemptsallowed', 'quiz'), 102 0, $options); 103 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 104 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 105 $quizsettings->add($setting); 106 107 // Grading method. 108 $setting = new \mod_quiz\admin\grade_method_setting('quiz/grademethod', 109 get_string('grademethod', 'quiz'), get_string('configgrademethod', 'quiz'), 110 ['value' => QUIZ_GRADEHIGHEST, 'adv' => false], null); 111 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 112 $quizsettings->add($setting); 113 114 // Maximum grade. 115 $setting = new admin_setting_configtext('quiz/maximumgrade', 116 get_string('maximumgrade'), get_string('configmaximumgrade', 'quiz'), 10, PARAM_INT); 117 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 118 $quizsettings->add($setting); 119 120 // Questions per page. 121 $perpage = []; 122 $perpage[0] = get_string('never'); 123 $perpage[1] = get_string('aftereachquestion', 'quiz'); 124 for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) { 125 $perpage[$i] = get_string('afternquestions', 'quiz', $i); 126 } 127 $setting = new admin_setting_configselect('quiz/questionsperpage', 128 get_string('newpageevery', 'quiz'), get_string('confignewpageevery', 'quiz'), 129 1, $perpage); 130 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 131 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 132 $quizsettings->add($setting); 133 134 // Navigation method. 135 $setting = new admin_setting_configselect('quiz/navmethod', 136 get_string('navmethod', 'quiz'), get_string('confignavmethod', 'quiz'), 137 QUIZ_NAVMETHOD_FREE, quiz_get_navigation_options()); 138 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 139 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 140 $quizsettings->add($setting); 141 142 // Shuffle within questions. 143 $setting = new admin_setting_configcheckbox('quiz/shuffleanswers', 144 get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'), 145 1); 146 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 147 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 148 $quizsettings->add($setting); 149 150 // Preferred behaviour. 151 $setting = new admin_setting_question_behaviour('quiz/preferredbehaviour', 152 get_string('howquestionsbehave', 'question'), get_string('howquestionsbehave_desc', 'quiz'), 153 'deferredfeedback'); 154 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 155 $quizsettings->add($setting); 156 157 // Can redo completed questions. 158 $setting = new admin_setting_configselect('quiz/canredoquestions', 159 get_string('canredoquestions', 'quiz'), get_string('canredoquestions_desc', 'quiz'), 160 0, 161 [0 => get_string('no'), 1 => get_string('canredoquestionsyes', 'quiz')]); 162 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 163 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 164 $quizsettings->add($setting); 165 166 // Each attempt builds on last. 167 $setting = new admin_setting_configcheckbox('quiz/attemptonlast', 168 get_string('eachattemptbuildsonthelast', 'quiz'), 169 get_string('configeachattemptbuildsonthelast', 'quiz'), 170 0); 171 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 172 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 173 $quizsettings->add($setting); 174 175 // Review options. 176 $quizsettings->add(new admin_setting_heading('reviewheading', 177 get_string('reviewoptionsheading', 'quiz'), '')); 178 foreach (review_setting::fields() as $field => $name) { 179 $default = review_setting::all_on(); 180 $forceduring = null; 181 if ($field == 'attempt') { 182 $forceduring = true; 183 } else if ($field == 'overallfeedback') { 184 $default = $default ^ review_setting::DURING; 185 $forceduring = false; 186 } 187 $quizsettings->add(new review_setting('quiz/review' . $field, 188 $name, '', $default, $forceduring)); 189 } 190 191 // Show the user's picture. 192 $setting = new \mod_quiz\admin\user_image_setting('quiz/showuserpicture', 193 get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'), 194 ['value' => 0, 'adv' => false], null); 195 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 196 $quizsettings->add($setting); 197 198 // Decimal places for overall grades. 199 $options = []; 200 for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) { 201 $options[$i] = $i; 202 } 203 $setting = new admin_setting_configselect('quiz/decimalpoints', 204 get_string('decimalplaces', 'quiz'), get_string('configdecimalplaces', 'quiz'), 205 2, $options); 206 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 207 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 208 $quizsettings->add($setting); 209 210 // Decimal places for question grades. 211 $options = [-1 => get_string('sameasoverall', 'quiz')]; 212 for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) { 213 $options[$i] = $i; 214 } 215 $setting = new admin_setting_configselect('quiz/questiondecimalpoints', 216 get_string('decimalplacesquestion', 'quiz'), 217 get_string('configdecimalplacesquestion', 'quiz'), 218 -1, $options); 219 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 220 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 221 $quizsettings->add($setting); 222 223 // Show blocks during quiz attempts. 224 $setting = new admin_setting_configcheckbox('quiz/showblocks', 225 get_string('showblocks', 'quiz'), get_string('configshowblocks', 'quiz'), 226 0); 227 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 228 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 229 $quizsettings->add($setting); 230 231 // Password. 232 $setting = new admin_setting_configpasswordunmask('quiz/quizpassword', 233 get_string('requirepassword', 'quiz'), get_string('configrequirepassword', 'quiz'), 234 ''); 235 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false); 236 $setting->set_required_flag_options(admin_setting_flag::ENABLED, false); 237 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 238 $quizsettings->add($setting); 239 240 // IP restrictions. 241 $setting = new admin_setting_configtext('quiz/subnet', 242 get_string('requiresubnet', 'quiz'), get_string('configrequiresubnet', 'quiz'), 243 '', PARAM_TEXT); 244 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 245 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 246 $quizsettings->add($setting); 247 248 // Enforced delay between attempts. 249 $setting = new admin_setting_configduration('quiz/delay1', 250 get_string('delay1st2nd', 'quiz'), get_string('configdelay1st2nd', 'quiz'), 251 0, 60); 252 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 253 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 254 $quizsettings->add($setting); 255 $setting = new admin_setting_configduration('quiz/delay2', 256 get_string('delaylater', 'quiz'), get_string('configdelaylater', 'quiz'), 257 0, 60); 258 $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true); 259 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 260 $quizsettings->add($setting); 261 262 // Browser security. 263 $setting = new \mod_quiz\admin\browser_security_setting('quiz/browsersecurity', 264 get_string('showinsecurepopup', 'quiz'), get_string('configpopup', 'quiz'), 265 ['value' => '-', 'adv' => true], null); 266 $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false); 267 $quizsettings->add($setting); 268 269 $quizsettings->add(new admin_setting_configtext('quiz/initialnumfeedbacks', 270 get_string('initialnumfeedbacks', 'quiz'), get_string('initialnumfeedbacks_desc', 'quiz'), 271 2, PARAM_INT, 5)); 272 273 // Allow user to specify if setting outcomes is an advanced setting. 274 if (!empty($CFG->enableoutcomes)) { 275 $quizsettings->add(new admin_setting_configcheckbox('quiz/outcomes_adv', 276 get_string('outcomesadvanced', 'quiz'), get_string('configoutcomesadvanced', 'quiz'), 277 '0')); 278 } 279 280 // Autosave frequency. 281 $quizsettings->add(new admin_setting_configduration('quiz/autosaveperiod', 282 get_string('autosaveperiod', 'quiz'), get_string('autosaveperiod_desc', 'quiz'), 60, 1)); 283 } 284 285 // Now, depending on whether any reports have their own settings page, add 286 // the quiz setting page to the appropriate place in the tree. 287 if (empty($reportsbyname) && empty($rulesbyname)) { 288 $ADMIN->add('modsettings', $quizsettings); 289 } else { 290 $ADMIN->add('modsettings', new admin_category('modsettingsquizcat', 291 get_string('modulename', 'quiz'), $module->is_enabled() === false)); 292 $ADMIN->add('modsettingsquizcat', $quizsettings); 293 294 // Add settings pages for the quiz report subplugins. 295 foreach ($reportsbyname as $strreportname => $report) { 296 $reportname = $report; 297 298 $settings = new admin_settingpage('modsettingsquizcat'.$reportname, 299 $strreportname, 'moodle/site:config', $module->is_enabled() === false); 300 include($CFG->dirroot . "/mod/quiz/report/$reportname/settings.php"); 301 if (!empty($settings)) { 302 $ADMIN->add('modsettingsquizcat', $settings); 303 } 304 } 305 306 // Add settings pages for the quiz access rule subplugins. 307 foreach ($rulesbyname as $strrulename => $rule) { 308 $settings = new admin_settingpage('modsettingsquizcat' . $rule, 309 $strrulename, 'moodle/site:config', $module->is_enabled() === false); 310 include($CFG->dirroot . "/mod/quiz/accessrule/$rule/settings.php"); 311 if (!empty($settings)) { 312 $ADMIN->add('modsettingsquizcat', $settings); 313 } 314 } 315 } 316 317 $settings = null; // We do not want standard settings link.
title
Description
Body
title
Description
Body
title
Description
Body
title
Body