]> git.mjollnir.org Git - moodle.git/commitdiff
merged from STABLE18
authorthepurpleblob <thepurpleblob>
Mon, 21 May 2007 13:11:06 +0000 (13:11 +0000)
committerthepurpleblob <thepurpleblob>
Mon, 21 May 2007 13:11:06 +0000 (13:11 +0000)
question/format/xml/format.php

index f7b337d891f8baf8f6830542af2ea989e79305e7..fe92c256a3a73e05f7003df523cce65b43d5aa4a 100755 (executable)
@@ -142,7 +142,7 @@ class qformat_xml extends qformat_default {
 
         // question name
         $qo->name = $this->getpath( $question, array('#','name',0,'#','text',0,'#'), '', true, $error_noname );
-        $qo->questiontext = $this->getpath( $question, array('#','questiontext',0,'#','text',0,'#'), '', true, $error_noquestion );
+        $qo->questiontext = $this->getpath( $question, array('#','questiontext',0,'#','text',0,'#'), '', true );
         $qo->questiontextformat = $this->getpath( $question, array('#','questiontext',0,'@','format'), '' );
         $image = $this->getpath( $question, array('#','image',0,'#'), $qo->image );
         $image_base64 = $this->getpath( $question, array('#','image_base64','0','#'),'' );
@@ -162,8 +162,8 @@ class qformat_xml extends qformat_default {
      * @return object answer object
      */   
     function import_answer( $answer ) {
-        $fraction = $answer['@']['fraction'];
-        $text = $this->import_text( $answer['#']['text']);
+        $fraction = $this->getpath($answer, array('@','fraction'), 0);
+        $text = $this->getpath( $answer, array('#','text',0,'#'),'',true);
         $feedback = $this->import_text( $answer['#']['feedback'][0]['#']['text'] );
 
         $ans = null;
@@ -458,12 +458,8 @@ class qformat_xml extends qformat_default {
         $answer = $question['#']['answer'][0];
 
         // get fraction - <fraction> tag is deprecated
-        if (!empty($answer['#']['fraction'][0]['#'])) {
-            $qo->fraction = $answer['#']['fraction'][0]['#'];
-        }
-        else {
-            $qo->fraction = $answer['@']['fraction'] / 100;
-        }
+        $qo->fraction = $this->getpath( $question, array('@','fraction'), 0 ) / 100;
+        $q0->fraction = $this->getpath( $question, array('#','fraction',0,'#'), $qo->fraction );
 
         return $qo;
     }