Merge branch 'w04_MDL-26008_20_creator' of git://github.com/skodak/moodle
authorSam Hemelryk <sam@moodle.com>
Mon, 24 Jan 2011 03:10:40 +0000 (11:10 +0800)
committerSam Hemelryk <sam@moodle.com>
Mon, 24 Jan 2011 03:10:40 +0000 (11:10 +0800)
blocks/online_users/block_online_users.php
course/resources.php
mod/label/lib.php
mod/quiz/index.php
mod/scorm/report.php
question/format/gift/format.php
question/format/gift/simpletest/testgiftformat.php
question/type/multianswer/questiontype.php

index 70ddd2b..4fb8972 100644 (file)
@@ -43,8 +43,6 @@ class block_online_users extends block_base {
 
         $groupmembers = "";
         $groupselect  = "";
-        $rafrom       = "";
-        $rawhere      = "";
         $params = array();
 
         //Add this to the SQL to show only group users
@@ -78,22 +76,22 @@ class block_online_users extends block_base {
             $params = array_merge($params, $eparams);
 
             $sql = "SELECT $userfields, MAX(ul.timeaccess) AS lastaccess
-                      FROM {user_lastaccess} ul, {user} u $groupmembers $rafrom
+                      FROM {user_lastaccess} ul $groupmembers, {user} u
                       JOIN ($esqljoin) euj ON euj.id = u.id
                      WHERE ul.timeaccess > $timefrom
                            AND u.id = ul.userid
                            AND ul.courseid = :courseid
-                           $groupselect $rawhere
+                           $groupselect
                   GROUP BY $userfields
                   ORDER BY lastaccess DESC";
 
            $csql = "SELECT u.id
-                      FROM {user_lastaccess} ul, {user} u $groupmembers $rafrom
+                      FROM {user_lastaccess} ul $groupmembers, {user} u
                       JOIN ($esqljoin) euj ON euj.id = u.id
                      WHERE ul.timeaccess > $timefrom
                            AND u.id = ul.userid
                            AND ul.courseid = :courseid
-                           $groupselect $rawhere
+                           $groupselect
                   GROUP BY u.id";
 
             $params['courseid'] = $this->page->course->id;
index 57abd08..b98ced9 100644 (file)
@@ -37,6 +37,9 @@ $allmodules = $DB->get_records('modules', array('visible'=>1));
 $modules = array();
 foreach ($allmodules as $key=>$module) {
     $modname = $module->name;
+    if ($modname === 'label') {
+        continue;
+    }
     $libfile = "$CFG->dirroot/mod/$modname/lib.php";
     if (!file_exists($libfile)) {
         continue;
index a80a08d..1f77822 100644 (file)
@@ -181,7 +181,7 @@ function label_reset_userdata($data) {
  *
  * @return array
  */
-function lable_get_extra_capabilities() {
+function label_get_extra_capabilities() {
     return array('moodle/site:accessallgroups');
 }
 
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 7d30bba..9648e60 100755 (executable)
                     }
                 } else {
                     // all users who can attempt scoes and who are in the currently selected group
-                    if (!$groupstudents = get_users_by_capability($context, 'mod/scorm:savetrack','','','','',$currentgroup,'',false)){
+                    if (!$groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack','','','','',$currentgroup,'',false)){
                         echo $OUTPUT->notification(get_string('nostudentsingroup'));
                         $nostudents = true;
                         $groupstudents = array();
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;