diff --git a/question/format/xml/format.php b/question/format/xml/format.php
index 4ddff96d502..8bcada5abd7 100644
--- a/question/format/xml/format.php
+++ b/question/format/xml/format.php
@@ -198,7 +198,7 @@ class qformat_xml extends qformat_default {
* @return object question object
*/
public function import_headers($question) {
- global $CFG, $USER;
+ global $USER;
// This routine initialises the question object.
$qo = $this->defaultquestion();
@@ -255,14 +255,7 @@ class qformat_xml extends qformat_default {
}
// Read the question tags.
- if (!empty($CFG->usetags) && array_key_exists('tags', $question['#'])
- && !empty($question['#']['tags'][0]['#']['tag'])) {
- require_once($CFG->dirroot.'/tag/lib.php');
- $qo->tags = array();
- foreach ($question['#']['tags'][0]['#']['tag'] as $tagdata) {
- $qo->tags[] = $this->getpath($tagdata, array('#', 'text', 0, '#'), '', true);
- }
- }
+ $this->import_question_tags($qo, $question);
return $qo;
}
@@ -380,6 +373,26 @@ class qformat_xml extends qformat_default {
}
}
+ /**
+ * Import all the question tags
+ *
+ * @param object $qo the question data that is being constructed.
+ * @param array $questionxml The xml representing the question.
+ * @return array of objects representing the tags in the file.
+ */
+ public function import_question_tags($qo, $questionxml) {
+ global $CFG;
+
+ if (!empty($CFG->usetags) && array_key_exists('tags', $questionxml['#'])
+ && !empty($questionxml['#']['tags'][0]['#']['tag'])) {
+ require_once($CFG->dirroot.'/tag/lib.php');
+ $qo->tags = array();
+ foreach ($questionxml['#']['tags'][0]['#']['tag'] as $tagdata) {
+ $qo->tags[] = $this->getpath($tagdata, array('#', 'text', 0, '#'), '', true);
+ }
+ }
+ }
+
/**
* Import files from a node in the XML.
* @param array $xml an array of
Here is something really interesting.
'; $expectedq->responsetemplate['format'] = FORMAT_HTML; + $expectedq->tags = array('tagEssay', 'tagEssay21', 'tagTest'); $this->assert(new question_check_specified_fields_expectation($expectedq), $q); } @@ -571,6 +589,10 @@ END;