// Substitute variables in questiontext before giving the data to the
// virtual type for printing
$virtualqtype = $this->get_virtual_qtype();
- $unit = $virtualqtype->get_default_numerical_unit($question);
-
+ if($unit = $virtualqtype->get_default_numerical_unit($question)){
+ $unit = $unit->unit;
+ } else {
+ $unit = '';
+ }
// We modify the question to look like a numerical question
$numericalquestion = fullclone($question);
foreach ($numericalquestion->options->answers as $key => $answer) {
$correctanswer = qtype_calculated_calculate_answer(
$answer->answer, $state->options->dataset, $answer->tolerance,
$answer->tolerancetype, $answer->correctanswerlength,
- $answer->correctanswerformat, $unit->unit);
+ $answer->correctanswerformat, $unit);
$numericalquestion->options->answers[$key]->answer = $correctanswer->answer;
}
$numericalquestion->questiontext = parent::substitute_variables(
function get_correct_responses(&$question, &$state) {
$virtualqtype = $this->get_virtual_qtype();
- $unit = $virtualqtype->get_default_numerical_unit($question);
+ if($unit = $virtualqtype->get_default_numerical_unit($question)){
+ $unit = $unit->unit;
+ } else {
+ $unit = '';
+ }
foreach ($question->options->answers as $answer) {
if (((int) $answer->fraction) === 1) {
$answernumerical = qtype_calculated_calculate_answer(
$answer->answer, $state->options->dataset, $answer->tolerance,
$answer->tolerancetype, $answer->correctanswerlength,
- $answer->correctanswerformat, $unit->unit);
+ $answer->correctanswerformat, $unit);
return array('' => $answernumerical->answer);
}
}