Skip to content

Commit

Permalink
MDL-41259 when duplicate course shortname exists an exception is thro…
Browse files Browse the repository at this point in the history
…wn and sync is aborted
  • Loading branch information
Nitzan Bar authored and Damyon Wiese committed Sep 2, 2013
1 parent 18839cb commit 9dccff7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions enrol/ldap/lang/en/enrol_ldap.php
Expand Up @@ -53,6 +53,7 @@
$string['createcourseextid'] = 'CREATE User enrolled to a nonexistant course \'{$a->courseextid}\'';
$string['createnotcourseextid'] = 'User enrolled to a nonexistant course \'{$a->courseextid}\'';
$string['creatingcourse'] = 'Creating course \'{$a}\'...';
$string['duplicateshortname'] = "Course creation failed. Duplicate short name. Skipping course with idnumber '{\$a->idnumber}'...";
$string['editlock'] = 'Lock value';
$string['emptyenrolment'] = "Empty enrolment for role '{\$a->role_shortname}' in course '{\$a->course_shortname}'\n";
$string['enrolname'] = 'LDAP';
Expand Down
6 changes: 6 additions & 0 deletions enrol/ldap/lib.php
Expand Up @@ -990,6 +990,12 @@ function create_course($course_ext, progress_trace $trace) {
$course->summary = $course_ext[$this->get_config('course_summary')][0];
}

// Check if the shortname already exists if it does - skip course creation.
if ($DB->record_exists('course', array('shortname' => $course->shortname))) {
$trace->output(get_string('duplicateshortname', 'enrol_ldap', $course));
return false;
}

$newcourse = create_course($course);
return $newcourse->id;
}
Expand Down

0 comments on commit 9dccff7

Please sign in to comment.