original_string: 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;
          }
      }
code: 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;
          }
      }
code_tokens: 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 ; } }
docstring: 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.
docstring_tokens: Add a unit to a response for display .