name_prefix."unit\""; $nameanswer = "name=\"".$question->name_prefix."answer\""; //if left unit is placed before answer so we need to answer field text and a center pice for the show units options // split the respnse in 2 element numerical and units /*if (!empty($question->options->showunits)){ if(isset($question->options->units) && count($question->options->units)){ $length = 0; $goodkey = 0 ; foreach ($question->options->units as $key => $unit){ if (false === stripos($value, $unit->unit)){ }else{ if(strlen($unit->unit)> $length) {$length =strlen($unit->unit); $goodkey = $key ; } } } if($length){ $value = str_replace($question->options->units[$goodkey]->unit, '' , $value); } $state->responses['unit']=$goodkey ;
} }*/ if (isset($state->responses['answer']) && $state->responses['answer']!='') { $valueanswer = ' value="'.s($state->responses['answer']).'" '; } else { $valueanswer = ' value="" '; } if (isset($state->responses['unit']) && $state->responses['unit']!='') { $valueunit = ' value="'.s($state->responses['unit']).'" '; } else { $valueunit = ' value="" '; if ($question->options->showunits == 2 ){ $valueunit = ' value="'.s($question->options->units[0]->unit).'" '; } } // put a div to enclose the answer and unit elements
$textlength = 20 ; ?> options->unitsleft == 0 ){ ?>
size="" />
feedback){ $classunit = question_get_feedback_class(1-$this->raw_unitpenalty); $feedbackimgunit = question_get_feedback_image(1-$this->raw_unitpenalty, $options->feedback); } if ($question->options->showunits == 3 || (isset($question->options->units) && count($question->options->units) == 0 )) {// no unit display or tested ?>
value ="" />
options->showunits == 0 ) {// display unit text input ?>
size=""/>
options->showunits == 2 ) {// display text ?>
options->units[0]->unit ; ?> /> options->units[0]->unit ; echo '  ' ; ?>
options->showunits == 1){?> options->showunits == 1 && isset($question->options->units)){?>
options->units as $key => $unit) { $checked = ''; $chosen = false; $type = 'type="radio"'; // $nameunit = "name=\"".$question->name_prefix;//."unit\""; if (isset($state->responses['unit'])){ if ($state->responses['unit'] == $unit->unit) { $checked = 'checked="checked"'; $chosen = true; } }else if ($key == 0) { $checked = 'checked="checked"'; $chosen = true; } $aid = $question->id ; $a = new stdClass; $a->id = $question->name_prefix."unit" ;//. "2" $a->class = ''; $a->feedbackimg = ''; // Print the control $a->control = ""; if ($options->correct_responses && $answer->fraction > 0) { $a->class = question_get_feedback_class(1); } if (($options->feedback && $chosen) || $options->correct_responses) { if ($type == ' type="checkbox" ') { $a->feedbackimg = question_get_feedback_image($answer->fraction > 0 ? 1 : 0, $chosen && $options->feedback); } else { $a->feedbackimg = question_get_feedback_image($answer->fraction, $chosen && $options->feedback); } } // Print the answer text $a->text = format_text($unit->unit, FORMAT_MOODLE, $formatoptions, $cmoptions->course); $row = 0 ; ?>
control; ?>
options->unitsleft == 1 ){?>
size=""/>
put a div to enclose the answer and unit elements ?>
options->instructions)){?>
options->instructions, true, $formatoptions, $cmoptions->course);?>