]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from STABLE.
authorthepurpleblob <thepurpleblob>
Tue, 28 Nov 2006 11:51:50 +0000 (11:51 +0000)
committerthepurpleblob <thepurpleblob>
Tue, 28 Nov 2006 11:51:50 +0000 (11:51 +0000)
Examview 'SA' type questions now supported.

question/format/examview/format.php

index 7032911e96fd5de4994c7f9a7b518fee2936cce6..4d38b91a5dd6c96e6425bd944ae4d661d844463e 100755 (executable)
@@ -4,31 +4,22 @@
 
 require_once("$CFG->libdir/xmlize.php");
 
-/*
-define("SHORTANSWER",   "1");
-define("TRUEFALSE",     "2");
-define("MULTICHOICE",   "3");
-define("MATCH",         "5");
-define("DESCRIPTION",   "7");
-define("NUMERICAL",     "8");
-define("MULTIANSWER",   "9");
-define("CALCULATED",   "10");
-*/
-
 class qformat_examview extends qformat_default {
     
-    var $qtypes = array('tf' => TRUEFALSE,
-    'mc' => MULTICHOICE,
-    'yn' => TRUEFALSE,
-    'co' => SHORTANSWER,
-    'ma' => MATCH,
-    'mtf' => 99,
-    'nr' => NUMERICAL,
-    'pr' => 99,
-    'es' => 99,
-    'ca' => 99,
-    'ot' => 99
-    );
+    var $qtypes = array(
+        'tf' => TRUEFALSE,
+        'mc' => MULTICHOICE,
+        'yn' => TRUEFALSE,
+        'co' => SHORTANSWER,
+        'ma' => MATCH,
+        'mtf' => 99,
+        'nr' => NUMERICAL,
+        'pr' => 99,
+        'es' => 99,
+        'ca' => 99,
+        'ot' => 99,
+        'sa' => ESSAY
+        );
     
     var $matching_questions = array();
 
@@ -170,7 +161,7 @@ class qformat_examview extends qformat_default {
         // Only one answer is allowed
         $htmltext = $this->unxmlise($qrec['#']['text'][0]['#']);
         $question->questiontext = $htmltext;
-        $question->name = $question->questiontext;
+        $question->name = shorten_text( $question->questiontext, 250 );
         
         switch ($question->qtype) {
         case MULTICHOICE:
@@ -186,6 +177,9 @@ class qformat_examview extends qformat_default {
         case SHORTANSWER:
             $question = $this->parse_co($qrec['#'], $question);
             break;
+        case ESSAY:
+            $question = $this->parse_sa($qrec['#'], $question);
+            break;
         case NUMERICAL:
             $question = $this->parse_nr($qrec['#'], $question);
             break;
@@ -253,6 +247,13 @@ class qformat_examview extends qformat_default {
         }
         return $question;
     }
+
+    function parse_sa($qrec, $question) {
+        $feedback = trim($this->unxmlise($qrec['answer'][0]['#']));
+        $question->feedback = $feedback;
+        $question->fraction = 0;
+        return $question;
+    }
     
     function parse_nr($qrec, $question)
     {