From 36e2232e27140e343496d5df85e8e7fe8794c838 Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Sat, 13 May 2006 08:49:46 +0000 Subject: [PATCH] Merged from STABLE. --- question/editlib.php | 15 ++++++++++++--- question/format.php | 3 ++- question/format/gift/format.php | 33 +++++++++++++++++++++++--------- question/format/webct/format.php | 1 - question/format/xhtml/format.php | 2 +- question/format/xml/format.php | 27 +++++++++----------------- 6 files changed, 48 insertions(+), 33 deletions(-) diff --git a/question/editlib.php b/question/editlib.php index 50e3e1d945..714985e600 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -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) { diff --git a/question/format.php b/question/format.php index 90cf4c9b20..7125adf160 100644 --- a/question/format.php +++ b/question/format.php @@ -238,8 +238,9 @@ class qformat_default { return $newfile; } +//================= // Export functions - +//================= function export_file_extension() { /// return the files extension appropriate for this type diff --git a/question/format/gift/format.php b/question/format/gift/format.php index 83cdc7af9d..0eb0b17a42 100755 --- a/question/format/gift/format.php +++ b/question/format/gift/format.php @@ -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; diff --git a/question/format/webct/format.php b/question/format/webct/format.php index a0e846c376..0be61746f7 100644 --- a/question/format/webct/format.php +++ b/question/format/webct/format.php @@ -660,7 +660,6 @@ class qformat_webct extends qformat_default { } echo ""; } - echo "
"; print_r( $questions ); die;
         return $questions;
     }
 }
diff --git a/question/format/xhtml/format.php b/question/format/xhtml/format.php
index b69501237b..9ce7b4b075 100755
--- a/question/format/xhtml/format.php
+++ b/question/format/xhtml/format.php
@@ -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 =  "qtype) {
         case TRUEFALSE:
-            $answer = $question->options->answers;
-            $true_percent = round( $answer['true']->fraction * 100 );
-            $false_percent = round( $answer['false']->fraction * 100 );
-            // true answer
-            $expout .= "    \n";
-            $expout .= $this->writetext("true",3)."\n";
-            $expout .= "      \n";
-            $expout .= $this->writetext( $answer['true']->feedback,4,false );
-            $expout .= "      \n";
-            $expout .= "    \n";
-
-            // false answer
-            $expout .= "    \n";
-            $expout .= $this->writetext("false")."\n";
-            $expout .= "      \n";
-            $expout .= $this->writetext( $answer['false']->feedback,4,false );
-            $expout .= "      \n";
-            $expout .= "    \n";
+            foreach ($question->options->answers as $answer) {
+                $fraction_pc = round( $answer->fraction * 100 );
+                $expout .= "    \n";
+                $expout .= $this->writetext(strtolower($answer->answer),3)."\n";
+                $expout .= "      \n";
+                $expout .= $this->writetext( $answer->feedback,4,false );
+                $expout .= "      \n";
+                $expout .= "    \n";
+            }
             break;
         case MULTICHOICE:
             $expout .= "    ".$this->get_single($question->options->single)."\n";
-- 
2.39.5