MDL-41259 when duplicate course shortname exists an exception is thrown and sync is aborted

This commit is contained in:
Nitzan Bar 2013-08-15 16:27:01 +03:00 committed by Nitzan Bar
parent d2aa53be1b
commit fdb04f62e9
2 changed files with 7 additions and 0 deletions

View File

@ -53,6 +53,7 @@ $string['course_summary_key'] = 'Summary';
$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';

View File

@ -990,6 +990,12 @@ class enrol_ldap_plugin extends enrol_plugin {
$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;
}