]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16250
authorthepurpleblob <thepurpleblob>
Thu, 28 Aug 2008 10:07:51 +0000 (10:07 +0000)
committerthepurpleblob <thepurpleblob>
Thu, 28 Aug 2008 10:07:51 +0000 (10:07 +0000)
Added support for Essay type questions

Merged from STABLE_19

question/format/blackboard/format.php

index 95ee5b6f47001ab49257d2b311bcf2e3fca9e201..460d430ee42d941a3d5d1fecbe76e7fc673b8328 100644 (file)
@@ -1,5 +1,6 @@
 <?php // $Id$
 
+
 ////////////////////////////////////////////////////////////////////////////
 /// Blackboard 6.0 Format
 ///
@@ -37,10 +38,48 @@ class qformat_blackboard extends qformat_default {
     $this->process_ma($xml, $questions);
     $this->process_fib($xml, $questions);
     $this->process_matching($xml, $questions);
+    $this->process_essay($xml, $questions);
 
     return $questions;
 }
 
+//----------------------------------------
+// Process Essay Questions
+//----------------------------------------
+function process_essay($xml, &$questions ) {
+  
+    if (isset($xml["POOL"]["#"]["QUESTION_ESSAY"])) {
+       $essayquestions = $xml["POOL"]["#"]["QUESTION_ESSAY"];
+    }
+    else {
+       return;
+    }  
+    
+    foreach ($essayquestions as $essayquestion) {
+        
+        $question = $this->defaultquestion();
+        
+        $question->qtype = ESSAY;      
+        
+        // determine if the question is already escaped html
+        $ishtml = $essayquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"];
+
+        // put questiontext in question object
+        if ($ishtml) {
+            $question->questiontext = html_entity_decode_php4(trim($essayquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
+        }
+        $question->questiontext = addslashes($question->questiontext);
+        
+        // put name in question object
+        $question->name = substr($question->questiontext, 0, 254);
+        $question->answer = '';
+        $question->feedback = '';
+        $question->fraction = 0;
+        
+        $questions[] = $question;
+    }  
+}
+
 //----------------------------------------
 // Process True / False Questions
 //----------------------------------------