]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13048 fix indefined course id when importing a Hot Potatoes quiz into the Lesson...
authorgbateson <gbateson>
Tue, 5 Feb 2008 04:13:51 +0000 (04:13 +0000)
committergbateson <gbateson>
Tue, 5 Feb 2008 04:13:51 +0000 (04:13 +0000)
question/format/hotpot/format.php

index f05fb7c9c79e077801bdeb452a6e152adf61c858..de91d43fa635b25897380bef97670f47687b5b2f 100644 (file)
@@ -24,12 +24,29 @@ class qformat_hotpot extends qformat_default {
         /// where each item is a question object as defined by
         /// readquestion().
 
-        // set baseurl
-        global $CFG;
+        // set courseid and baseurl
+        global $CFG, $COURSE, $course;
+        switch (true) {
+            case isset($this->course->id):
+                // import to quiz module
+                $courseid = $this->course->id;
+                break;
+            case isset($course->id):
+                // import to lesson module
+                $courseid = $course->id;
+                break;
+            case isset($COURSE->id):
+                // last resort
+                $courseid = $COURSE->id;
+                break;
+            default:
+                // shouldn't happen !!
+                $courseid = 0; 
+        }
         if ($CFG->slasharguments) {
-            $baseurl = "$CFG->wwwroot/file.php/{$this->course->id}/";
+            $baseurl = "$CFG->wwwroot/file.php/$courseid/";
         } else {
-            $baseurl = "$CFG->wwwroot/file.php?file=/{$this->course->id}/";
+            $baseurl = "$CFG->wwwroot/file.php?file=/$courseid/";
         }
 
         // get import file name