original_string: protected function write_answers(array $answers, $qtype) {
  
          $this->xmlwriter->begin_tag('answers');
          foreach ($answers as $elementname => $elements) {
              foreach ($elements as $element) {
                  $answer = $this->convert_answer($element, $qtype);
                  // Migrate images in answertext.
                  if ($answer['answerformat'] == FORMAT_HTML) {
                      $answer['answertext'] = $this->migrate_files($answer['answertext'], 'question', 'answer', $answer['id']);
                  }
                  // Migrate images in feedback.
                  if ($answer['feedbackformat'] == FORMAT_HTML) {
                      $answer['feedback'] = $this->migrate_files($answer['feedback'], 'question', 'answerfeedback', $answer['id']);
                  }
                  $this->write_xml('answer', $answer, array('/answer/id'));
              }
          }
          $this->xmlwriter->end_tag('answers');
      }
code: protected function write_answers(array $answers, $qtype) {
  
          $this->xmlwriter->begin_tag('answers');
          foreach ($answers as $elementname => $elements) {
              foreach ($elements as $element) {
                  $answer = $this->convert_answer($element, $qtype);
                  // Migrate images in answertext.
                  if ($answer['answerformat'] == FORMAT_HTML) {
                      $answer['answertext'] = $this->migrate_files($answer['answertext'], 'question', 'answer', $answer['id']);
                  }
                  // Migrate images in feedback.
                  if ($answer['feedbackformat'] == FORMAT_HTML) {
                      $answer['feedback'] = $this->migrate_files($answer['feedback'], 'question', 'answerfeedback', $answer['id']);
                  }
                  $this->write_xml('answer', $answer, array('/answer/id'));
              }
          }
          $this->xmlwriter->end_tag('answers');
      }
code_tokens: protected function write_answers ( array $ answers , $ qtype ) { $ this -> xmlwriter -> begin_tag ( 'answers' ) ; foreach ( $ answers as $ elementname => $ elements ) { foreach ( $ elements as $ element ) { $ answer = $ this -> convert_answer ( $ element , $ qtype ) ; // Migrate images in answertext. if ( $ answer [ 'answerformat' ] == FORMAT_HTML ) { $ answer [ 'answertext' ] = $ this -> migrate_files ( $ answer [ 'answertext' ] , 'question' , 'answer' , $ answer [ 'id' ] ) ; } // Migrate images in feedback. if ( $ answer [ 'feedbackformat' ] == FORMAT_HTML ) { $ answer [ 'feedback' ] = $ this -> migrate_files ( $ answer [ 'feedback' ] , 'question' , 'answerfeedback' , $ answer [ 'id' ] ) ; } $ this -> write_xml ( 'answer' , $ answer , array ( '/answer/id' ) ) ; } } $ this -> xmlwriter -> end_tag ( 'answers' ) ; }
docstring: Converts the answers and writes them into the questions.xml
  
  The structure "answers" is used by several qtypes. It contains data from {question_answers} table.
  
  @param array $answers as parsed by the grouped parser in moodle.xml
  @param string $qtype containing the answers
docstring_tokens: Converts the answers and writes them into the questions . xml