options->unitsleft == 0 ){ ?>
help_icon('validnumberformats', 'qtype_numerical', ''); echo get_string('datasetnumber', 'quiz') ; ?> size="" /> options->unitgradingtype != 0 && $unit_in_numerical_answer){ print_string('nonvalidcharactersinnumber', 'qtype_numerical'); } ?>
options->showunits == NUMERICALQUESTIONUNITNODISPLAY || (isset($question->options->units) && count($question->options->units) == 0 )) {// no unit display or tested ?>
value ="" />
options->showunits == NUMERICALQUESTIONUNITTEXTINPUTDISPLAY ) {// display unit text input ?>
options->unitgradingtype == 0 ){ echo $OUTPUT->help_icon('unitoptional', 'qtype_numerical', ''); }else { // unitgradingtype == 1 echo $OUTPUT->help_icon('unitmandatory', 'qtype_numerical', ''); } echo get_string('unit', 'quiz'); if ($state->responses['unit'] == '')$classunit = ''; ?> size=""/> responses['unit'] != '') echo $feedbackimgunit; if ($options->feedback && $question->options->unitgradingtype == 1 && ! $valid_numerical_unit && ! $answerasterisk ){ if (!empty($empty_unit)) { print_string('unitmandatory', 'qtype_numerical'); } else { if(isset($question->options->units) && count($question->options->units) > 0){ $found = 0 ; $valid_unit_found = 0 ; foreach($question->options->units as $key => $unit){ if($state->responses['unit'] == $unit->unit){ print_string('unitnotvalid', 'qtype_numerical'); $valid_unit_found = 1 ; break; } } if ($valid_unit_found == 0) { print_string('unitunknown', 'qtype_numerical'); } } } } ?>
options->showunits == NUMERICALQUESTIONUNITTEXTDISPLAY ) {// display text ?>
/> options->units[0]->unit; echo '  '; ?>
options->showunits == NUMERICALQUESTIONUNITMULTICHOICEDISPLAY){?> options->units)){?>
multiplier is true then // the // if(isset($state->responses['unit']) && $state->responses['unit'] != '' ){ $valid_numerical_unit_index = -1; foreach ($question->options->units as $key => $unit) { $checked = ''; $chosen = false; $classunit = 0 ; $feedbackimgunit = question_get_feedback_image(0); $valid_numerical_unit = false ; $validunit = false ; $type = 'type="radio"'; // echo "

boucle unit $key $unit->unit answerfraction $answer->fraction classunit $classunit index $valid_numerical_unit_index $key response $response $unit->multiplier $unit->unit state

";print_r($answer);echo "

"; if(isset($state->responses['unit']) && $state->responses['unit'] != '' ){ // $nameunit = "name=\"".$question->name_prefix;//."unit\""; // if (isset($response->number) && $response->number != false && isset($state->responses['unit']) && $state->responses['unit'] != '' ){ // if ($unit->unit == $state->responses['unit']){ // test if the numerical value as is or as multiplied by this unit // could give a good response // we need to extract the numerical and apply it with this unit // as if it was used $testresponse = $state->responses['answer']/$unit->multiplier ; /* if(isset($state->responses['unit'])){ $testresponse .= $state->responses['unit'] ; } */ $response = $this->apply_unit($testresponse, array($question->options->units[$key])) ; $invalid_unit_found = 0 ; if ($response !== false) { $this->get_tolerance_interval($answer); if($answer->min <= $response && $response <= $answer->max){ // then it could give a good response // has it been used ? $classunit = 1; // or max response i.e. 1 $feedbackimgunit = question_get_feedback_image($rawgrade); $valid_numerical_unit = true ; $validunit = true ; $valid_numerical_unit_index = $key ; } } } // if ($unit->unit == $state->responses['unit']){ // we have a valid unit response if($answerasterisk || $valid_numerical_unit_index == $key ){ $classunit = $rawgrade ; //question_get_feedback_class(1) ; // ; } // we have a unit response // this unit is the one chosen // test if the unit give a valid response // $testresponse = $response->number /$unit->multiplier ; // if($answerasterisk || ($answer->min <= $testresponse && $testresponse <= $answer->max)) { // $classunitvalue = $answer->fraction ; // } // echo "

dans display $answer->fraction classunit $classunit index $valid_numerical_unit_index $key response $response $unit->multiplier $unit->unit state

";print_r($answer);echo "

"; // if ($state->responses['unit'] == $unit->unit) { if (isset($state->responses['unit']) && $unit->unit == $state->responses['unit']){ $checked = 'checked="checked"'; $chosen = true; }else { $checked = ''; } $aid = $question->id ; $a = new stdClass; $a->id = $question->name_prefix."unit" ;//. "2" $a->class = '' ; $a->feedbackimg = ''; $a->control = ""; if ($options->correct_responses && $classunit > 0 ) { //$answer->fraction $a->class = question_get_feedback_class($classunit); } if (($options->feedback && $chosen) || $options->correct_responses) { $a->feedbackimg = question_get_feedback_image($classunit, $chosen && $options->feedback); } // Print the control // Print the answer text $a->text = s($unit->unit); $row = 0 ; ?>
control.'   '; ?>
feedback && isset($state->responses['answer'])&& $state->responses['answer'] != '' && (!isset($state->responses['unit']) || $state->responses['unit'] == '') && ! $answerasterisk ){ print_string('unitnotselected', 'qtype_numerical'); } ?>
options->unitsleft == 1 ){?>
help_icon('validnumberformats', 'qtype_numerical', ''); echo get_string('datasetnumber', 'quiz'); ?> size=""/>
put a div to enclose the answer and unit elements ?>
options->instructions)){?>
options->instructions, $question->options->instructionsformat, $formatoptions, $cmoptions->course);?>
print_question_submit_buttons($question, $state, $cmoptions, $options); ?>