mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'MDL-32570-24' of git://github.com/danpoltawski/moodle into MOODLE_24_STABLE
This commit is contained in:
commit
786538f74f
1 changed files with 20 additions and 2 deletions
|
@ -411,10 +411,10 @@ function process_group_tag($tagcontents) {
|
||||||
} else {
|
} else {
|
||||||
// If not found and not allowed to create, stick with default
|
// If not found and not allowed to create, stick with default
|
||||||
$this->log_line('Category '.$group->category.' not found in Moodle database, so using default category instead.');
|
$this->log_line('Category '.$group->category.' not found in Moodle database, so using default category instead.');
|
||||||
$course->category = 1;
|
$course->category = $this->get_default_category_id();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$course->category = 1;
|
$course->category = $this->get_default_category_id();
|
||||||
}
|
}
|
||||||
$course->timecreated = time();
|
$course->timecreated = time();
|
||||||
$course->startdate = time();
|
$course->startdate = time();
|
||||||
|
@ -809,6 +809,24 @@ function load_role_mappings() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default category id (often known as 'Miscellaneous'),
|
||||||
|
* statically cached to avoid multiple DB lookups on big imports.
|
||||||
|
*
|
||||||
|
* @return int id of default category.
|
||||||
|
*/
|
||||||
|
private function get_default_category_id() {
|
||||||
|
static $defaultcategoryid = null;
|
||||||
|
|
||||||
|
if ($defaultcategoryid === null) {
|
||||||
|
$category = get_course_category();
|
||||||
|
$defaultcategoryid = $category->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $defaultcategoryid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // end of class
|
} // end of class
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue