}else { // unitgradingtype == 1
echo $OUTPUT->help_icon('unitmandatory', 'qtype_numerical', '');
}
- echo get_string('unit', 'quiz'); ?>
+ echo get_string('unit', 'quiz');
+ if ($state->responses['unit'] == '')$classunit = '';
+ ?>
</legend>
<input type="text" class="<?php echo $classunit; ?>" <?php echo "$readonly $nameunit $valueunit"; //
?> size="<?php echo $textlength;?>"/>
- <?php echo $feedbackimgunit;
+ <?php if ($state->responses['unit'] != '') echo $feedbackimgunit;
if ($options->feedback && $question->options->unitgradingtype == 1 && ! $valid_numerical_unit && ! $answerasterisk ){
if ( $empty_unit) {
print_string('unitmandatory', 'qtype_numerical');
$answertotest = $state->responses['answer'];
// values coming from NUMERICALQUESTIONUNITTEXTINPUTDISPLAY
// or NUMERICALQUESTIONUNITTEXTDISPLAY as unit hidden HTML element
+
+ if($question->options->showunits == NUMERICALQUESTIONUNITTEXTINPUTDISPLAY ){
+ //
+ $testresponse = $this->extract_numerical_response($state->responses['answer']);
+ if($testresponse->unit != '' || $testresponse->number === false){
+ return false;
+ }
+ $answertotest = $testresponse->number ;
+ }
if(isset($state->responses['unit'])) {
- $answertotest .= $state->responses['unit'] ;
+ $answertotest .= $state->responses['unit'] ;
}
// if ($question->options->showunits == NUMERICALQUESTIONUNITTEXTDISPLAY && isset($question->options->units[0])){
// $answertotest .= $question->options->units[0]->unit ;