mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-13048 fix undefined course id when importing a Hot Potatoes quiz into the Lesson module
This commit is contained in:
parent
88540a03e6
commit
5d5f22570f
1 changed files with 21 additions and 4 deletions
|
@ -20,12 +20,29 @@ class qformat_hotpot extends qformat_default {
|
||||||
/// where each item is a question object as defined by
|
/// where each item is a question object as defined by
|
||||||
/// readquestion().
|
/// readquestion().
|
||||||
|
|
||||||
// set baseurl
|
// set courseid and baseurl
|
||||||
global $CFG;
|
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) {
|
if ($CFG->slasharguments) {
|
||||||
$baseurl = "$CFG->wwwroot/file.php/{$this->course->id}/";
|
$baseurl = "$CFG->wwwroot/file.php/$courseid/";
|
||||||
} else {
|
} else {
|
||||||
$baseurl = "$CFG->wwwroot/file.php?file=/{$this->course->id}/";
|
$baseurl = "$CFG->wwwroot/file.php?file=/$courseid/";
|
||||||
}
|
}
|
||||||
|
|
||||||
// get import file name
|
// get import file name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue