]> git.mjollnir.org Git - moodle.git/commitdiff
Category can now be specified in Moodle XML format.
authorthepurpleblob <thepurpleblob>
Wed, 29 Nov 2006 14:27:48 +0000 (14:27 +0000)
committerthepurpleblob <thepurpleblob>
Wed, 29 Nov 2006 14:27:48 +0000 (14:27 +0000)
question/format/xml/format.php

index 5094305333b0954acc7e574a9d3ea98333730747..f7c6425f0e3389926dcffb44fca157d2bb13fb0d 100755 (executable)
@@ -398,6 +398,20 @@ class qformat_xml extends qformat_default {
         return $qo;
     }
 
+    /**
+     * this is not a real question type. It's a dummy type used
+     * to specify the import category
+     * format is:
+     * <question type="category">
+     *     <category>tom/dick/harry</category>
+     * </question>
+     */
+    function import_category( $question ) {
+        $qo->qtype = 'category';
+        $qo->category = $question['#']['category'][0]['#'];
+        return $qo;
+    }
+
     /**
      * parse the array of lines into an array of questions
      * this *could* burn memory - but it won't happen that much
@@ -450,6 +464,9 @@ class qformat_xml extends qformat_default {
             elseif ($question_type=='essay') {
                 $qo = $this->import_essay( $question );
             }
+            elseif ($question_type=='category') {
+                $qo = $this->import_category( $question );
+            }
             else {
                 $notsupported = get_string( 'xmltypeunsupported','quiz',$question_type );
                 echo "<p>$notsupported</p>";
@@ -461,7 +478,6 @@ class qformat_xml extends qformat_default {
                 $questions[] = $qo;
             }
         }
-
         return $questions;
     }