Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-41259 when duplicate course shortname exists an exception is thro…

…wn and sync is aborted
  • Loading branch information...
commit fdb04f62e994a4b4a0450bab43412c610d828abf 1 parent d2aa53b
Nitzan Bar authored nitzo committed
Showing with 7 additions and 0 deletions.
  1. +1 −0  enrol/ldap/lang/en/enrol_ldap.php
  2. +6 −0 enrol/ldap/lib.php
View
1  enrol/ldap/lang/en/enrol_ldap.php
@@ -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';
View
6 enrol/ldap/lib.php
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.