2003-09-09 12:34:51 +00:00
|
|
|
<FORM name="theform" method="post" <?php echo $onsubmit ?> action="question.php">
|
2003-07-10 13:25:07 +00:00
|
|
|
<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>
|
2003-07-10 13:25:07 +00:00
|
|
|
<TD>
|
2003-09-09 12:34:51 +00:00
|
|
|
<?php choose_from_menu($categories, "category", "$question->category", ""); ?>
|
2003-07-10 13:25:07 +00:00
|
|
|
</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>
|
2003-07-10 13:25:07 +00:00
|
|
|
<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"]); ?>
|
2003-07-10 13:25:07 +00:00
|
|
|
</TD>
|
|
|
|
</TR>
|
|
|
|
<TR valign=top>
|
2003-09-09 12:34:51 +00:00
|
|
|
<TD align=right><P><B><?php print_string("question", "quiz") ?>:</B></P></TD>
|
2003-07-10 13:25:07 +00:00
|
|
|
<TD>
|
2003-09-09 12:34:51 +00:00
|
|
|
<?php if (isset($err["questiontext"])) {
|
2003-07-10 13:25:07 +00:00
|
|
|
formerr($err["questiontext"]);
|
|
|
|
echo "<BR \>";
|
|
|
|
}
|
|
|
|
print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
|
|
|
|
if ($usehtmleditor) {
|
|
|
|
helpbutton("richtext", get_string("helprichtext"), "moodle");
|
|
|
|
} else {
|
|
|
|
helpbutton("text", get_string("helptext"), "moodle");
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</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>
|
2003-07-10 13:25:07 +00:00
|
|
|
<TD>
|
2003-09-09 12:34:51 +00:00
|
|
|
<?php if (empty($images)) {
|
2003-07-10 13:25:07 +00:00
|
|
|
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
|
2003-07-10 13:25:07 +00:00
|
|
|
// 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) ?>"/>
|
2003-07-17 22:11:08 +00:00
|
|
|
</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>
|
2003-07-17 22:11:08 +00:00
|
|
|
<TD>
|
2003-09-09 12:34:51 +00:00
|
|
|
<INPUT align="LEFT" type="text" id="acceptederror0" name="acceptederror[]" size="15" value="<?php p($acceptederror) ?>" />±
|
2003-07-10 13:25:07 +00:00
|
|
|
<!-- 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>
|
2003-07-10 13:25:07 +00:00
|
|
|
<TD>
|
2003-09-09 12:34:51 +00:00
|
|
|
<textarea name="feedback[]" rows=2 cols=50 wrap="virtual"><?php p($answers[0]->feedback) ?></textarea>
|
2003-07-10 13:25:07 +00:00
|
|
|
</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") ?>">
|
2003-07-10 13:25:07 +00:00
|
|
|
</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") ?>');
|
2003-07-10 13:25:07 +00:00
|
|
|
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") ?>');
|
2003-07-10 13:25:07 +00:00
|
|
|
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
|
2003-07-10 13:25:07 +00:00
|
|
|
if ($usehtmleditor) {
|
|
|
|
print_richedit_javascript("theform", "questiontext", "no");
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|