mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 12:45:04 +01:00
MDL-45273 only create the quiz settings if necessary.
This commit is contained in:
parent
9ec7a71661
commit
8a347d8011
@ -55,169 +55,171 @@ if (empty($reportsbyname) && empty($rulesbyname)) {
|
||||
}
|
||||
$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')));
|
||||
if ($ADMIN->fulltree) {
|
||||
// Introductory explanation that all the settings are defaults for the add quiz form.
|
||||
$quizsettings->add(new admin_setting_heading('quizintro', '', get_string('configintro', 'quiz')));
|
||||
|
||||
// Time limit.
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/timelimit',
|
||||
get_string('timelimitsec', 'quiz'), get_string('configtimelimitsec', 'quiz'),
|
||||
array('value' => '0', 'adv' => false), PARAM_INT));
|
||||
// Time limit.
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/timelimit',
|
||||
get_string('timelimitsec', 'quiz'), get_string('configtimelimitsec', 'quiz'),
|
||||
array('value' => '0', 'adv' => false), PARAM_INT));
|
||||
|
||||
// What to do with overdue attempts.
|
||||
$quizsettings->add(new mod_quiz_admin_setting_overduehandling('quiz/overduehandling',
|
||||
get_string('overduehandling', 'quiz'), get_string('overduehandling_desc', 'quiz'),
|
||||
array('value' => 'autoabandon', 'adv' => false), null));
|
||||
// What to do with overdue attempts.
|
||||
$quizsettings->add(new mod_quiz_admin_setting_overduehandling('quiz/overduehandling',
|
||||
get_string('overduehandling', 'quiz'), get_string('overduehandling_desc', 'quiz'),
|
||||
array('value' => 'autoabandon', 'adv' => false), null));
|
||||
|
||||
// Grace period time.
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/graceperiod',
|
||||
get_string('graceperiod', 'quiz'), get_string('graceperiod_desc', 'quiz'),
|
||||
array('value' => '86400', 'adv' => false), PARAM_INT));
|
||||
// Grace period time.
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/graceperiod',
|
||||
get_string('graceperiod', 'quiz'), get_string('graceperiod_desc', 'quiz'),
|
||||
array('value' => '86400', 'adv' => false), PARAM_INT));
|
||||
|
||||
// Minimum grace period used behind the scenes.
|
||||
$quizsettings->add(new admin_setting_configtext('quiz/graceperiodmin',
|
||||
get_string('graceperiodmin', 'quiz'), get_string('graceperiodmin_desc', 'quiz'),
|
||||
60, PARAM_INT));
|
||||
// Minimum grace period used behind the scenes.
|
||||
$quizsettings->add(new admin_setting_configtext('quiz/graceperiodmin',
|
||||
get_string('graceperiodmin', 'quiz'), get_string('graceperiodmin_desc', 'quiz'),
|
||||
60, PARAM_INT));
|
||||
|
||||
// Number of attempts.
|
||||
$options = array(get_string('unlimited'));
|
||||
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/attempts',
|
||||
get_string('attemptsallowed', 'quiz'), get_string('configattemptsallowed', 'quiz'),
|
||||
array('value' => 0, 'adv' => false), $options));
|
||||
|
||||
// Grading method.
|
||||
$quizsettings->add(new mod_quiz_admin_setting_grademethod('quiz/grademethod',
|
||||
get_string('grademethod', 'quiz'), get_string('configgrademethod', 'quiz'),
|
||||
array('value' => QUIZ_GRADEHIGHEST, 'adv' => false), null));
|
||||
|
||||
// Maximum grade.
|
||||
$quizsettings->add(new admin_setting_configtext('quiz/maximumgrade',
|
||||
get_string('maximumgrade'), get_string('configmaximumgrade', 'quiz'), 10, PARAM_INT));
|
||||
|
||||
// Shuffle questions.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shufflequestions',
|
||||
get_string('shufflequestions', 'quiz'), get_string('configshufflequestions', 'quiz'),
|
||||
array('value' => 0, 'adv' => false)));
|
||||
|
||||
// Questions per page.
|
||||
$perpage = array();
|
||||
$perpage[0] = get_string('never');
|
||||
$perpage[1] = get_string('aftereachquestion', 'quiz');
|
||||
for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
|
||||
$perpage[$i] = get_string('afternquestions', 'quiz', $i);
|
||||
}
|
||||
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questionsperpage',
|
||||
get_string('newpageevery', 'quiz'), get_string('confignewpageevery', 'quiz'),
|
||||
array('value' => 1, 'adv' => false), $perpage));
|
||||
|
||||
// Navigation method.
|
||||
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/navmethod',
|
||||
get_string('navmethod', 'quiz'), get_string('confignavmethod', 'quiz'),
|
||||
array('value' => QUIZ_NAVMETHOD_FREE, 'adv' => true), quiz_get_navigation_options()));
|
||||
|
||||
// Shuffle within questions.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shuffleanswers',
|
||||
get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'),
|
||||
array('value' => 1, 'adv' => false)));
|
||||
|
||||
// Preferred behaviour.
|
||||
$quizsettings->add(new admin_setting_question_behaviour('quiz/preferredbehaviour',
|
||||
get_string('howquestionsbehave', 'question'), get_string('howquestionsbehave_desc', 'quiz'),
|
||||
'deferredfeedback'));
|
||||
|
||||
// Each attempt builds on last.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/attemptonlast',
|
||||
get_string('eachattemptbuildsonthelast', 'quiz'),
|
||||
get_string('configeachattemptbuildsonthelast', 'quiz'),
|
||||
array('value' => 0, 'adv' => true)));
|
||||
|
||||
// Review options.
|
||||
$quizsettings->add(new admin_setting_heading('reviewheading',
|
||||
get_string('reviewoptionsheading', 'quiz'), ''));
|
||||
foreach (mod_quiz_admin_review_setting::fields() as $field => $name) {
|
||||
$default = mod_quiz_admin_review_setting::all_on();
|
||||
$forceduring = null;
|
||||
if ($field == 'attempt') {
|
||||
$forceduring = true;
|
||||
} else if ($field == 'overallfeedback') {
|
||||
$default = $default ^ mod_quiz_admin_review_setting::DURING;
|
||||
$forceduring = false;
|
||||
// Number of attempts.
|
||||
$options = array(get_string('unlimited'));
|
||||
for ($i = 1; $i <= QUIZ_MAX_ATTEMPT_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$quizsettings->add(new mod_quiz_admin_review_setting('quiz/review' . $field,
|
||||
$name, '', $default, $forceduring));
|
||||
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/attempts',
|
||||
get_string('attemptsallowed', 'quiz'), get_string('configattemptsallowed', 'quiz'),
|
||||
array('value' => 0, 'adv' => false), $options));
|
||||
|
||||
// Grading method.
|
||||
$quizsettings->add(new mod_quiz_admin_setting_grademethod('quiz/grademethod',
|
||||
get_string('grademethod', 'quiz'), get_string('configgrademethod', 'quiz'),
|
||||
array('value' => QUIZ_GRADEHIGHEST, 'adv' => false), null));
|
||||
|
||||
// Maximum grade.
|
||||
$quizsettings->add(new admin_setting_configtext('quiz/maximumgrade',
|
||||
get_string('maximumgrade'), get_string('configmaximumgrade', 'quiz'), 10, PARAM_INT));
|
||||
|
||||
// Shuffle questions.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shufflequestions',
|
||||
get_string('shufflequestions', 'quiz'), get_string('configshufflequestions', 'quiz'),
|
||||
array('value' => 0, 'adv' => false)));
|
||||
|
||||
// Questions per page.
|
||||
$perpage = array();
|
||||
$perpage[0] = get_string('never');
|
||||
$perpage[1] = get_string('aftereachquestion', 'quiz');
|
||||
for ($i = 2; $i <= QUIZ_MAX_QPP_OPTION; ++$i) {
|
||||
$perpage[$i] = get_string('afternquestions', 'quiz', $i);
|
||||
}
|
||||
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questionsperpage',
|
||||
get_string('newpageevery', 'quiz'), get_string('confignewpageevery', 'quiz'),
|
||||
array('value' => 1, 'adv' => false), $perpage));
|
||||
|
||||
// Navigation method.
|
||||
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/navmethod',
|
||||
get_string('navmethod', 'quiz'), get_string('confignavmethod', 'quiz'),
|
||||
array('value' => QUIZ_NAVMETHOD_FREE, 'adv' => true), quiz_get_navigation_options()));
|
||||
|
||||
// Shuffle within questions.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/shuffleanswers',
|
||||
get_string('shufflewithin', 'quiz'), get_string('configshufflewithin', 'quiz'),
|
||||
array('value' => 1, 'adv' => false)));
|
||||
|
||||
// Preferred behaviour.
|
||||
$quizsettings->add(new admin_setting_question_behaviour('quiz/preferredbehaviour',
|
||||
get_string('howquestionsbehave', 'question'), get_string('howquestionsbehave_desc', 'quiz'),
|
||||
'deferredfeedback'));
|
||||
|
||||
// Each attempt builds on last.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/attemptonlast',
|
||||
get_string('eachattemptbuildsonthelast', 'quiz'),
|
||||
get_string('configeachattemptbuildsonthelast', 'quiz'),
|
||||
array('value' => 0, 'adv' => true)));
|
||||
|
||||
// Review options.
|
||||
$quizsettings->add(new admin_setting_heading('reviewheading',
|
||||
get_string('reviewoptionsheading', 'quiz'), ''));
|
||||
foreach (mod_quiz_admin_review_setting::fields() as $field => $name) {
|
||||
$default = mod_quiz_admin_review_setting::all_on();
|
||||
$forceduring = null;
|
||||
if ($field == 'attempt') {
|
||||
$forceduring = true;
|
||||
} else if ($field == 'overallfeedback') {
|
||||
$default = $default ^ mod_quiz_admin_review_setting::DURING;
|
||||
$forceduring = false;
|
||||
}
|
||||
$quizsettings->add(new mod_quiz_admin_review_setting('quiz/review' . $field,
|
||||
$name, '', $default, $forceduring));
|
||||
}
|
||||
|
||||
// Show the user's picture.
|
||||
$quizsettings->add(new mod_quiz_admin_setting_user_image('quiz/showuserpicture',
|
||||
get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'),
|
||||
array('value' => 0, 'adv' => false), $options));
|
||||
|
||||
// Decimal places for overall grades.
|
||||
$options = array();
|
||||
for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/decimalpoints',
|
||||
get_string('decimalplaces', 'quiz'), get_string('configdecimalplaces', 'quiz'),
|
||||
array('value' => 2, 'adv' => false), $options));
|
||||
|
||||
// Decimal places for question grades.
|
||||
$options = array(-1 => get_string('sameasoverall', 'quiz'));
|
||||
for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questiondecimalpoints',
|
||||
get_string('decimalplacesquestion', 'quiz'),
|
||||
get_string('configdecimalplacesquestion', 'quiz'),
|
||||
array('value' => -1, 'adv' => true), $options));
|
||||
|
||||
// Show blocks during quiz attempts.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/showblocks',
|
||||
get_string('showblocks', 'quiz'), get_string('configshowblocks', 'quiz'),
|
||||
array('value' => 0, 'adv' => true)));
|
||||
|
||||
// Password.
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/password',
|
||||
get_string('requirepassword', 'quiz'), get_string('configrequirepassword', 'quiz'),
|
||||
array('value' => '', 'adv' => true), PARAM_TEXT));
|
||||
|
||||
// IP restrictions.
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/subnet',
|
||||
get_string('requiresubnet', 'quiz'), get_string('configrequiresubnet', 'quiz'),
|
||||
array('value' => '', 'adv' => true), PARAM_TEXT));
|
||||
|
||||
// Enforced delay between attempts.
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay1',
|
||||
get_string('delay1st2nd', 'quiz'), get_string('configdelay1st2nd', 'quiz'),
|
||||
array('value' => 0, 'adv' => true), PARAM_INT));
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay2',
|
||||
get_string('delaylater', 'quiz'), get_string('configdelaylater', 'quiz'),
|
||||
array('value' => 0, 'adv' => true), PARAM_INT));
|
||||
|
||||
// Browser security.
|
||||
$quizsettings->add(new mod_quiz_admin_setting_browsersecurity('quiz/browsersecurity',
|
||||
get_string('showinsecurepopup', 'quiz'), get_string('configpopup', 'quiz'),
|
||||
array('value' => '-', 'adv' => true), null));
|
||||
|
||||
// Allow user to specify if setting outcomes is an advanced setting
|
||||
if (!empty($CFG->enableoutcomes)) {
|
||||
$quizsettings->add(new admin_setting_configcheckbox('quiz/outcomes_adv',
|
||||
get_string('outcomesadvanced', 'quiz'), get_string('configoutcomesadvanced', 'quiz'),
|
||||
'0'));
|
||||
}
|
||||
|
||||
// Autosave frequency.
|
||||
$options = array(
|
||||
0 => get_string('donotuseautosave', 'quiz'),
|
||||
60 => get_string('oneminute', 'quiz'),
|
||||
120 => get_string('numminutes', 'moodle', 2),
|
||||
300 => get_string('numminutes', 'moodle', 5),
|
||||
);
|
||||
$quizsettings->add(new admin_setting_configselect('quiz/autosaveperiod',
|
||||
get_string('autosaveperiod', 'quiz'), get_string('autosaveperiod_desc', 'quiz'), 0, $options));
|
||||
}
|
||||
|
||||
// Show the user's picture.
|
||||
$quizsettings->add(new mod_quiz_admin_setting_user_image('quiz/showuserpicture',
|
||||
get_string('showuserpicture', 'quiz'), get_string('configshowuserpicture', 'quiz'),
|
||||
array('value' => 0, 'adv' => false), $options));
|
||||
|
||||
// Decimal places for overall grades.
|
||||
$options = array();
|
||||
for ($i = 0; $i <= QUIZ_MAX_DECIMAL_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/decimalpoints',
|
||||
get_string('decimalplaces', 'quiz'), get_string('configdecimalplaces', 'quiz'),
|
||||
array('value' => 2, 'adv' => false), $options));
|
||||
|
||||
// Decimal places for question grades.
|
||||
$options = array(-1 => get_string('sameasoverall', 'quiz'));
|
||||
for ($i = 0; $i <= QUIZ_MAX_Q_DECIMAL_OPTION; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$quizsettings->add(new admin_setting_configselect_with_advanced('quiz/questiondecimalpoints',
|
||||
get_string('decimalplacesquestion', 'quiz'),
|
||||
get_string('configdecimalplacesquestion', 'quiz'),
|
||||
array('value' => -1, 'adv' => true), $options));
|
||||
|
||||
// Show blocks during quiz attempts.
|
||||
$quizsettings->add(new admin_setting_configcheckbox_with_advanced('quiz/showblocks',
|
||||
get_string('showblocks', 'quiz'), get_string('configshowblocks', 'quiz'),
|
||||
array('value' => 0, 'adv' => true)));
|
||||
|
||||
// Password.
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/password',
|
||||
get_string('requirepassword', 'quiz'), get_string('configrequirepassword', 'quiz'),
|
||||
array('value' => '', 'adv' => true), PARAM_TEXT));
|
||||
|
||||
// IP restrictions.
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/subnet',
|
||||
get_string('requiresubnet', 'quiz'), get_string('configrequiresubnet', 'quiz'),
|
||||
array('value' => '', 'adv' => true), PARAM_TEXT));
|
||||
|
||||
// Enforced delay between attempts.
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay1',
|
||||
get_string('delay1st2nd', 'quiz'), get_string('configdelay1st2nd', 'quiz'),
|
||||
array('value' => 0, 'adv' => true), PARAM_INT));
|
||||
$quizsettings->add(new admin_setting_configtext_with_advanced('quiz/delay2',
|
||||
get_string('delaylater', 'quiz'), get_string('configdelaylater', 'quiz'),
|
||||
array('value' => 0, 'adv' => true), PARAM_INT));
|
||||
|
||||
// Browser security.
|
||||
$quizsettings->add(new mod_quiz_admin_setting_browsersecurity('quiz/browsersecurity',
|
||||
get_string('showinsecurepopup', 'quiz'), get_string('configpopup', 'quiz'),
|
||||
array('value' => '-', 'adv' => true), null));
|
||||
|
||||
// Allow user to specify if setting outcomes is an advanced setting
|
||||
if (!empty($CFG->enableoutcomes)) {
|
||||
$quizsettings->add(new admin_setting_configcheckbox('quiz/outcomes_adv',
|
||||
get_string('outcomesadvanced', 'quiz'), get_string('configoutcomesadvanced', 'quiz'),
|
||||
'0'));
|
||||
}
|
||||
|
||||
// Autosave frequency.
|
||||
$options = array(
|
||||
0 => get_string('donotuseautosave', 'quiz'),
|
||||
60 => get_string('oneminute', 'quiz'),
|
||||
120 => get_string('numminutes', 'moodle', 2),
|
||||
300 => get_string('numminutes', 'moodle', 5),
|
||||
);
|
||||
$quizsettings->add(new admin_setting_configselect('quiz/autosaveperiod',
|
||||
get_string('autosaveperiod', 'quiz'), get_string('autosaveperiod_desc', 'quiz'), 0, $options));
|
||||
|
||||
// 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) && empty($rulesbyname)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user