public function add_unit($questiondata, $answer, $unit = null) {
        if (is_null($unit)) {
            $unit = $this->get_default_numerical_unit($questiondata);
        }

        if (!$unit) {
            return $answer;
        }

        if (!empty($questiondata->options->unitsleft)) {
            return $unit->unit . ' ' . $answer;
        } else {
            return $answer . ' ' . $unit->unit;
        }
    }
public function add_unit($questiondata, $answer, $unit = null) {
        if (is_null($unit)) {
            $unit = $this->get_default_numerical_unit($questiondata);
        }

        if (!$unit) {
            return $answer;
        }

        if (!empty($questiondata->options->unitsleft)) {
            return $unit->unit . ' ' . $answer;
        } else {
            return $answer . ' ' . $unit->unit;
        }
    }
public function add_unit ( $ questiondata , $ answer , $ unit = null ) { if ( is_null ( $ unit ) ) { $ unit = $ this -> get_default_numerical_unit ( $ questiondata ) ; } if ( ! $ unit ) { return $ answer ; } if ( ! empty ( $ questiondata -> options -> unitsleft ) ) { return $ unit -> unit . ' ' . $ answer ; } else { return $ answer . ' ' . $ unit -> unit ; } }
Add a unit to a response for display.
@param object $questiondata the data defining the quetsion.
@param string $answer a response.
@param object $unit a unit. If null, {@link get_default_numerical_unit()}
is used.
Add a unit to a response for display .