]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from STABLE.
authorthepurpleblob <thepurpleblob>
Sat, 13 May 2006 08:49:46 +0000 (08:49 +0000)
committerthepurpleblob <thepurpleblob>
Sat, 13 May 2006 08:49:46 +0000 (08:49 +0000)
question/editlib.php
question/format.php
question/format/gift/format.php
question/format/webct/format.php
question/format/xhtml/format.php
question/format/xml/format.php

index 50e3e1d945c1cddb44c78b812742cc123fd9b99d..714985e6000357a1fe3ccf5df6eb895c9c5e10d2 100644 (file)
@@ -19,10 +19,11 @@ require_once($CFG->libdir.'/questionlib.php');
 * Function to read all questions for category into big array
 *
 * @param int $category category number
-* @param bool @noparent if true only questions with NO parent will be selected
+* @param bool $noparent if true only questions with NO parent will be selected
+* @param bool $recurse include subdirectories
 * @author added by Howard Miller June 2004
 */
-function get_questions_category( $category, $noparent=false ) {
+function get_questions_category( $category, $noparent=false, $recurse=true ) {
 
     global $QTYPES;
 
@@ -35,8 +36,16 @@ function get_questions_category( $category, $noparent=false ) {
       $npsql = " and parent='0' ";
     }
 
+    // get (list) of categories
+    if ($recurse) {
+        $categorylist = question_categorylist( $category->id );
+    }
+    else {
+        $categorylist = $category->id;
+    }
+
     // get the list of questions for the category
-    if ($questions = get_records_select("question","category={$category->id} $npsql", "qtype, name ASC")) {
+    if ($questions = get_records_select("question","category IN ($categorylist) $npsql", "qtype, name ASC")) {
 
         // iterate through questions, getting stuff we need
         foreach($questions as $question) {
index 90cf4c9b2041de23d1acd2ba0baa6868af89ffd9..7125adf160e7dffd0b0459574da5840f4855de67 100644 (file)
@@ -238,8 +238,9 @@ class qformat_default {
         return $newfile;
     }
 
+//=================
 // Export functions
-
+//=================
 
     function export_file_extension() {
     /// return the files extension appropriate for this type
index 83cdc7af9d04560c18d7c04f55bdb482a5d4ab96..0eb0b17a42f2f7e1c146c60b3e1d9c109703ed43 100755 (executable)
@@ -507,16 +507,31 @@ function writequestion( $question ) {
     switch($question->qtype) {
     case TRUEFALSE:
         $answers = $question->options->answers;
-        if ($answers['true']->fraction==1) {
-            $answertext = 'TRUE';
-            $wrong_feedback = $this->repchar( $answers['false']->feedback );
-            $right_feedback = $this->repchar( $answers['true']->feedback );
-        }
-        else {
-            $answertext = 'FALSE';
-            $wrong_feedback = $this->repchar( $answers['true']->feedback );
-            $right_feedback = $this->repchar( $answers['false']->feedback );
+        foreach ($answers as $answer) {
+            if (trim($answer->answer)=='True') {
+                if ($answer->fraction==1) {
+                    $answertext = 'TRUE';
+                    $right_feedback = $answer->feedback;
+                }
+                else {
+                    $answertext = 'FALSE';
+                    $wrong_feedback = $answer->feedback;
+                }
+            }
+            else {
+                if ($answer->fraction==1) {
+                    $answertext = 'FALSE';
+                    $right_feedback = $answer->feedback;
+                }
+                else {
+                    $answertext = 'TRUE';
+                    $wrong_feedback = $answer->feedback;
+                }
+            }
         }
+
+        $wrong_feedback = $this->repchar( $wrong_feedback );
+        $right_feedback = $this->repchar( $right_feedback );
         $expout .= "::".$question->name."::".$tfname.$this->repchar( $question->questiontext,$textformat )."{".$this->repchar( $answertext );
         if ($wrong_feedback!="") {
             $expout .= "#".$wrong_feedback;
index a0e846c376a8e22aa41072278480bd8e3b764f62..0be61746f798bb19fe1fcf6109379153fbed5440 100644 (file)
@@ -660,7 +660,6 @@ class qformat_webct extends qformat_default {
             }
             echo "</ul>";
         }
-        echo "<pre>"; print_r( $questions ); die;
         return $questions;
     }
 }
index b69501237b398658ad31a95f04b66b8174b565c9..9ce7b4b0759b384e2e6fb2259e1c4d00c73b02bd 100755 (executable)
@@ -114,7 +114,7 @@ function presave_process( $content ) {
   global $CFG;
 
   // get css bit
-  $css_lines = file( "$CFG->dirroot/mod/quiz/format/xhtml/xhtml.css" );
+  $css_lines = file( "$CFG->dirroot/question/format/xhtml/xhtml.css" );
   $css = implode( ' ',$css_lines ); 
 
   $xp =  "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
index 67cfdcd111dd4a194423e2dd6cf49bc051dd57e9..70843ccf7e6badcd434fbab9c5f3f88939864c21 100755 (executable)
@@ -553,24 +553,15 @@ class qformat_xml extends qformat_default {
         // output depends on question type
         switch($question->qtype) {
         case TRUEFALSE:
-            $answer = $question->options->answers;
-            $true_percent = round( $answer['true']->fraction * 100 );
-            $false_percent = round( $answer['false']->fraction * 100 );
-            // true answer
-            $expout .= "    <answer fraction=\"$true_percent\">\n";
-            $expout .= $this->writetext("true",3)."\n";
-            $expout .= "      <feedback>\n";
-            $expout .= $this->writetext( $answer['true']->feedback,4,false );
-            $expout .= "      </feedback>\n";
-            $expout .= "    </answer>\n";
-
-            // false answer
-            $expout .= "    <answer fraction=\"$false_percent\">\n";
-            $expout .= $this->writetext("false")."\n";
-            $expout .= "      <feedback>\n";
-            $expout .= $this->writetext( $answer['false']->feedback,4,false );
-            $expout .= "      </feedback>\n";
-            $expout .= "    </answer>\n";
+            foreach ($question->options->answers as $answer) {
+                $fraction_pc = round( $answer->fraction * 100 );
+                $expout .= "    <answer fraction=\"$fraction_pc\">\n";
+                $expout .= $this->writetext(strtolower($answer->answer),3)."\n";
+                $expout .= "      <feedback>\n";
+                $expout .= $this->writetext( $answer->feedback,4,false );
+                $expout .= "      </feedback>\n";
+                $expout .= "    </answer>\n";
+            }
             break;
         case MULTICHOICE:
             $expout .= "    <single>".$this->get_single($question->options->single)."</single>\n";