Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-29325 imsenterprise enrolment - allow more flexible naming of cou…

…rses - thanks to Adam Barbary for patch
  • Loading branch information...
commit b47316cded8a425c038449f7df5407ce15eca00c 1 parent f89a83b
@danmarsden danmarsden authored
Showing with 17 additions and 2 deletions.
  1. +17 −2 enrol/imsenterprise/lib.php
View
19 enrol/imsenterprise/lib.php
@@ -315,9 +315,12 @@ function process_group_tag($tagcontents) {
if (preg_match('{<sourcedid>.*?<id>(.+?)</id>.*?</sourcedid>}is', $tagcontents, $matches)) {
$group->coursecode = trim($matches[1]);
}
- if (preg_match('{<description>.*?<short>(.*?)</short>.*?</description>}is', $tagcontents, $matches)) {
+ if (preg_match('{<description>.*?<long>(.*?)</long>.*?</description>}is', $tagcontents, $matches)){
$group->description = trim($matches[1]);
}
+ if (preg_match('{<description>.*?<short>(.*?)</short>.*?</description>}is', $tagcontents, $matches)) {
+ $group->shortName = trim($matches[1]);
+ }
if (preg_match('{<org>.*?<orgunit>(.*?)</orgunit>.*?</org>}is', $tagcontents, $matches)) {
$group->category = trim($matches[1]);
}
@@ -355,11 +358,23 @@ function process_group_tag($tagcontents) {
if (!$createnewcourses) {
$this->log_line("Course $coursecode not found in Moodle's course idnumbers.");
} else {
+ // Set shortname to description or description to shortname if one is set but not the other.
+ if (!isset($group->description) && !isset($group->shortName)) {
+ // If neither short nor long description are set let if fail
+ $this->log_line("Neither long nor short name are set for $coursecode");
+ } else if (!isset($group->description)) {
+ // If short and ID exist, then give the long short's value, then give short the ID's value
+ $group->description = $group->shortName;
+ $group->shortName = $coursecode;
+ } else if (!isset($group->shortName)) {
+ // If long and ID exist, then map long to long, then give short the ID's value.
+ $group->shortName = $coursecode;
+ }
// Create the (hidden) course(s) if not found
$courseconfig = get_config('moodlecourse'); // Load Moodle Course shell defaults
$course = new stdClass();
$course->fullname = $group->description;
- $course->shortname = $coursecode;
+ $course->shortname = $group->shortName;;
$course->idnumber = $coursecode;
$course->format = $courseconfig->format;
$course->visible = $courseconfig->visible;
Please sign in to comment.
Something went wrong with that request. Please try again.