Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-13048 fix undefined course id when importing a Hot Potatoes quiz …

…into the Lesson module
  • Loading branch information...
commit 5d5f22570f573795a91db6a801a8ee93c7954ae4 1 parent 88540a0
gbateson authored
Showing with 21 additions and 4 deletions.
  1. +21 −4 question/format/hotpot/format.php
View
25 question/format/hotpot/format.php
@@ -20,12 +20,29 @@ function readquestions ($lines) {
/// 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
Please sign in to comment.
Something went wrong with that request. Please try again.