diff --git a/question/format.php b/question/format.php
index dc3db4aadce..081b68b36a3 100644
--- a/question/format.php
+++ b/question/format.php
@@ -876,26 +876,4 @@ class qformat_default {
return html_to_text(format_text($question->questiontext,
$question->questiontextformat, $formatoptions), 0, false);
}
-
- /**
- * convert files into text output in the given format.
- * @param array
- * @param string encoding method
- * @return string $string
- */
- protected function writefiles($files, $encoding='base64') {
- if (empty($files)) {
- return '';
- }
- $string = '';
- foreach ($files as $file) {
- if ($file->is_directory()) {
- continue;
- }
- $string .= '';
- $string .= base64_encode($file->get_content());
- $string .= '';
- }
- return $string;
- }
}
diff --git a/question/format/xml/format.php b/question/format/xml/format.php
index d83aa55ae5f..5498217588a 100644
--- a/question/format/xml/format.php
+++ b/question/format/xml/format.php
@@ -1051,6 +1051,27 @@ class qformat_xml extends qformat_default {
return $xml;
}
+ /**
+ * Generte the XML to represent some files.
+ * @param array of store array of stored_file objects.
+ * @return string $string the XML.
+ */
+ public function write_files($files) {
+ if (empty($files)) {
+ return '';
+ }
+ $string = '';
+ foreach ($files as $file) {
+ if ($file->is_directory()) {
+ continue;
+ }
+ $string .= '';
+ $string .= base64_encode($file->get_content());
+ $string .= '';
+ }
+ return $string;
+ }
+
protected function presave_process($content) {
// Override to allow us to add xml headers and footers
return '
@@ -1110,11 +1131,11 @@ class qformat_xml extends qformat_default {
$expout .= " \n";
$expout .= " format($question->questiontextformat)}>\n";
$expout .= $this->writetext($question->questiontext, 3);
- $expout .= $this->writefiles($question->questiontextfiles);
+ $expout .= $this->write_files($question->questiontextfiles);
$expout .= " \n";
$expout .= " format($question->generalfeedbackformat)}>\n";
$expout .= $this->writetext($question->generalfeedback, 3);
- $expout .= $this->writefiles($question->generalfeedbackfiles);
+ $expout .= $this->write_files($question->generalfeedbackfiles);
$expout .= " \n";
if ($question->qtype != 'multianswer') {
$expout .= " {$question->defaultmark}\n";
@@ -1191,7 +1212,7 @@ class qformat_xml extends qformat_default {
$expout .= " format($question->options->instructionsformat) . ">\n";
$expout .= $this->writetext($question->options->instructions, 3);
- $expout .= $this->writefiles($files);
+ $expout .= $this->write_files($files);
$expout .= " \n";
}
break;
@@ -1207,7 +1228,7 @@ class qformat_xml extends qformat_default {
$expout .= " format($subquestion->questiontextformat) . ">\n";
$expout .= $this->writetext($subquestion->questiontext, 3);
- $expout .= $this->writefiles($files);
+ $expout .= $this->write_files($files);
$expout .= " \n";
$expout .= $this->writetext($subquestion->answertext, 4);
$expout .= " \n";
@@ -1235,7 +1256,7 @@ class qformat_xml extends qformat_default {
$expout .= " format($question->options->graderinfoformat) . ">\n";
$expout .= $this->writetext($question->options->graderinfo, 3);
- $expout .= $this->writefiles($fs->get_area_files($contextid, 'qtype_essay',
+ $expout .= $this->write_files($fs->get_area_files($contextid, 'qtype_essay',
'graderinfo', $question->id));
$expout .= " \n";
break;
@@ -1255,21 +1276,21 @@ class qformat_xml extends qformat_default {
'correctfeedback', $question->id);
$expout .= " \n";
$expout .= $this->writetext($question->options->correctfeedback, 3);
- $expout .= $this->writefiles($files);
+ $expout .= $this->write_files($files);
$expout .= " \n";
$files = $fs->get_area_files($contextid, $component,
'partiallycorrectfeedback', $question->id);
$expout .= " \n";
$expout .= $this->writetext($question->options->partiallycorrectfeedback, 3);
- $expout .= $this->writefiles($files);
+ $expout .= $this->write_files($files);
$expout .= " \n";
$files = $fs->get_area_files($contextid, $component,
'incorrectfeedback', $question->id);
$expout .= " \n";
$expout .= $this->writetext($question->options->incorrectfeedback, 3);
- $expout .= $this->writefiles($files);
+ $expout .= $this->write_files($files);
$expout .= " \n";
foreach ($question->options->answers as $answer) {
@@ -1287,7 +1308,7 @@ class qformat_xml extends qformat_default {
$files = $fs->get_area_files($contextid, $component,
'instruction', $question->id);
$expout .= $this->writetext($answer->feedback);
- $expout .= $this->writefiles($answer->feedbackfiles);
+ $expout .= $this->write_files($answer->feedbackfiles);
$expout .= " \n";
$expout .= "\n";
}
@@ -1312,7 +1333,7 @@ class qformat_xml extends qformat_default {
$expout .= " format($question->options->instructionsformat) . ">\n";
$expout .= $this->writetext($question->options->instructions, 3);
- $expout .= $this->writefiles($files);
+ $expout .= $this->write_files($files);
$expout .= " \n";
}
@@ -1418,10 +1439,10 @@ class qformat_xml extends qformat_default {
$output = '';
$output .= " format($answer->answerformat)}>\n";
$output .= $this->writetext($answer->answer, 3);
- $output .= $this->writefiles($answer->answerfiles);
+ $output .= $this->write_files($answer->answerfiles);
$output .= " format($answer->feedbackformat)}>\n";
$output .= $this->writetext($answer->feedback, 4);
- $output .= $this->writefiles($answer->feedbackfiles);
+ $output .= $this->write_files($answer->feedbackfiles);
$output .= " \n";
$output .= $extra;
$output .= " \n";