moodle/mod/quiz/mod.html

565 lines
19 KiB
HTML

<!-- This page defines the form to create or edit an instance of this module -->
<!-- It is used from /course/mod.php. The whole instance is available as $form. -->
<!-- Some javascript to allow for the hiding of advanced options
This code was derived from mod.html in the resource module -->
<script language="javascript" type="text/javascript">
function showhide (id, set) {
divobj = document.getElementById(id);
butobj = document.getElementById(id+'button');
prefobj = document.getElementById(id+'pref');
if (set == true) {
if (prefobj.value == '1') {
divobj.style.display = 'block';
butobj.value = '<?php print_string("hideadvancedsettings") ?>';
} else {
divobj.style.display = 'none';
butobj.value = '<?php print_string("showadvancedsettings") ?>...';
}
} else {
if (prefobj.value == '1') {
divobj.style.display = 'none';
butobj.value = '<?php print_string("showadvancedsettings") ?>...';
prefobj.value = '0';
} else {
divobj.style.display = 'block';
butobj.value = '<?php print_string("hideadvancedsettings") ?>';
prefobj.value = '1';
}
}
}
</script>
<?php
require_once("$CFG->dirroot/mod/quiz/locallib.php");
// Ensure that all form variables are initialized
if (!isset($form->name)) {
$form->name = "";
}
if (!isset($form->intro)) {
$form->intro = "";
}
if (!isset($form->timeopen)) {
$form->timeopen = "";
}
if (!isset($form->timeclose)) {
$form->timeclose = "";
}
if (!isset($form->attempts)) {
$form->attempts = $CFG->quiz_attempts;
}
if (!isset($form->attemptonlast)) {
$form->attemptonlast = $CFG->quiz_attemptonlast;
}
if (!isset($form->grademethod)) {
$form->grademethod = $CFG->quiz_grademethod;
}
if (!isset($form->feedback)) {
$form->feedback = $CFG->quiz_showfeedback;
}
if (!isset($form->correctanswers)) {
$form->correctanswers = $CFG->quiz_showanswer;
}
if (!isset($form->review)) {
$form->review = $CFG->quiz_allowreview;
}
if (!isset($form->questionsperpage)) {
$form->questionsperpage = 0;
}
if (!isset($form->shufflequestions)) {
$form->shufflequestions = $CFG->quiz_shufflequestions;
}
if (!isset($form->shuffleanswers)) {
$form->shuffleanswers = $CFG->quiz_shuffleanswers;
}
if (!isset($form->grade)) {
$form->grade = $CFG->quiz_maximumgrade;
}
if (!isset($form->questions)) {
$form->questions = "";
}
if (!isset($form->password)) {
$form->password = $CFG->quiz_password;
}
if (!isset($form->subnet)) {
$form->subnet = $CFG->quiz_subnet;
}
if (!isset($form->timelimit)) {
$form->timelimit = $CFG->quiz_timelimit;
}
if (!isset($form->popup)) {
$form->popup = $CFG->quiz_popup;
}
$fix = 0; // This will later be set to 1 if some of the variables have been fixed by the admin.
// the following are used for drop-down menus
$reviewoptions = array();
$reviewoptions[0] = get_string('reviewnever', 'quiz');
$reviewoptions[1] = get_string('reviewafter', 'quiz');
$reviewoptions[2] = get_string('reviewbefore', 'quiz');
$reviewoptions[3] = get_string('reviewalways', 'quiz');
$yesnooptions = array();
$yesnooptions[0] = get_string("no");
$yesnooptions[1] = get_string("yes");
$attemptoptions = array();
$attemptoptions[0] = get_string("attemptsunlimited", "quiz");
$attemptoptions[1] = "1 ".strtolower(get_string("attempt", "quiz"));
for ($i=2;$i<=6;$i++) {
$attemptoptions[$i] = "$i ".strtolower(get_string("attempts", "quiz"));
}
$grades = array();
for ($i=100; $i>=1; $i--) {
$grades[$i] = $i;
}
$grades[0] = get_string("nograde");
?>
<form name="form" method="post" action="mod.php">
<center>
<!-- Now comes a table with all the options that have not been fixed by the admin -->
<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 />
<span class="editorhelptext">
<?php
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
helpbutton("text", get_string("helptext"), "moodle", true, true);
echo '<br />';
emoticonhelpbutton("form", "description");
echo '<br />';
}
?>
<br />
</span>
</td>
<td>
<?php
print_textarea($usehtmleditor, 20, 50, 680, 400, "intro", $form->intro);
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("quizopen", "quiz") ?>:</b></td>
<td>
<?php
if (!$form->timeopen and $course->format == "weeks") {
$form->timeopen = $course->startdate + (($form->section - 1) * 608400);
}
print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
print_time_selector("openhour", "openminute", $form->timeopen);
helpbutton("timeopen", get_string("quizopen","quiz"), "quiz");
?>
</td>
</tr>
<tr valign="top">
<td align="right"><b><?php print_string("quizclose", "quiz") ?>:</b></td>
<td>
<?php
if (!$form->timeclose and $course->format == "weeks") {
$form->timeclose = $course->startdate + (($form->section) * 608400);
}
print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose);
print_time_selector("closehour", "closeminute", $form->timeclose);
helpbutton("timeopen", get_string("quizclose","quiz"), "quiz");
?>
</td>
</tr>
<?php if (!$CFG->quiz_fix_timelimit) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("timelimit", "quiz") ?>:</b></td>
<td>
<?php
print_timer_selector($form->timelimit, get_string("minutes","quiz"));
helpbutton("timelimit", get_string("quiztimer","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<tr valign="top">
<td align="right"><b><?php print_string('questionsperpage', 'quiz') ?>:</b></td>
<td>
<?php
$perpage= array();
for ($i=0; $i<=50; ++$i) {
$perpage[$i] = $i;
}
$perpage[0] = get_string('allinone', 'quiz');
choose_from_menu($perpage, 'questionsperpage', $form->questionsperpage, '');
helpbutton('questionsperpage', get_string('questionsperpage'), 'quiz');
?>
</td>
</tr>
<?php if (!$CFG->quiz_fix_shufflequestions) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("shufflequestions", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "shufflequestions", "$form->shufflequestions", "");
helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if (!$CFG->quiz_fix_shuffleanswers) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("shuffleanswers", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "shuffleanswers", "$form->shuffleanswers", "");
helpbutton("shuffleanswers", get_string("shuffleanswers","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if (!$CFG->quiz_fix_attempts) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("attemptsallowed", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($attemptoptions, "attempts", "$form->attempts", "");
helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if (!$CFG->quiz_fix_attemptonlast) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("eachattemptbuildsonthelast", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "attemptonlast",
"$form->attemptonlast", "");
helpbutton("repeatattempts",
get_string("eachattemptbuildsonthelast", "quiz"),
"quiz");
?>
</td>
</tr>
<?php } ?>
<?php if (!$CFG->quiz_fix_grademethod) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("grademethod", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($QUIZ_GRADE_METHOD, "grademethod", "$form->grademethod", "");
helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if (!$CFG->quiz_fix_showfeedback) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("showfeedback", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "feedback", "$form->feedback", "");
helpbutton("feedback", get_string("showfeedback","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if (!$CFG->quiz_fix_showanswer) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("showcorrectanswer", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "correctanswers", "$form->correctanswers", "");
helpbutton("correctanswers", get_string("showcorrectanswer","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if (!$CFG->quiz_fix_allowreview) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("allowreview", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($reviewoptions, "review", "$form->review", "");
helpbutton("review2", get_string("allowreview","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if (!$CFG->quiz_fix_maximumgrade) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
<td>
<?php
choose_from_menu($grades, "grade", "$form->grade", "");
helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if (!$CFG->quiz_fix_popup) { ?>
<tr valign="top">
<td align="right"><b><?php print_string("popup", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "popup", "$form->popup", "");
helpbutton("popup", get_string("popup","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if (!$CFG->quiz_fix_password) { ?>
<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>
<?php } ?>
<?php if (!$CFG->quiz_fix_subnet) { ?>
<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>
<?php } ?>
</table>
<!-- Now comes a copy of the above but enclosed in a div with id optionsettings and with
the conditions reversed, so that it shows exactly the options that are usually hidden.
The variable $fix is set to 1 if there is at least one fixed option.
The visibility of this div is controlled by javascript. -->
<div id="optionsettings">
<?php print_heading(get_string('advancedsettings')); ?>
<table cellpadding="5">
<?php if ($CFG->quiz_fix_timelimit) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("timelimit", "quiz") ?>:</b></td>
<td>
<?php
print_timer_selector($form->timelimit, get_string("minutes","quiz"));
helpbutton("timelimit", get_string("quiztimer","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_shufflequestions) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("shufflequestions", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "shufflequestions", "$form->shufflequestions", "");
helpbutton("shufflequestions", get_string("shufflequestions","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_shuffleanswers) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("shuffleanswers", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "shuffleanswers", "$form->shuffleanswers", "");
helpbutton("shuffleanswers", get_string("shuffleanswers","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_attempts) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("attemptsallowed", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($attemptoptions, "attempts", "$form->attempts", "");
helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_attemptonlast) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("eachattemptbuildsonthelast", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "attemptonlast",
"$form->attemptonlast", "");
helpbutton("repeatattempts",
get_string("eachattemptbuildsonthelast", "quiz"),
"quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_grademethod) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("grademethod", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($QUIZ_GRADE_METHOD, "grademethod", "$form->grademethod", "");
helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_showfeedback) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("showfeedback", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "feedback", "$form->feedback", "");
helpbutton("feedback", get_string("showfeedback","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_showanswer) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("showcorrectanswer", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "correctanswers", "$form->correctanswers", "");
helpbutton("correctanswers", get_string("showcorrectanswer","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_allowreview) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("allowreview", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($reviewoptions, "review", "$form->review", "");
helpbutton("review", get_string("allowreview","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_maximumgrade) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
<td>
<?php
choose_from_menu($grades, "grade", "$form->grade", "");
helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_popup) { $fix = 1; ?>
<tr valign="top">
<td align="right"><b><?php print_string("popup", "quiz") ?>:</b></td>
<td>
<?php
choose_from_menu($yesnooptions, "popup", "$form->popup", "");
helpbutton("popup", get_string("popup","quiz"), "quiz");
?>
</td>
</tr>
<?php } ?>
<?php if ($CFG->quiz_fix_password) { $fix = 1; ?>
<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>
<?php } ?>
<?php if ($CFG->quiz_fix_subnet) { $fix = 1; ?>
<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>
<?php } ?>
</table>
</div>
<!-- Now show the button that the teacher can use to display and override the settings that were
fixed by the admin. -->
<?php if ($fix) { ?>
<input type="button" value="hide settings" id="optionsettingsbutton" onclick="javascript: return showhide('optionsettings');" />
<input type="hidden" name="optionsettingspref" id="optionsettingspref"
value="<?php echo get_user_preferences('quiz_optionsettingspref', 0); ?>" />
<br />
<?php } else { ?>
<input type="hidden" value="hide settings" id="optionsettingsbutton" />
<input type="hidden" name="optionsettingspref" id="optionsettingspref"
value="0" />
<?php } ?>
<br />
<!-- these hidden variables are always the same -->
<input type="hidden" name="course" value="<?php p($form->course) ?>" />
<input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
<input type="hidden" name="section" value="<?php p($form->section) ?>" />
<input type="hidden" name="module" value="<?php p($form->module) ?>" />
<input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
<input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
<input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
<input type="submit" value="<?php print_string("savechanges") ?>" />
<!-- provide an additional button to edit questions -->
<input type="hidden" name="redirecturl" value="<?php p("$CFG->wwwroot/mod/quiz/edit.php?quizid=$form->instance") ?>" />
<input type="submit" name="redirect" value="<?php print_string('saveandedit', 'quiz') ?>" />
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
</center>
</form>
<script language="javascript" type="text/javascript">
showhide('optionsettings', true);
</script>