/**
  * 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;
 }
 /**
  * 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 .= $format->write_combined_feedback($question->options, $question->id, $question->contextid);
     foreach ($question->options->subquestions as $subquestion) {
         $files = $fs->get_area_files($contextid, 'qtype_ddmatch', 'subquestion', $subquestion->id);
         $textformat = $format->get_format($subquestion->questiontextformat);
         $expout .= "    <subquestion format=\"{$textformat}\">\n";
         $expout .= '      ' . $format->writetext($subquestion->questiontext);
         $expout .= '      ' . $format->write_files($files, 2);
         $expout .= "       <answer format=\"{$textformat}\">\n";
         $expout .= '      ' . $format->writetext($subquestion->answertext);
         $files = $fs->get_area_files($contextid, 'qtype_ddmatch', 'subanswer', $subquestion->id);
         $expout .= '      ' . $format->write_files($files, 2);
         $expout .= "       </answer>\n";
         $expout .= "    </subquestion>\n";
     }
     return $expout;
 }
 /**
  * Helper method used by {@link export_to_xml()}.
  * @param qformat_xml $format the importer/exporter object.
  * @param string $tag the XML tag to use.
  * @param string $text the text to output.
  * @param int $textformat the text's format.
  * @param int $itemid the itemid for any files.
  * @param int $contextid the context id that the text belongs to.
  * @param string $indent the amount of indent to add at the start of the line.
  * @return string XML fragment.
  */
 protected function export_xml_text(qformat_xml $format, $tag, $text, $textformat, $contextid, $filearea, $itemid, $indent = '    ')
 {
     $fs = get_file_storage();
     $files = $fs->get_area_files($contextid, 'qtype_stack', $filearea, $itemid);
     $output = '';
     $output .= $indent . "<{$tag} {$format->format($textformat)}>\n";
     $output .= $indent . '  ' . $format->writetext($text);
     $output .= $format->write_files($files);
     $output .= $indent . "</{$tag}>\n";
     return $output;
 }
示例#4
0
 public function export_to_xml($question, qformat_xml $format, $extra = null)
 {
     //get file storage
     $fs = get_file_storage();
     $expout = "";
     $expout .= "    <responseformat>" . $question->options->responseformat . "</responseformat>\n";
     $expout .= "    <responsefieldlines>" . $question->options->responsefieldlines . "</responsefieldlines>\n";
     $expout .= "    <attachments>" . $question->options->attachments . "</attachments>\n";
     $expout .= "    <graderinfo " . $format->format($question->options->graderinfoformat) . ">\n";
     $expout .= $format->writetext($question->options->graderinfo, 3);
     $expout .= $format->write_files($fs->get_area_files($question->contextid, 'qtype_poodllrecording', 'graderinfo', $question->id));
     $expout .= "    </graderinfo>\n";
     $expout .= "    <backimage>" . $format->write_files($fs->get_area_files($question->contextid, 'qtype_poodllrecording', 'backimage', $question->id)) . "</backimage>\n";
     $expout .= "    <boardsize>" . $question->options->boardsize . "</boardsize>\n";
     $expout .= "    <timelimit>" . $question->options->timelimit . "</timelimit>\n";
     return $expout;
 }