mirrored from git://git.moodle.org/moodle.git
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
/
calculated.html
171 lines (166 loc) · 6.26 KB
/
calculated.html
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
<FORM name="theform" method="post" <?php echo $onsubmit ?> action="question.php">
<CENTER>
<INPUT type="hidden" name="nextwizardpage" value="<?php p($nextwizardpage)?>"/>
<?php foreach ($calculatedmessages as $message) {formerr("$message<br/>");} ?>
<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, 20, 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 ": ";
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("correctanswerformula", "quiz") ?>:</B></P></TD>
<TD>
<INPUT align="LEFT" type="text" id="formula0" name="answer[]" size="20" value="<?php p($answers[0]->answer) ?>"/>
<INPUT type="hidden" name="fraction[]" value="1.0"/>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string("tolerance", "quiz"); ?>:</B></P></TD>
<TD>
<INPUT align="LEFT" type="text" id=tolerance0" name="tolerance[]" size="15" value="<?php p($answers[0]->tolerance) ?>" />±
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string("tolerancetype", "quiz"); ?>:</B></P></TD>
<TD>
<?php choose_from_menu($qtypeobj->tolerance_types(),
'tolerancetype[]', $answers[0]->tolerancetype, false); ?>
</TD>
</TR>
<TR valign=top>
<TD align=right><P><B><?php print_string("correctanswerlength", "quiz"); ?>:</B></P></TD>
<TD>
<?php choose_from_menu(array('1' => '1', '2' => '2', '3' => '3',
'4' => '4', '5' => '5', '6' => '6',
'7' => '7', '8' => '8', '9' => '9',
'10' => '10'),
'correctanswerlength[]',
$answers[0]->correctanswerlength, false); ?>
</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 (formula0.value=='') {
alert('<?php print_string("missingformula","quiz") ?>');
return false;
/* It could perhaps be an idea to parse the formula here
* but as it is necessary at the server anyway, we can
* leave like this for the moment. */
} else if (''!=defaultunit.value && !isNaN(defaultunit.value)) {
alert('<?php print_string("unitmustnotbenumeric","quiz") ?>');
return false;
} else if (isNaN(tolerance0.value)) {
alert('<?php print_string("tolerancemustbenumeric","quiz") ?>');
return false;
} else {
return true;
}
}
}
</script>