Merge branch 'w04_MDL-26045_20_onlineblock' of git://github.com/skodak/moodle
authorSam Hemelryk <sam@moodle.com>
Mon, 24 Jan 2011 02:45:46 +0000 (10:45 +0800)
committerSam Hemelryk <sam@moodle.com>
Mon, 24 Jan 2011 02:45:46 +0000 (10:45 +0800)
mod/quiz/index.php
question/format/gift/format.php
question/format/gift/simpletest/testgiftformat.php
question/type/multianswer/questiontype.php

index 631f95b..22e1229 100644 (file)
@@ -92,8 +92,8 @@
                 SELECT qg.quiz, qg.grade
                 FROM {quiz_grades} qg
                 JOIN {quiz} q ON q.id = qg.quiz
-                WHERE q.course = ?',
-                $course->id);
+                WHERE q.course = ? AND qg.userid = ?',
+                array($course->id, $USER->id));
     }
 
     $table = new html_table();
index 29780e8..e086691 100755 (executable)
@@ -392,7 +392,7 @@ class qformat_gift extends qformat_default {
                 list($answer, $wrongfeedback, $rightfeedback) =
                         $this->split_truefalse_comment($answertext, $question->questiontextformat);
 
-                if ($answer == "T" OR $answer == "TRUE") {
+                if ($answer['text'] == "T" OR $answer['text'] == "TRUE") {
                     $question->correctanswer = 1;
                     $question->feedbacktrue = $rightfeedback;
                     $question->feedbackfalse = $wrongfeedback;
index da66ac7..113329a 100644 (file)
@@ -659,6 +659,74 @@ FALSE#42 is the Ultimate Answer.#You gave the right answer.}";
         $this->assert(new CheckSpecifiedFieldsExpectation($expectedq), $q);
     }
 
+    public function test_import_truefalse_true_answer1() {
+        $gift = "// name 0-11
+::2-08 TSL::TSL is blablabla.{T}";
+        $lines = preg_split('/[\\n\\r]/', str_replace("\r\n", "\n", $gift));
+
+        $importer = new qformat_gift();
+        $q = $importer->readquestion($lines);
+
+        $expectedq = (object) array(
+            'name' => '2-08 TSL',
+            'questiontext' => "TSL is blablabla.",
+            'questiontextformat' => FORMAT_MOODLE,
+            'generalfeedback' => '',
+            'generalfeedbackformat' => FORMAT_MOODLE,
+            'qtype' => 'truefalse',
+            'defaultgrade' => 1,
+            'penalty' => 1,
+            'length' => 1,
+            'correctanswer' => 1,
+            'feedbacktrue' => array(
+                'text' => '',
+                'format' => FORMAT_MOODLE,
+                'files' => array(),
+            ),
+            'feedbackfalse' => array(
+                'text' => '',
+                'format' => FORMAT_MOODLE,
+                'files' => array(),
+            ),
+        );
+
+        $this->assert(new CheckSpecifiedFieldsExpectation($expectedq), $q);
+    }
+
+    public function test_import_truefalse_true_answer2() {
+        $gift = "// name 0-11
+::2-08 TSL::TSL is blablabla.{TRUE}";
+        $lines = preg_split('/[\\n\\r]/', str_replace("\r\n", "\n", $gift));
+
+        $importer = new qformat_gift();
+        $q = $importer->readquestion($lines);
+
+        $expectedq = (object) array(
+            'name' => '2-08 TSL',
+            'questiontext' => "TSL is blablabla.",
+            'questiontextformat' => FORMAT_MOODLE,
+            'generalfeedback' => '',
+            'generalfeedbackformat' => FORMAT_MOODLE,
+            'qtype' => 'truefalse',
+            'defaultgrade' => 1,
+            'penalty' => 1,
+            'length' => 1,
+            'correctanswer' => 1,
+            'feedbacktrue' => array(
+                'text' => '',
+                'format' => FORMAT_MOODLE,
+                'files' => array(),
+            ),
+            'feedbackfalse' => array(
+                'text' => '',
+                'format' => FORMAT_MOODLE,
+                'files' => array(),
+            ),
+        );
+
+        $this->assert(new CheckSpecifiedFieldsExpectation($expectedq), $q);
+    }
+
     public function test_export_truefalse() {
         $qdata = (object) array(
             'id' => 666 ,
index 1c713f2..012cc43 100644 (file)
@@ -278,12 +278,6 @@ class embedded_cloze_qtype extends default_questiontype {
     function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
         global $QTYPES, $CFG, $USER, $OUTPUT, $PAGE;
 
-        static $overlibdivoutput = false;
-        if (!$overlibdivoutput) {
-            echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib
-            $overlibdivoutput = true;
-        }
-
         $readonly = empty($options->readonly) ? '' : 'readonly="readonly"';
         $disabled = empty($options->readonly) ? '' : 'disabled="disabled"';
         $formatoptions = new stdClass;