MDL-19668 renaming textbox and select elements
[moodle.git] / mod / quiz / settingstree.php
CommitLineData
e2249afe 1<?php // $Id$
2/**
3 * settingstree.php - Tells the admin menu that there are sub menu pages to
4 * include for this activity.
5 *
6 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
7 * @package quiz
8 */
9
10require_once($CFG->dirroot . '/mod/quiz/lib.php');
7fb0303d 11require_once($CFG->dirroot . '/mod/quiz/settingslib.php');
e2249afe 12
13// First get a list of quiz reports with there own settings pages. If there none,
14// we use a simpler overall menu structure.
15$reportsbyname = array();
17da2e6f 16if ($reports = get_plugin_list('quiz')) {
17 foreach ($reports as $report => $reportdir) {
18 if (file_exists("$reportdir/settings.php")) {
e2249afe 19 $strreportname = get_string($report . 'report', 'quiz_'.$report);
20 // Deal with reports which are lacking the language string
21 if ($strreportname[0] == '[') {
22 $textlib = textlib_get_instance();
23 $strreportname = $textlib->strtotitle($report . ' report');
24 }
25 $reportsbyname[$strreportname] = $report;
26 }
27 }
28 ksort($reportsbyname);
29}
30
31// Create the quiz settings page.
32if (empty($reportsbyname)) {
33 $pagetitle = get_string('modulename', 'quiz');
34} else {
35 $pagetitle = get_string('generalsettings', 'admin');
36}
37$quizsettings = new admin_settingpage('modsettingquiz', $pagetitle, 'moodle/site:config');
38
39// Introductory explanation that all the settings are defaults for the add quiz form.
40$quizsettings->add(new admin_setting_heading('quizintro', '', get_string('configintro', 'quiz')));
41
84e628a0 42// Time limit
c304d581 43$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/timelimit',
84e628a0 44 get_string('timelimitsec', 'quiz'), get_string('configtimelimitsec', 'quiz'),
e2249afe 45 array('value' => '0', 'fix' => false), PARAM_INT));
46
84e628a0 47// Number of attempts
48$options = array(get_string('unlimited'));
49for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
50 $options[$i] = $i;
e2249afe 51}
c304d581 52$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/attempts',
84e628a0 53 get_string('attemptsallowed', 'quiz'), get_string('configattemptsallowed', 'quiz'),
54 array('value' => 0, 'fix' => false), $options));
55
56// Grading method.
c304d581 57$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/grademethod',
84e628a0 58 get_string('grademethod', 'quiz'), get_string('configgrademethod', 'quiz'),
59 array('value' => QUIZ_GRADEHIGHEST, 'fix' => false), quiz_get_grading_options()));
60
61// Maximum grade
62$quizsettings->add(new admin_setting_configtext('quiz/maximumgrade',
63 get_string('maximumgrade'), get_string('configmaximumgrade', 'quiz'), 10, PARAM_INT));
64
65// Shuffle questions
66$quizsettings->add(new admin_setting_yesno_with_advanced('quiz/shufflequestions',
67 get_string('shufflequestions', 'quiz'), get_string('configshufflequestions', 'quiz'),
68 array('value' => 0, 'fix' => false)));
69
70// Questions per page
e2249afe 71$perpage = array();
72$perpage[0] = get_string('never');
73$perpage[1] = get_string('aftereachquestion', 'quiz');
84e628a0 74for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
e2249afe 75 $perpage[$i] = get_string('afternquestions', 'quiz', $i);
76}
c304d581 77$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questionsperpage',
e2249afe 78 get_string('newpageevery', 'quiz'), get_string('confignewpageevery', 'quiz'),
79 array('value' => 1, 'fix' => false), $perpage));
80
84e628a0 81// Shuffle within questions
7fb0303d 82$quizsettings->add(new admin_setting_yesno_with_advanced('quiz/shuffleanswers',
e2249afe 83 get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'),
84 array('value' => 1, 'fix' => false)));
85
84e628a0 86// Adaptive mode.
7fb0303d 87$quizsettings->add(new admin_setting_yesno_with_advanced('quiz/optionflags',
e2249afe 88 get_string('adaptive', 'quiz'), get_string('configadaptive', 'quiz'),
89 array('value' => 1, 'fix' => false)));
90
84e628a0 91// Apply penalties.
7fb0303d 92$quizsettings->add(new admin_setting_yesno_with_advanced('quiz/penaltyscheme',
e2249afe 93 get_string('penaltyscheme', 'quiz'), get_string('configpenaltyscheme', 'quiz'),
84e628a0 94 array('value' => 1, 'fix' => true)));
95
96// Each attempt builds on last.
97$quizsettings->add(new admin_setting_yesno_with_advanced('quiz/attemptonlast',
98 get_string('eachattemptbuildsonthelast', 'quiz'), get_string('configeachattemptbuildsonthelast', 'quiz'),
99 array('value' => 0, 'fix' => true)));
100
101// Review options.
102$quizsettings->add(new admin_setting_quiz_reviewoptions('quiz/review',
103 get_string('reviewoptions', 'quiz'), get_string('configreviewoptions', 'quiz'),
104 array('value' => QUIZ_REVIEW_IMMEDIATELY | QUIZ_REVIEW_OPEN | QUIZ_REVIEW_CLOSED, 'fix' => false)));
105
106// Show the user's picture
107$quizsettings->add(new admin_setting_yesno_with_advanced('quiz/showuserpicture',
108 get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'),
109 array('value' => 0, 'fix' => false)));
e2249afe 110
84e628a0 111// Decimal places for overall grades.
e2249afe 112$options = array();
84e628a0 113for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) {
e2249afe 114 $options[$i] = $i;
115}
c304d581 116$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/decimalpoints',
84e628a0 117 get_string('decimalplaces', 'quiz'), get_string('configdecimalplaces', 'quiz'),
e2249afe 118 array('value' => 2, 'fix' => false), $options));
119
84e628a0 120// Decimal places for question grades.
121$options = array(-1 => get_string('sameasoverall', 'quiz'));
122for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) {
123 $options[$i] = $i;
124}
c304d581 125$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questiondecimalpoints',
84e628a0 126 get_string('decimalplacesquestion', 'quiz'), get_string('configdecimalplacesquestion', 'quiz'),
127 array('value' => -1, 'fix' => true), $options));
e2249afe 128
84e628a0 129// Password.
c304d581 130$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/password',
e2249afe 131 get_string('requirepassword', 'quiz'), get_string('configrequirepassword', 'quiz'),
84e628a0 132 array('value' => '', 'fix' => true), PARAM_TEXT));
e2249afe 133
84e628a0 134// IP restrictions.
c304d581 135$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/subnet',
e2249afe 136 get_string('requiresubnet', 'quiz'), get_string('configrequiresubnet', 'quiz'),
84e628a0 137 array('value' => '', 'fix' => true), PARAM_TEXT));
138
139// Enforced delay between attempts.
c304d581 140$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay1',
84e628a0 141 get_string('delay1st2nd', 'quiz'), get_string('configdelay1st2nd', 'quiz'),
142 array('value' => 0, 'fix' => true), PARAM_INTEGER));
c304d581 143$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay2',
84e628a0 144 get_string('delaylater', 'quiz'), get_string('configdelaylater', 'quiz'),
145 array('value' => 0, 'fix' => true), PARAM_INTEGER));
146
147// 'Secure' window.
148$quizsettings->add(new admin_setting_yesno_with_advanced('quiz/popup',
149 get_string('showinsecurepopup', 'quiz'), get_string('configpopup', 'quiz'),
150 array('value' => 0, 'fix' => true)));
e2249afe 151
152/// Now, depending on whether any reports have their own settings page, add
153/// the quiz setting page to the appropriate place in the tree.
154if (empty($reportsbyname)) {
155 $ADMIN->add('modsettings', $quizsettings);
156} else {
157 $ADMIN->add('modsettings', new admin_category('modsettingsquizcat', get_string('modulename', 'quiz'), !$module->visible));
158 $ADMIN->add('modsettingsquizcat', $quizsettings);
159
160/// Add the report pages for the settings.php files in sub directories of mod/quiz/report
161 foreach ($reportsbyname as $strreportname => $report) {
162 $reportname = $report;
163 $settings = new admin_settingpage('modsettingsquizcat'.$reportname, $strreportname, 'moodle/site:config', !$module->visible);
164 if ($ADMIN->fulltree) {
165 include($CFG->dirroot."/mod/quiz/report/$reportname/settings.php");
166 }
167 $ADMIN->add('modsettingsquizcat', $settings);
168 }
169}