Permalink
Browse files

MDL-29117 use default course settings when template not set in db enrol

  • Loading branch information...
1 parent acb3bf8 commit c4437be63b64c49279af3c68cb12488417fcacb3 @skodak skodak committed Dec 11, 2011
Showing with 27 additions and 5 deletions.
  1. +27 −5 enrol/database/lib.php
@@ -639,22 +639,44 @@ public function sync_courses($verbose = false) {
if ($createcourses) {
require_once("$CFG->dirroot/course/lib.php");
- $template = $this->get_config('templatecourse');
+ $templatecourse = $this->get_config('templatecourse');
$defaultcategory = $this->get_config('defaultcategory');
- if ($template) {
- if ($template = $DB->get_record('course', array('shortname'=>$template))) {
+ $template = false;
+ if ($templatecourse) {
+ if ($template = $DB->get_record('course', array('shortname'=>$templatecourse))) {
unset($template->id);
unset($template->fullname);
unset($template->shortname);
unset($template->idnumber);
} else {
- $template = new stdClass();
+ if ($verbose) {
+ mtrace(" can not find template for new course!");
+ }
}
- } else {
+ }
+ if (!$template) {
+ $courseconfig = get_config('moodlecourse');
$template = new stdClass();
+ $template->summary = '';
+ $template->summaryformat = FORMAT_HTML;
+ $template->format = $courseconfig->format;
+ $template->numsections = $courseconfig->numsections;
+ $template->hiddensections = $courseconfig->hiddensections;
+ $template->newsitems = $courseconfig->newsitems;
+ $template->showgrades = $courseconfig->showgrades;
+ $template->showreports = $courseconfig->showreports;
+ $template->maxbytes = $courseconfig->maxbytes;
+ $template->groupmode = $courseconfig->groupmode;
+ $template->groupmodeforce = $courseconfig->groupmodeforce;
+ $template->visible = $courseconfig->visible;
+ $template->lang = $courseconfig->lang;
+ $template->groupmodeforce = $courseconfig->groupmodeforce;
}
if (!$DB->record_exists('course_categories', array('id'=>$defaultcategory))) {
+ if ($verbose) {
+ mtrace(" default course category does not exist!");
+ }
$categories = $DB->get_records('course_categories', array(), 'sortorder', 'id', 0, 1);
$first = reset($categories);
$defaultcategory = $first->id;

0 comments on commit c4437be

Please sign in to comment.