Commit | Line | Data |
---|---|---|
94909089 PP |
1 | <div class="qtext"> |
2 | <?php echo $questiontext; ?> | |
3 | </div> | |
aeb15530 | 4 | |
94909089 PP |
5 | <?php if ($image) { ?> |
6 | <img class="qimage" src="<?php echo $image; ?>" alt="" /> | |
7 | <?php } ?> | |
aeb15530 | 8 | |
94909089 PP |
9 | <div class="ablock clearfix"> |
10 | <div class="prompt"> | |
11 | <?php echo get_string("answer", "quiz").': '; ?> | |
12 | </div> | |
ca3ede76 | 13 | <div class="que numerical clearfix"> |
94909089 | 14 | <?php |
b003b818 | 15 | $textlength = 20 ; |
16 | ?> | |
17 | ||
18 | <?php | |
19 | if ( $question->options->unitsleft == 0 ){ ?> | |
20 | ||
21 | <div class="answer"> | |
22 | <fieldset class="answer" id="generalheader"> | |
4454447d PS |
23 | <legend class="ftoggler"> |
24 | <?php echo get_string('datasetnumber', 'quiz') ; ?> | |
25 | </legend> | |
b003b818 | 26 | <input type="text" class="<?php echo $class; ?>" <?php echo "$readonly $nameanswer $valueanswer"; // |
27 | ?> size="<?php echo $textlength;?>" /> | |
28 | <?php echo $feedbackimg; ?> | |
29 | </fieldset> | |
30 | </div> | |
aeb15530 PS |
31 | |
32 | ||
b003b818 | 33 | <?php }// display unit |
94909089 | 34 | |
04e91671 | 35 | if ($question->options->showunits == NUMERICALQUESTIONUNITNODISPLAY || (isset($question->options->units) && count($question->options->units) == 0 )) {// no unit display or tested |
aeb15530 | 36 | |
b003b818 | 37 | ?> |
38 | <div class="answer"> | |
aeb15530 PS |
39 | <input type="hidden" |
40 | <?php | |
41 | echo $nameunit; | |
42 | ?> | |
b003b818 | 43 | value ="" /> |
44 | </div> | |
45 | <?php | |
04e91671 | 46 | } else if ($question->options->showunits == NUMERICALQUESTIONUNITTEXTINPUTDISPLAY ) {// display unit text input |
aeb15530 | 47 | ?> |
ca3ede76 | 48 | <div class="answer numerical "> |
b003b818 | 49 | <fieldset class="clearfix" id="generalheader"> |
4454447d PS |
50 | <legend class="ftoggler"> |
51 | <?php echo get_string('unit', 'quiz'); ?> | |
52 | </legend> | |
b003b818 | 53 | <input type="text" class="<?php echo $classunit; ?>" <?php echo "$readonly $nameunit $valueunit"; // |
54 | ?> size="<?php echo $textlength;?>"/> | |
94909089 PP |
55 | <?php echo $feedbackimgunit; |
56 | if ($options->feedback && $classunitvalue == 0 && ! $answerasterisk ){ | |
57 | if(isset($question->options->units) && count($question->options->units) > 0){ | |
58 | $found = 0 ; | |
59 | foreach($question->options->units as $key => $unit){ | |
60 | if($state->responses['unit'] == $unit->unit){ | |
61 | print_string('unitnotvalid', 'qtype_numerical'); | |
62 | $found = 1 ; | |
63 | break; | |
64 | } | |
65 | } | |
66 | if ($found == 0) { | |
67 | print_string('unitunknown', 'qtype_numerical'); | |
68 | } | |
69 | } | |
70 | } | |
71 | ||
72 | ?> | |
b003b818 | 73 | </fieldset> |
74 | </div> | |
aeb15530 | 75 | <?php |
b003b818 | 76 | |
04e91671 | 77 | } else if ($question->options->showunits == NUMERICALQUESTIONUNITTEXTDISPLAY ) {// display text |
aeb15530 | 78 | |
b003b818 | 79 | ?> |
80 | <div class="answer"> | |
81 | <fieldset class="clearfix" id="generalheader"> | |
4454447d PS |
82 | <legend class="ftoggler"> |
83 | <?php echo get_string('unit', 'quiz'); | |
4454447d PS |
84 | ?> |
85 | </legend> | |
aeb15530 PS |
86 | <input type="hidden" |
87 | <?php | |
88 | echo $nameunit; echo $valueunit ; | |
b003b818 | 89 | |
aeb15530 | 90 | ?> |
b003b818 | 91 | /> |
92 | <?php echo $question->options->units[0]->unit ; | |
93 | ||
aeb15530 | 94 | echo ' ' ; |
b003b818 | 95 | ?> |
96 | </fieldset> | |
97 | </div> | |
aeb15530 | 98 | |
b003b818 | 99 | <?php |
100 | ||
aeb15530 PS |
101 | //display the units as choice |
102 | ||
04e91671 | 103 | } else if ($question->options->showunits == NUMERICALQUESTIONUNITMULTICHOICEDISPLAY){?> |
b003b818 | 104 | |
105 | ||
aeb15530 PS |
106 | |
107 | <?php | |
108 | //display the units as choice | |
04e91671 | 109 | if ( isset($question->options->units)){?> |
b003b818 | 110 | <div class="answer"> |
aa384ade PP |
111 | <fieldset class="clearfix" id="generalheader"> |
112 | <legend class="ftoggler"> | |
113 | <?php echo get_string('unit', 'quiz'); | |
114 | ?> | |
115 | </legend> | |
b003b818 | 116 | <table class="answer"> |
117 | ||
94909089 PP |
118 | <?php |
119 | // the order is not shuffled | |
120 | //however the unitvalue is related to the number value | |
121 | // if the response/unit->multiplier is true then | |
122 | // the | |
123 | ||
124 | foreach ($question->options->units as $key => $unit) { | |
b003b818 | 125 | $checked = ''; |
126 | $chosen = false; | |
94909089 | 127 | $classunitvalue = 0 ; |
b003b818 | 128 | $type = 'type="radio"'; |
129 | // $nameunit = "name=\"".$question->name_prefix;//."unit\""; | |
ca3ede76 | 130 | if ($response != '' && isset($state->responses['unit']) && $state->responses['unit'] != '' ){ |
94909089 PP |
131 | // we have a unit response |
132 | // this unit is the one chosen | |
133 | // test if the unit give a valid response | |
134 | $testresponse = $response /$unit->multiplier ; | |
135 | if($answerasterisk || ($answer->min <= $testresponse && $testresponse <= $answer->max)) { | |
136 | $classunitvalue = $answer->fraction ; | |
137 | } | |
138 | // echo "<p> dans display classunitvalue $classunitvalue response $response $unit->multiplier $unit->unit state <pre>";print_r($answer);echo "</pre></p>"; | |
139 | if ($state->responses['unit'] == $unit->unit) { | |
140 | $checked = 'checked="checked"'; | |
141 | $chosen = true; | |
142 | ||
143 | } | |
b003b818 | 144 | }else if ($key == 0) { |
145 | $checked = 'checked="checked"'; | |
146 | $chosen = true; | |
147 | } | |
aeb15530 PS |
148 | |
149 | $aid = $question->id ; | |
b003b818 | 150 | $a = new stdClass; |
151 | $a->id = $question->name_prefix."unit" ;//. "2" | |
94909089 | 152 | $a->class = '' ; |
b003b818 | 153 | $a->feedbackimg = ''; |
154 | ||
b003b818 | 155 | $a->control = "<input $readonly $nameunit $checked $type value=\"$key\" />"; |
156 | ||
94909089 PP |
157 | if ($options->correct_responses && $classunitvalue > 0 ) { //$answer->fraction |
158 | $a->class = question_get_feedback_class($classunitvalue); | |
b003b818 | 159 | } |
160 | if (($options->feedback && $chosen) || $options->correct_responses) { | |
94909089 PP |
161 | /* if ($type == ' type="checkbox" ') { |
162 | // $a->feedbackimg = question_get_feedback_image($answer->fraction > 0 ? 1 : 0, $chosen && $options->feedback); | |
163 | $a->feedbackimg = question_get_feedback_image($classunitvalue, $chosen && $options->feedback); | |
164 | ||
165 | } else {*/ | |
166 | $a->feedbackimg = question_get_feedback_image($classunitvalue, $chosen && $options->feedback); | |
167 | ||
168 | // } | |
b003b818 | 169 | } |
170 | ||
94909089 | 171 | // Print the control |
b003b818 | 172 | // Print the answer text |
173 | $a->text = format_text($unit->unit, FORMAT_MOODLE, $formatoptions, $cmoptions->course); | |
174 | $row = 0 ; | |
175 | ||
176 | ?> | |
177 | <tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>"> | |
178 | <td class="c0 control"> | |
179 | <?php echo $a->control; ?> | |
180 | </td> | |
181 | <td class="c1 text <?php echo $a->class ?>"> | |
182 | <label for="<?php echo $a->id ?>"> | |
183 | <?php echo $a->text; ?> | |
94909089 PP |
184 | <?php echo $a->feedbackimg; |
185 | if ($options->feedback && $classunitvalue == 0 && $chosen && !$answerasterisk){ | |
186 | print_string('unitnotvalid', 'qtype_numerical'); | |
187 | } | |
188 | ?> | |
b003b818 | 189 | </label> |
190 | </td> | |
191 | </tr> | |
192 | <?php } ?> | |
193 | ||
194 | </table> | |
aa384ade | 195 | </fieldset> |
aeb15530 PS |
196 | |
197 | </div> | |
b003b818 | 198 | <?php } // end unit choices |
199 | // display intructions | |
200 | // general message first | |
201 | } | |
aeb15530 | 202 | |
b003b818 | 203 | if ($question->options->unitsleft == 1 ){?> |
aeb15530 | 204 | |
b003b818 | 205 | <div class="answer"> |
206 | <fieldset class="clearfix" id="generalheader"> | |
4454447d PS |
207 | <legend class="ftoggler"> |
208 | <?php echo get_string('datasetnumber', 'quiz'); ?> | |
209 | </legend> | |
b003b818 | 210 | <input type="text" class="<?php echo $class; ?>" <?php echo "$readonly $nameanswer $valueanswer"; // |
211 | ?> size="<?php echo $textlength;?>"/> | |
212 | <?php echo $feedbackimg; ?> | |
213 | </fieldset> | |
aeb15530 PS |
214 | </div> |
215 | <?php } | |
ca3ede76 | 216 | |
b003b818 | 217 | //</div> put a div to enclose the answer and unit elements |
218 | ?> | |
ca3ede76 | 219 | </div> |
b003b818 | 220 | |
221 | ||
222 | <div class="feedback"> | |
223 | <fieldset class="clearfix" id="generalheader"> | |
4454447d PS |
224 | <legend class="ftoggler"> |
225 | <?php echo get_string('instructions', 'auth'); ?> | |
226 | </legend> | |
b003b818 | 227 | <div class="feedback"> |
5774a5f5 | 228 | <fieldset class="clearfix" id="generalheader"> |
4454447d | 229 | <legend class="ftoggler"> |
5774a5f5 | 230 | <?php echo get_string('validnumberformats', 'qtype_numerical');?> |
4454447d | 231 | </legend> |
94909089 PP |
232 | <?php echo get_string('validnumbers', 'qtype_numerical'); |
233 | ||
234 | ?> | |
235 | ||
aeb15530 | 236 | </fieldset> |
b003b818 | 237 | </div> |
238 | <?php if (!empty($question->options->instructions)){?> | |
239 | <div> | |
240 | <?php echo format_text($question->options->instructions, true, $formatoptions, $cmoptions->course);?> | |
aeb15530 PS |
241 | </div> |
242 | <?php }?> | |
243 | </fieldset> | |
244 | </div> | |
b003b818 | 245 | |
94909089 PP |
246 | <?php if ($feedback) { ?> |
247 | <div class="feedback"> | |
248 | <?php echo $feedback ?> | |
249 | </div> | |
250 | <?php } ?> | |
251 | <?php $this->print_question_submit_buttons($question, $state, $cmoptions, $options); ?> | |
252 | </div> | |
253 | ||
b003b818 | 254 |