public function export_to_xml($question, qformat_xml $format, $extra = null)
 {
     $output = '';
     $output .= '    <shuffleanswers>' . $question->options->shuffleanswers . "</shuffleanswers>\n";
     $output .= $format->write_combined_feedback($question->options, $question->id, $question->contextid);
     foreach ($question->options->answers as $answer) {
         $output .= "    <selectoption>\n";
         $output .= $format->writetext($answer->answer, 3);
         $output .= "      <group>{$answer->feedback}</group>\n";
         $output .= "    </selectoption>\n";
     }
     return $output;
 }
Пример #2
0
 /**
  * Exports the question to Moodle XML format.
  *
  * @param object $question question to be exported into XML format
  * @param qformat_xml $format format class exporting the question
  * @param object $extra extra information (not required for exporting this question in this format)
  * @return string containing the question data in XML format
  */
 public function export_to_xml($question, qformat_xml $format, $extra = null)
 {
     $expout = '';
     $expout .= $format->write_combined_feedback($question->options, $question->id, $question->contextid);
     $extraquestionfields = $this->extra_question_fields();
     array_shift($extraquestionfields);
     foreach ($extraquestionfields as $extra) {
         $expout .= "    <{$extra}>" . $question->options->{$extra} . "</{$extra}>\n";
     }
     return $expout;
 }
Пример #3
0
 public function export_to_xml($question, qformat_xml $format, $extra = null)
 {
     $output = '';
     $output .= '    <shuffleanswers>' . $question->options->shuffleanswers . "</shuffleanswers>\n";
     $output .= $format->write_combined_feedback($question->options, $question->id, $question->contextid);
     foreach ($question->options->answers as $answer) {
         $options = unserialize($answer->feedback);
         $output .= "    <dragbox>\n";
         $output .= $format->writetext($answer->answer, 3);
         $output .= "      <group>{$options->draggroup}</group>\n";
         if ($options->infinite) {
             $output .= "      <infinite/>\n";
         }
         $output .= "    </dragbox>\n";
     }
     return $output;
 }
Пример #4
0
 public function export_to_xml($question, qformat_xml $format, $extra = null)
 {
     $fs = get_file_storage();
     $contextid = $question->contextid;
     $output = '';
     if ($question->options->shuffleanswers) {
         $output .= "    <shuffleanswers/>\n";
     }
     $output .= $format->write_combined_feedback($question->options, $question->id, $question->contextid);
     $files = $fs->get_area_files($contextid, 'qtype_ddimageortext', 'bgimage', $question->id);
     $output .= "    " . $this->write_files($files, 2) . "\n";
     foreach ($question->options->drags as $drag) {
         $files = $fs->get_area_files($contextid, 'qtype_ddimageortext', 'dragimage', $drag->id);
         $output .= "    <drag>\n";
         $output .= "      <no>{$drag->no}</no>\n";
         $output .= $format->writetext($drag->label, 3) . "\n";
         $output .= "      <draggroup>{$drag->draggroup}</draggroup>\n";
         if ($drag->infinite) {
             $output .= "      <infinite/>\n";
         }
         $output .= $this->write_files($files, 3);
         $output .= "    </drag>\n";
     }
     foreach ($question->options->drops as $drop) {
         $output .= "    <drop>\n";
         $output .= $format->writetext($drop->label, 3);
         $output .= "      <no>{$drop->no}</no>\n";
         $output .= "      <choice>{$drop->choice}</choice>\n";
         $output .= "      <xleft>{$drop->xleft}</xleft>\n";
         $output .= "      <ytop>{$drop->ytop}</ytop>\n";
         $output .= "    </drop>\n";
     }
     return $output;
 }
 /**
  * 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;
 }
Пример #6
0
 public function export_to_xml($question, qformat_xml $format, $extra = null)
 {
     $fs = get_file_storage();
     $contextid = $question->contextid;
     $output = '';
     if ($question->options->shuffleanswers) {
         $output .= "    <shuffleanswers/>\n";
     }
     if ($question->options->showmisplaced) {
         $output .= "    <showmisplaced/>\n";
     }
     $output .= $format->write_combined_feedback($question->options, $question->id, $question->contextid);
     $files = $fs->get_area_files($contextid, 'qtype_ddmarker', 'bgimage', $question->id);
     $output .= "    " . $this->write_files($files, 2) . "\n";
     foreach ($question->options->drags as $drag) {
         $files = $fs->get_area_files($contextid, 'qtype_ddmarker', 'dragimage', $drag->id);
         $output .= "    <drag>\n";
         $output .= "      <no>{$drag->no}</no>\n";
         $output .= $format->writetext($drag->label, 3);
         if ($drag->infinite) {
             $output .= "      <infinite/>\n";
         }
         $output .= "      <noofdrags>{$drag->noofdrags}</noofdrags>\n";
         $output .= "    </drag>\n";
     }
     foreach ($question->options->drops as $drop) {
         $output .= "    <drop>\n";
         $output .= "      <no>{$drop->no}</no>\n";
         $output .= "      <shape>{$drop->shape}</shape>\n";
         $output .= "      <coords>{$drop->coords}</coords>\n";
         $output .= "      <choice>{$drop->choice}</choice>\n";
         $output .= "    </drop>\n";
     }
     return $output;
 }