moodle/mod/quiz/numerical.html

142 lines
5.1 KiB
HTML
Raw Normal View History

2003-09-09 12:34:51 +00:00
<FORM name="theform" method="post" <?php echo $onsubmit ?> action="question.php">
<CENTER>
<TABLE cellpadding=5>
<TR valign=top>
2003-09-09 12:34:51 +00:00
<TD align=right><P><B><?php print_string("category", "quiz") ?>:</B></P></TD>
<TD>
2003-09-09 12:34:51 +00:00
<?php choose_from_menu($categories, "category", "$question->category", ""); ?>
</TD>
</TR>
<TR valign=top>
2003-09-09 12:34:51 +00:00
<TD align=right><P><B><?php print_string("questionname", "quiz") ?>:</B></P></TD>
<TD>
2003-09-09 12:34:51 +00:00
<INPUT type="text" name="name" size=50 value="<?php p($question->name) ?>">
<?php if (isset($err["name"])) formerr($err["name"]); ?>
</TD>
</TR>
<tr valign=top>
<td align="right"><p><b><?php print_string("question", "quiz") ?>:</b></p>
<br />
<br />
<br />
<p><font SIZE="1">
<?php
if ($usehtmleditor) {
helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
} else {
helpbutton("text", get_string("helptext"), "moodle", true, true);
}
?>
</font></p>
</td>
<td>
2003-09-09 12:34:51 +00:00
<?php if (isset($err["questiontext"])) {
formerr($err["questiontext"]);
echo "<br />";
}
print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
if ($usehtmleditor) { /// Trying this out for a while
echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'">';
} else {
echo "<div align=right>";
print_string("formattexttype");
echo ":&nbsp;";
if (!$question->questiontextformat) {
$question->questiontextformat = FORMAT_MOODLE;
}
choose_from_menu(format_text_menu(), "questiontextformat", $question->questiontextformat, "");
helpbutton("textformat", get_string("helpformatting"));
echo "</div>";
}
?>
</td>
</tr>
<TR valign=top>
2003-09-09 12:34:51 +00:00
<TD align=right><P><B><?php print_string("imagedisplay", "quiz") ?>:</B></P></TD>
<TD>
2003-09-09 12:34:51 +00:00
<?php if (empty($images)) {
print_string("noimagesyet");
} else {
choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
}
?>
</TD>
</TR>
<TR valign=top>
2003-09-09 12:34:51 +00:00
<TD align=right><P><B><?php print_string("correctanswer", "quiz") ?>:</B></P></TD>
2003-09-11 13:21:56 +00:00
<?php
// Even thou the rest of the module can handle up to six numerical answers,
// this form will limit the number of numerical answers to one only.
if (is_numeric($answers[0]->min) && is_numeric($answers[0]->answer)) {
$acceptederror = (float)($answers[0]->answer)
- (float)($answers[0]->min);
} else {
$acceptederror = "";
}
?>
<TD>
2003-09-09 12:34:51 +00:00
<INPUT align="LEFT" type="text" id="correct0" name="answer[]" size="20" value="<?php p($answers[0]->answer) ?>"/>&nbsp;&nbsp;
</TD>
</TR>
<TR valign=top>
2003-09-09 12:34:51 +00:00
<TD align=right><P><B><?php print_string("acceptederror", "quiz"); ?>:</B></P></TD>
<TD>
2003-09-09 12:34:51 +00:00
<INPUT align="LEFT" type="text" id="acceptederror0" name="acceptederror[]" size="15" value="<?php p($acceptederror) ?>" />&plusmn;
<!-- Values max and min will be determined when the form is submitted -->
<INPUT type="HIDDEN" id="min0" name="min[]" value=""/>
<INPUT type="HIDDEN" id="max0" name="max[]" value=""/>
<INPUT type="HIDDEN" name="fraction[]" value="1"/>
<BR/>
</TD>
</TR>
<TR valign=top>
2003-09-09 12:34:51 +00:00
<TD align=right><P><B><?php print_string("feedback", "quiz") ?>:</B></P></TD>
<TD>
2003-09-09 12:34:51 +00:00
<textarea name="feedback[]" rows=2 cols=50 wrap="virtual"><?php p($answers[0]->feedback) ?></textarea>
</TD>
</TR>
</TABLE>
2003-09-09 12:34:51 +00:00
<INPUT type="hidden" name=id value="<?php p($question->id) ?>">
<INPUT type="hidden" name=qtype value="<?php p($question->qtype) ?>">
<INPUT type="submit" onClick="return determineMinAndMax();" value="<?php print_string("savechanges") ?>">
</CENTER>
</FORM>
<SCRIPT language="JAVASCRIPT">
function determineMinAndMax() {
// This client-side script will determine the values for min and max
// based on the input for answer and acceptederror.
with(document.theform) {
if (correct0.value=='') {
2003-09-09 12:34:51 +00:00
alert('<?php print_string("missingcorrectanswer","quiz") ?>');
return false;
} else if (acceptederror0.value=='') {
var correct= parseFloat(correct0.value);
if (!isNaN(correct)) {
min0.value= correct;
max0.value= correct;
}
return true;
} else if (isNaN(acceptederror0.value) || isNaN(correct0.value)) {
2003-09-09 12:34:51 +00:00
alert('<?php print_string("answerswithacceptederrormarginmustbenumeric", "quiz") ?>');
return false;
} else {
var correct= parseFloat(correct0.value);
var error= Math.abs(acceptederror0.value);
min0.value= correct-error;
max0.value= correct+error;
return true;
}
}
}
</SCRIPT>
2003-09-09 12:34:51 +00:00
<?php
if ($usehtmleditor) {
print_richedit_javascript("theform", "questiontext", "no");
}
?>