original_string: public function import_answer($answer, $withanswerfiles = false, $defaultformat = 'html') {
          $ans = new stdClass();
  
          if ($withanswerfiles) {
              $ans->answer = $this->import_text_with_files($answer, array(), '', $defaultformat);
          } else {
              $ans->answer = array();
              $ans->answer['text']   = $this->getpath($answer, array('#', 'text', 0, '#'), '', true);
              $ans->answer['format'] = FORMAT_PLAIN;
          }
  
          $ans->feedback = $this->import_text_with_files($answer, array('#', 'feedback', 0), '', $defaultformat);
  
          $ans->fraction = $this->getpath($answer, array('@', 'fraction'), 0) / 100;
  
          return $ans;
      }
code: public function import_answer($answer, $withanswerfiles = false, $defaultformat = 'html') {
          $ans = new stdClass();
  
          if ($withanswerfiles) {
              $ans->answer = $this->import_text_with_files($answer, array(), '', $defaultformat);
          } else {
              $ans->answer = array();
              $ans->answer['text']   = $this->getpath($answer, array('#', 'text', 0, '#'), '', true);
              $ans->answer['format'] = FORMAT_PLAIN;
          }
  
          $ans->feedback = $this->import_text_with_files($answer, array('#', 'feedback', 0), '', $defaultformat);
  
          $ans->fraction = $this->getpath($answer, array('@', 'fraction'), 0) / 100;
  
          return $ans;
      }
code_tokens: public function import_answer ( $ answer , $ withanswerfiles = false , $ defaultformat = 'html' ) { $ ans = new stdClass ( ) ; if ( $ withanswerfiles ) { $ ans -> answer = $ this -> import_text_with_files ( $ answer , array ( ) , '' , $ defaultformat ) ; } else { $ ans -> answer = array ( ) ; $ ans -> answer [ 'text' ] = $ this -> getpath ( $ answer , array ( '#' , 'text' , 0 , '#' ) , '' , true ) ; $ ans -> answer [ 'format' ] = FORMAT_PLAIN ; } $ ans -> feedback = $ this -> import_text_with_files ( $ answer , array ( '#' , 'feedback' , 0 ) , '' , $ defaultformat ) ; $ ans -> fraction = $ this -> getpath ( $ answer , array ( '@' , 'fraction' ) , 0 ) / 100 ; return $ ans ; }
docstring: Import the common parts of a single answer
  @param array answer xml tree for single answer
  @param bool $withanswerfiles if true, the answers are HTML (or $defaultformat)
  and so may contain files, otherwise the answers are plain text.
  @param array Default text format for the feedback, and the answers if $withanswerfiles
  is true.
  @return object answer object
docstring_tokens: Import the common parts of a single answer