From 2c6041eb5af7c9b8670a8569172244bf1ca5c16c Mon Sep 17 00:00:00 2001 From: gbateson Date: Tue, 5 Feb 2008 04:08:54 +0000 Subject: [PATCH] MDL-13048 fix undefined course id when importing a Hot Potatoes quiz into the Lesson module --- question/format/hotpot/format.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/question/format/hotpot/format.php b/question/format/hotpot/format.php index 17238333309..e2b4c18b893 100644 --- a/question/format/hotpot/format.php +++ b/question/format/hotpot/format.php @@ -20,12 +20,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 -- 2.11.4.GIT