/**
  * export_to_xml
  *
  * @param stdClass    $question
  * @param qformat_xml $format
  * @param string      $extra (optional, default=null)
  * @todo Finish documenting this function
  */
 function export_to_xml($question, qformat_xml $format, $extra = null)
 {
     list($count, $type) = $this->extract_count_and_type($question);
     $output = '';
     $output .= "    <selecttype>{$type}</selecttype>\n";
     $output .= "    <selectcount>{$count}</selectcount>\n";
     foreach ($question->options->answers as $answer) {
         $output .= '    <answer fraction="' . $answer->fraction . '" ' . $format->format($answer->answerformat) . ">\n";
         $output .= $format->writetext($answer->answer, 3);
         if ($feedback = trim($answer->feedback)) {
             // usually there is no feedback
             $output .= '      <feedback ' . $format->format($answer->feedbackformat) . ">\n";
             $output .= $format->writetext($answer->feedback, 4);
             $output .= "      </feedback>\n";
         }
         $output .= "    </answer>\n";
     }
     return $output;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
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;
 }