1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
<FORM name="theform" method="post" action="question.php">
<CENTER>
<TABLE cellpadding=5>
<TR valign=top>
<TD align=right><P><B><?php print_string("category", "quiz") ?>:</B></P></TD>
<TD>
<?php quiz_category_select_menu($course->id, true, true, $question->category); ?>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string("questionname", "quiz") ?>:</B></P></TD>
<TD>
<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>
<?php if (isset($err["questiontext"])) {
formerr($err["questiontext"]);
echo "<br />";
}
print_textarea($usehtmleditor, 15, 60, 630, 300, "questiontext", $question->questiontext);
if ($usehtmleditor) {
echo '<input type="hidden" name="questiontextformat" value="'.FORMAT_HTML.'">';
} else {
echo "<div align=right>";
print_string("formattexttype");
echo ": ";
if (!isset($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>
<TD align=right><P><B><?php print_string("imagedisplay", "quiz") ?>:</B></P></TD>
<TD>
<?php if (empty($images)) {
print_string("noimagesyet");
} else {
choose_from_menu($images, "image", "$question->image", get_string("none"),"","");
}
?>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string("correctanswer", "quiz") ?>:</B></P></TD>
<?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>
<INPUT align="LEFT" type="text" id="correct0" name="answer[]" size="20" value="<?php p($answers[0]->answer) ?>"/>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string("acceptederror", "quiz"); ?>:</B></P></TD>
<TD>
<INPUT align="LEFT" type="text" id="acceptederror0" name="acceptederror[]" size="15" value="<?php p($acceptederror) ?>" />±
<!-- 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>
<TD align=right><P><B><?php print_string("feedback", "quiz") ?>:</B></P></TD>
<TD>
<textarea name="feedback[]" rows=2 cols=50 wrap="virtual"><?php p($answers[0]->feedback) ?></textarea>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string("unit", "quiz") ?>:</B></P></TD>
<TD>
<P><INPUT type="HIDDEN" name="multiplier[]" value="1.0"/>
<INPUT align="LEFT" type="text" id="defaultunit" name="unit[]"
size="5" value="<?php p($units[0]->unit) ?>"/>
<B>(<?php print_string("optional", "quiz") ?>)</B></P>
</TD>
</TR>
<TR valign=top>
<td></td>
<TD align=left><P><B><?php print_string("alternativeunits", "quiz") ?>:</B></P></TD>
<td></td>
</TR>
<?PHP
for ($i=1; $i<count($units); $i++) {
$unit=$units[$i];
?>
<TR valign=top>
<td></td>
<TD align=left>
<P><B><?php print_string("multiplier", "quiz") ?>:</B>
<INPUT type="text" id="<?php p("multiplier$i") ?>" size="10"
align="RIGHT" name="multiplier[]"
value="<?php p($unit->multiplier) ?>"/>
<B> <?php print_string("unit", "quiz") ?>:</B>
<INPUT align="LEFT" type="text" id="<?php p("unit$i") ?>"
name="unit[]"
size="5" value="<?php p($unit->unit) ?>"/></P>
</TD>
</TR>
<?PHP
} /// END for
?>
</TABLE>
<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=='') {
alert('<?php print_string("missingcorrectanswer","quiz") ?>');
return false;
} else if (isNaN(correct0.value) && defaultunit.value) {
alert('<?php print_string("unitonlyworksfornumericanswers","quiz") ?>');
return false;
} else if (''!=defaultunit.value && !isNaN(defaultunit.value)) {
alert('<?php print_string("unitmustnotbenumeric","quiz") ?>');
return false;
} else if (acceptederror0.value=='') {
var correct= parseFloat(correct0.value);
if (!isNaN(correct)) {
min0.value= correct;
max0.value= correct;
correct0.value += defaultunit.value;
}
return true;
} else if (isNaN(acceptederror0.value) || isNaN(correct0.value)) {
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;
correct0.value += defaultunit.value;
return true;
}
}
}
</SCRIPT>
|