New quiz config page to allow admin to set defaults and hide options on the quiz setup page.

This commit is contained in:
gustav_delius 2004-12-23 07:09:33 +00:00
parent 0044147e10
commit a5c0990e5d
7 changed files with 520 additions and 168 deletions

View File

@ -0,0 +1 @@
<p align="center"><b>Fix site defaults</b></p> <p>If you check these boxes then the default value that you choose here will be fixed for all new instances. The setup screen that the teacher sees will be simplified because it will not display the option. </p>

View File

@ -461,6 +461,7 @@ $string['existingcoursedeleting'] = 'Existing course, deleting it first';
$string['existingcreators'] = 'Existing course creators';
$string['existingstudents'] = 'Enrolled students';
$string['existingteachers'] = 'Existing teachers';
$string['explanation'] = 'Explanation';
$string['failedloginattempts'] = '$a->attempts failed logins since your last login';
$string['failedloginattemptsall'] = '$a->attempts failed logins for $a->accounts accounts';
$string['feedback'] = 'Feedback';
@ -473,6 +474,7 @@ $string['findmorecourses'] = 'Find more courses...';
$string['firstdayofweek'] = '0';
$string['firstname'] = 'First name';
$string['firsttime'] = 'Is this your first time here?';
$string['fix'] = 'Fix';
$string['followingoptional'] = 'The following items are optional';
$string['followingrequired'] = 'The following items are required';
$string['force'] = 'Force';
@ -942,6 +944,7 @@ $string['showtheselogs'] = 'Show these logs';
$string['since'] = 'Since';
$string['sincelast'] = ' since last login';
$string['site'] = 'Site';
$string['sitedefault'] = 'Site Default';
$string['siteerrors'] = 'Site errors';
$string['sitefiles'] = 'Site files';
$string['sitelogs'] = 'Site logs';

View File

@ -213,6 +213,17 @@ function upgrade_activity_modules($return) {
error($module->name .' tables could NOT be set up successfully!');
}
}
if ( is_readable($fullmod .'/defaults.php')) {
// Insert default values for any important configuration variables
include_once($fullmod .'/defaults.php');
foreach ($defaults as $name => $value) {
if (!isset($CFG->$name)) {
$CFG->$name = $value;
set_config($name, $value);
}
}
}
}
if (!empty($updated_modules)) {

View File

@ -2880,7 +2880,7 @@ function print_time_selector($hour, $minute, $currenttime=0, $step=5) {
* @param string $unit ?
* @todo Finish documenting this function
*/
function print_timer_selector($timelimit = 0, $unit = '') {
function print_timer_selector($timelimit = 0, $unit = '', $name = 'timelimit') {
global $CFG;
@ -2894,7 +2894,7 @@ function print_timer_selector($timelimit = 0, $unit = '') {
for ($i=1; $i<=$maxvalue; $i++) {
$minutes[$i] = $i.$unit;
}
choose_from_menu($minutes, 'timelimit', $timelimit, get_string('none'));
choose_from_menu($minutes, $name, $timelimit, get_string('none'));
}
/**

233
mod/quiz/config.html Normal file
View File

@ -0,0 +1,233 @@
<form method="post" action="module.php" name="form">
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
<table cellpadding="9" cellspacing="0" >
<tr valign="top">
<th align="right">&nbsp;</th>
<th align="left">
<?php print_string('sitedefault'); ?>
</th>
<th align="center">
<?php print_string('fix'); helpbutton("fixdefaults"); ?>
</th>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("timelimit", "quiz") ?>:</b></td>
<td>
<?php
print_timer_selector($CFG->quiz_timelimit, get_string("minutes","quiz"), 'quiz_timelimit');
helpbutton("timelimit", get_string("quiztimer","quiz"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_timelimit" value="0">
<input type="checkbox" name="quiz_fix_timelimit" value="1" <?php p($CFG->quiz_fix_timelimit ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("shufflequestions", "quiz") ?>:</b></td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "quiz_shufflequestions", $CFG->quiz_shufflequestions, "", "", "");
helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_shufflequestions" value="0">
<input type="checkbox" name="quiz_fix_shufflequestions" value="1" <?php p($CFG->quiz_fix_shufflequestions ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("shuffleanswers", "quiz") ?>:</b></td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "quiz_shuffleanswers", $CFG->quiz_shuffleanswers, "", "", "");
helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_shuffleanswers" value="0">
<input type="checkbox" name="quiz_fix_shuffleanswers" value="1" <?php p($CFG->quiz_fix_shuffleanswers ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("attemptsallowed", "quiz") ?>:</b></td>
<td>
<?php
unset($options);
$options[0] = get_string("attemptsunlimited", "quiz");
$options[1] = "1 ".strtolower(get_string("attempt", "quiz"));
for ($i=2;$i<=6;$i++) {
$options[$i] = "$i ".strtolower(get_string("attempts", "quiz"));
}
choose_from_menu ($options, "quiz_attempts", $CFG->quiz_attempts, "", "", "");
helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_attempts" value="0">
<input type="checkbox" name="quiz_fix_attempts" value="1" <?php p($CFG->quiz_fix_attempts ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("eachattemptbuildsonthelast", "quiz") ?>:</b></td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "quiz_attemptonlast", $CFG->quiz_attemptonlast, "", "", "");
helpbutton("repeatattempts", get_string("eachattemptbuildsonthelast", "quiz"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_attemptonlast" value="0">
<input type="checkbox" name="quiz_fix_attemptonlast" value="1" <?php p($CFG->quiz_fix_attemptonlast ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("grademethod", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu ($QUIZ_GRADE_METHOD, "quiz_grademethod", $CFG->quiz_grademethod, "", "", "");
helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_grademethod" value="0">
<input type="checkbox" name="quiz_fix_grademethod" value="1" <?php p($CFG->quiz_fix_grademethod ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("showfeedback", "quiz") ?>:</b></td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "quiz_showfeedback", $CFG->quiz_showfeedback, "", "", "");
helpbutton("feedback", get_string("showfeedback","quiz"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_showfeedback" value="0">
<input type="checkbox" name="quiz_fix_showfeedback" value="1" <?php p($CFG->quiz_fix_showfeedback ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("showcorrectanswer", "quiz") ?>:</b></td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "quiz_showanswer", $CFG->quiz_showanswer, "", "", "");
helpbutton("correctanswers", get_string("showcorrectanswer","quiz"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_showanswer" value="0">
<input type="checkbox" name="quiz_fix_showanswer" value="1" <?php p($CFG->quiz_fix_showanswer ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("allowreview", "quiz") ?>:</b></td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "quiz_allowreview", $CFG->quiz_allowreview, "", "", "");
helpbutton("review", get_string("allowreview","quiz"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_allowreview" value="0">
<input type="checkbox" name="quiz_fix_allowreview" value="1" <?php p($CFG->quiz_fix_allowreview ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
<td>
<?php
unset($grades);
for ($i=100; $i>=1; $i--) {
$grades[$i] = $i;
}
$grades[0] = get_string("nograde");
choose_from_menu ($grades, "quiz_maximumgrade", $CFG->quiz_maximumgrade, "", "", "");
helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_maximumgrade" value="0">
<input type="checkbox" name="quiz_fix_maximumgrade" value="1" <?php p($CFG->quiz_fix_maximumgrade ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("popup", "quiz") ?>:</b></td>
<td>
<?php
unset($options);
$options[0] = get_string("no");
$options[1] = get_string("yes");
choose_from_menu ($options, "quiz_popup", $CFG->quiz_popup, "", "", "");
helpbutton("popup", get_string("popup","quiz"), "quiz");
?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_popup" value="0">
<input type="checkbox" name="quiz_fix_popup" value="1" <?php p($CFG->quiz_fix_popup ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("requirepassword", "quiz") ?>:</b></td>
<td>
<input type="text" name="quiz_password" size="20" value="<?php p($CFG->quiz_password) ?>" />
<?php helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_password" value="0">
<input type="checkbox" name="quiz_fix_password" value="1" <?php p($CFG->quiz_fix_password ? "checked" : "") ?> />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("requiresubnet", "quiz") ?>:</b></td>
<td>
<input type="text" name="quiz_subnet" size="20" value="<?php p($CFG->quiz_subnet) ?>" />
<?php helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
</td>
<td align="center">
<input type="hidden" name="quiz_fix_subnet" value="0">
<input type="checkbox" name="quiz_fix_subnet" value="1" <?php p($CFG->quiz_fix_subnet ? "checked" : "") ?> />
</td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" value="<?php print_string("savechanges") ?>" />
</td>
</tr>
</table>
</form>

36
mod/quiz/defaults.php Normal file
View File

@ -0,0 +1,36 @@
<?php // $Id$
// This file is generally only included from upgrade_activity_modules()
// It defines default values for any important configuration variables
$defaults = array (
'quiz_allowreview' => 0,
'quiz_attemptonlast' => 0,
'quiz_attempts' => 0,
'quiz_grademethod' => '',
'quiz_maximumgrade' => 0,
'quiz_password' => '',
'quiz_popup' => 0,
'quiz_showanswer' => '',
'quiz_showfeedback' => '',
'quiz_shuffleanswers' => 1,
'quiz_shufflequestions' => 0,
'quiz_subnet' => '',
'quiz_timelimit' => 0,
'quiz_fix_allowreview' => 0,
'quiz_fix_attemptonlast' => 0,
'quiz_fix_attempts' => 0,
'quiz_fix_grademethod' => 0,
'quiz_fix_maximumgrade' => 0,
'quiz_fix_password' => 0,
'quiz_fix_popup' => 0,
'quiz_fix_showanswer' => 0,
'quiz_fix_showfeedback' => 0,
'quiz_fix_shuffleanswers' => 0,
'quiz_fix_shufflequestions' => 0,
'quiz_fix_subnet' => 0,
'quiz_fix_timelimit' => 0
);
?>

View File

@ -17,60 +17,61 @@
$form->timeclose = "";
}
if (!isset($form->attempts)) {
$form->attempts = 0;
$form->attempts = $CFG->quiz_attempts;
}
if (!isset($form->attemptonlast)) {
$form->attemptonlast = 0;
$form->attemptonlast = $CFG->quiz_attemptonlast;
}
if (!isset($form->grademethod)) {
$form->grademethod = "";
$form->grademethod = $CFG->quiz_grademethod;
}
if (!isset($form->feedback)) {
$form->feedback = "";
$form->feedback = $CFG->quiz_showfeedback;
}
if (!isset($form->correctanswers)) {
$form->correctanswers = "";
$form->correctanswers = $CFG->quiz_showanswer;
}
if (!isset($form->review)) {
$form->review = 0;
$form->review = $CFG->quiz_allowreview;
}
if (!isset($form->shufflequestions)) {
$form->shufflequestions = 0;
$form->shufflequestions = $CFG->quiz_shufflequestions;
}
if (!isset($form->shuffleanswers)) {
$form->shuffleanswers = 1;
$form->shuffleanswers = $CFG->quiz_shuffleanswers;
}
if (!isset($form->grade)) {
$form->grade = 0;
$form->grade = $CFG->quiz_maximumgrade;
}
if (!isset($form->questions)) {
$form->questions = "";
}
if (!isset($form->password)) {
$form->password = "";
$form->password = $CFG->quiz_password;
}
if (!isset($form->subnet)) {
$form->subnet = "";
$form->subnet = $CFG->quiz_subnet;
}
if (!isset($form->timelimit)) {
$form->timelimit = 0;
$form->timelimit = $CFG->quiz_timelimit;
}
if (!isset($form->popup)) {
$form->popup = 0;
$form->popup = $CFG->quiz_popup;
}
?>
<form name="form" method="post" action="../mod/quiz/edit.php">
<center>
<table cellpadding="5">
<tr valign="top">
<td align="right"><b><?php print_string("name") ?>:</b></td>
<td>
<input type="text" name="name" size="40" value="<?php p($form->name) ?>" />
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("introduction", "quiz") ?>:</b>
<br />
@ -94,6 +95,7 @@
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("quizopen", "quiz") ?>:</b></td>
<td>
@ -107,6 +109,7 @@
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("quizclose", "quiz") ?>:</b></td>
<td>
@ -120,7 +123,11 @@
?>
</td>
</tr>
<tr valign="top">
<?php if ($CFG->quiz_fix_timelimit) { ?>
<input type="hidden" name="timelimit" value="<?php p($form->timelimit) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("timelimit", "quiz") ?>:</b></td>
<td>
<?php
@ -128,8 +135,13 @@
helpbutton("timelimit", get_string("quiztimer","quiz"), "quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_shufflequestions) { ?>
<input type="hidden" name="shufflequestions" value="<?php p($form->shufflequestions) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("shufflequestions", "quiz") ?>:</b></td>
<td>
<?php
@ -140,8 +152,13 @@
helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_shuffleanswers) { ?>
<input type="hidden" name="shuffleanswers" value="<?php p($form->shuffleanswers) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("shuffleanswers", "quiz") ?>:</b></td>
<td>
<?php
@ -152,8 +169,13 @@
helpbutton("shuffleanswers", get_string("shuffleanswers","quiz"), "quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_attempts) { ?>
<input type="hidden" name="attempts" value="<?php p($form->attempts) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("attemptsallowed", "quiz") ?>:</b></td>
<td>
<?php
@ -167,8 +189,13 @@
helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_attemptonlast) { ?>
<input type="hidden" name="attemptonlast" value="<?php p($form->attemptonlast) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("eachattemptbuildsonthelast", "quiz") ?>:</b></td>
<td>
<?php
@ -182,8 +209,13 @@
"quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_grademethod) { ?>
<input type="hidden" name="grademethod" value="<?php p($form->grademethod) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("grademethod", "quiz") ?>:</b></td>
<td>
<?php
@ -196,8 +228,13 @@
helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_showfeedback) { ?>
<input type="hidden" name="feedback" value="<?php p($form->feedback) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("showfeedback", "quiz") ?>:</b></td>
<td>
<?php
@ -208,8 +245,13 @@
helpbutton("feedback", get_string("showfeedback","quiz"), "quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_showanswer) { ?>
<input type="hidden" name="correctanswers" value="<?php p($form->correctanswers) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("showcorrectanswer", "quiz") ?>:</b></td>
<td>
<?php
@ -220,8 +262,13 @@
helpbutton("correctanswers", get_string("showcorrectanswer","quiz"), "quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_allowreview) { ?>
<input type="hidden" name="review" value="<?php p($form->review) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("allowreview", "quiz") ?>:</b></td>
<td>
<?php
@ -232,8 +279,13 @@
helpbutton("review", get_string("allowreview","quiz"), "quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_maximumgrade) { ?>
<input type="hidden" name="grade" value="<?php p($form->grade) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
<td>
<?php
@ -246,8 +298,13 @@
helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_popup) { ?>
<input type="hidden" name="popup" value="<?php p($form->popup) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("popup", "quiz") ?>:</b></td>
<td>
<?php
@ -258,21 +315,32 @@
helpbutton("popup", get_string("popup","quiz"), "quiz");
?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_password) { ?>
<input type="hidden" name="password" value="<?php p($form->password) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("requirepassword", "quiz") ?>:</b></td>
<td>
<input type="text" name="password" size="40" value="<?php p($form->password) ?>" />
<?php helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
</td>
</tr>
<tr valign="top">
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_subnet) { ?>
<input type="hidden" name="subnet" value="<?php p($form->subnet) ?>">
<?php } else { ?>
<tr valign="top">
<td align="right"><b><?php print_string("requiresubnet", "quiz") ?>:</b></td>
<td>
<input type="text" name="subnet" size="40" value="<?php p($form->subnet) ?>" />
<?php helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
</td>
</tr>
</tr>
<?php } ?>
</table>
<input type="hidden" name="questions" value="<?php p($form->questions) ?>" />