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