/**
  * Provide export functionality for xml format
  * As answers field in question_jme contains answers ids we can't use typebase method.
  * @param question object the question object
  * @param format object the format object so that helper methods can be used
  * @param extra mixed any additional format specific data that may be passed by the format (see format code for info)
  * @return string the data to append to the output buffer or false if error
  */
 public function export_to_xml($question, qformat_xml $format, $extra = null)
 {
     $extraquestionfields = $this->extra_question_fields();
     array_shift($extraquestionfields);
     $expout = '';
     foreach ($extraquestionfields as $field) {
         $exportedvalue = $format->xml_escape($question->options->{$field});
         $expout .= "    <{$field}>{$exportedvalue}</{$field}>\n";
     }
     // Write out all the answers.
     $expout .= $format->write_answers($question->options->answers);
     return $expout;
 }
 /**
  * Provide export functionality for xml format
  * @param question object the question object
  * @param format object the format object so that helper methods can be used
  * @param extra mixed any additional format specific data that may be passed by the format (see format code for info)
  * @return string the data to append to the output buffer or false if error
  */
 public function export_to_xml($question, qformat_xml $format, $extra = null)
 {
     $expout = '';
     $fs = get_file_storage();
     $contextid = $question->contextid;
     $expout .= "    <shuffleanswers>" . $format->get_single($question->options->shuffleanswers) . "</shuffleanswers>\n";
     $textformat = $format->get_format($question->options->correctfeedbackformat);
     $files = $fs->get_area_files($contextid, 'question', 'correctfeedback', $question->id);
     $expout .= "    <correctfeedback format=\"{$textformat}\">\n" . '      ' . $format->writetext($question->options->correctfeedback);
     $expout .= $format->write_files($files);
     $expout .= "    </correctfeedback>\n";
     $textformat = $format->get_format($question->options->incorrectfeedbackformat);
     $files = $fs->get_area_files($contextid, 'question', 'incorrectfeedback', $question->id);
     $expout .= "    <incorrectfeedback format=\"{$textformat}\">\n" . '      ' . $format->writetext($question->options->incorrectfeedback);
     $expout .= $format->write_files($files);
     $expout .= "    </incorrectfeedback>\n";
     if (!empty($question->options->shownumcorrect)) {
         $expout .= "    <shownumcorrect/>\n";
     }
     $expout .= "    <answernumbering>{$question->options->answernumbering}</answernumbering>\n";
     $expout .= $format->write_answers($question->options->answers);
     return $expout;
 }