2 <?php echo $questiontext; ?>
5 <div class="ablock clearfix">
7 <?php echo get_string("answer", "quiz").': '; ?>
9 <div class="que numerical clearfix">
15 if ( $question->options->unitsleft == 0 ){ ?>
18 <fieldset class="answer" id="generalheader">
19 <legend class="ftoggler">
21 echo $OUTPUT->help_icon('validnumberformats', 'qtype_numerical', '');
22 echo get_string('datasetnumber', 'quiz') ;
25 <input type="text" class="<?php echo $class; ?>" <?php echo "$readonly $nameanswer $valueanswer"; //
26 ?> size="<?php echo $textlength;?>" />
27 <?php echo $feedbackimg;
28 if(! $answerasterisk && $question->options->unitgradingtype != 0 && $unit_in_numerical_answer){
29 print_string('nonvalidcharactersinnumber', 'qtype_numerical');
38 <?php }// display unit
40 if ($question->options->showunits == NUMERICALQUESTIONUNITNODISPLAY || (isset($question->options->units) && count($question->options->units) == 0 )) {// no unit display or tested
51 } else if ($question->options->showunits == NUMERICALQUESTIONUNITTEXTINPUTDISPLAY ) {// display unit text input
53 <div class="answer numerical ">
54 <fieldset class="clearfix" id="generalheader">
55 <legend class="ftoggler">
57 if ( $question->options->unitgradingtype == 0 ){
58 echo $OUTPUT->help_icon('unitoptional', 'qtype_numerical', '');
59 }else { // unitgradingtype == 1
60 echo $OUTPUT->help_icon('unitmandatory', 'qtype_numerical', '');
62 echo get_string('unit', 'quiz'); ?>
64 <input type="text" class="<?php echo $classunit; ?>" <?php echo "$readonly $nameunit $valueunit"; //
65 ?> size="<?php echo $textlength;?>"/>
66 <?php echo $feedbackimgunit;
67 if ($options->feedback && $question->options->unitgradingtype == 1 && ! $valid_numerical_unit && ! $answerasterisk ){
69 print_string('unitmandatory', 'qtype_numerical');
71 if(isset($question->options->units) && count($question->options->units) > 0){
73 $valid_unit_found = 0 ;
74 foreach($question->options->units as $key => $unit){
75 if($state->responses['unit'] == $unit->unit){
76 print_string('unitnotvalid', 'qtype_numerical');
77 $valid_unit_found = 1 ;
81 if ($valid_unit_found == 0) {
82 print_string('unitunknown', 'qtype_numerical');
92 } else if ($question->options->showunits == NUMERICALQUESTIONUNITTEXTDISPLAY ) {// display text
96 <fieldset class="clearfix" id="generalheader">
97 <legend class="ftoggler">
98 <?php echo get_string('unit', 'quiz');
103 echo $nameunit; echo $valueunit ;
107 <?php echo $question->options->units[0]->unit ;
116 //display the units as choice
118 } else if ($question->options->showunits == NUMERICALQUESTIONUNITMULTICHOICEDISPLAY){?>
123 //display the units as choice
124 if ( isset($question->options->units)){?>
126 <fieldset class="clearfix" id="generalheader">
127 <legend class="ftoggler">
129 echo get_string('selectunit', 'qtype_numerical');
135 // the order is not shuffled
136 //however the unitvalue is related to the number value
137 // if the response/unit->multiplier is true then
139 // if(isset($state->responses['unit']) && $state->responses['unit'] != '' ){
140 $valid_numerical_unit_index = -1;
141 foreach ($question->options->units as $key => $unit) {
145 $feedbackimgunit = question_get_feedback_image(0);
146 $valid_numerical_unit = false ;
148 $type = 'type="radio"';
149 // echo "<p> boucle unit $key $unit->unit answerfraction $answer->fraction classunit $classunit index $valid_numerical_unit_index $key response $response $unit->multiplier $unit->unit state <pre>";print_r($answer);echo "</pre></p>";
150 if(isset($state->responses['unit']) && $state->responses['unit'] != '' ){
151 // $nameunit = "name=\"".$question->name_prefix;//."unit\"";
152 // if (isset($response->number) && $response->number != false && isset($state->responses['unit']) && $state->responses['unit'] != '' ){
153 // if ($unit->unit == $state->responses['unit']){
154 // test if the numerical value as is or as multiplied by this unit
155 // could give a good response
156 // we need to extract the numerical and apply it with this unit
158 $testresponse = $state->responses['answer']/$unit->multiplier ;
159 /* if(isset($state->responses['unit'])){
160 $testresponse .= $state->responses['unit'] ;
162 $response = $this->apply_unit($testresponse, array($question->options->units[$key])) ;
163 $invalid_unit_found = 0 ;
164 if ($response !== false) {
165 $this->get_tolerance_interval($answer);
166 if($answer->min <= $response && $response <= $answer->max){
167 // then it could give a good response
168 // has it been used ?
169 $classunit = 1; // or max response i.e. 1
170 $feedbackimgunit = question_get_feedback_image($rawgrade);
171 $valid_numerical_unit = true ;
174 $valid_numerical_unit_index = $key ;
178 // if ($unit->unit == $state->responses['unit']){
179 // we have a valid unit response
180 if($answerasterisk || $valid_numerical_unit_index == $key ){
181 $classunit = $rawgrade ; //question_get_feedback_class(1) ; // ;
183 // we have a unit response
184 // this unit is the one chosen
185 // test if the unit give a valid response
186 // $testresponse = $response->number /$unit->multiplier ;
187 // if($answerasterisk || ($answer->min <= $testresponse && $testresponse <= $answer->max)) {
188 // $classunitvalue = $answer->fraction ;
190 // echo "<p> dans display $answer->fraction classunit $classunit index $valid_numerical_unit_index $key response $response $unit->multiplier $unit->unit state <pre>";print_r($answer);echo "</pre></p>";
191 // if ($state->responses['unit'] == $unit->unit) {
192 if (isset($state->responses['unit']) && $unit->unit == $state->responses['unit']){
193 $checked = 'checked="checked"';
200 $aid = $question->id ;
202 $a->id = $question->name_prefix."unit" ;//. "2"
204 $a->feedbackimg = '';
206 $a->control = "<input $readonly $nameunit $checked $type value=\"$key\" />";
208 if ($options->correct_responses && $classunit > 0 ) { //$answer->fraction
209 $a->class = question_get_feedback_class($classunit);
211 if (($options->feedback && $chosen) || $options->correct_responses) {
212 $a->feedbackimg = question_get_feedback_image($classunit, $chosen && $options->feedback);
216 // Print the answer text
217 $a->text = format_text($unit->unit, FORMAT_MOODLE, $formatoptions, $cmoptions->course);
221 <tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>">
222 <td class="c0 control " style=" ">
223 <?php echo $a->control.' '; ?>
225 <td style=" " class="c1 text <?php echo $a->class ?>">
226 <label for="<?php echo $a->id ?>">
227 <?php echo $a->text.'<br />'; ?>
228 <?php echo $a->feedbackimg;
229 if ($options->feedback && $classunit == 0 && $chosen && !$answerasterisk){
230 print_string('unitnotvalid', 'qtype_numerical');
232 echo ' ';
240 <?php if ($options->feedback && isset($state->responses['answer'])&& $state->responses['answer'] != '' && (!isset($state->responses['unit']) || $state->responses['unit'] == '') && ! $answerasterisk ){
242 print_string('unitnotselected', 'qtype_numerical');
248 <?php } // end unit choices
249 // display intructions
250 // general message first
253 if ($question->options->unitsleft == 1 ){?>
256 <fieldset class="clearfix" id="generalheader">
257 <legend class="ftoggler">
259 echo $OUTPUT->help_icon('validnumberformats', 'qtype_numerical', '');
260 echo get_string('datasetnumber', 'quiz');
263 <input type="text" class="<?php echo $class; ?>" <?php echo "$readonly $nameanswer $valueanswer"; //
264 ?> size="<?php echo $textlength;?>"/>
265 <?php echo $feedbackimg; ?>
270 //</div> put a div to enclose the answer and unit elements
275 <?php if (!empty($question->options->instructions)){?>
276 <div class="feedback">
277 <fieldset class="clearfix" id="generalheader">
278 <legend class="ftoggler">
279 <?php echo get_string('instructions', 'auth'); ?>
282 <?php echo format_text($question->options->instructions, $question->options->instructionsformat, $formatoptions, $cmoptions->course);?>
288 <?php if ($feedback) { ?>
289 <div class="feedback">
290 <?php echo $feedback ?>
293 <?php $this->print_question_submit_buttons($question, $state, $cmoptions, $options); ?>