--- lib.php 2011-08-27 02:25:07.000000000 +1000 +++ lib.php 2011-11-04 13:52:23.000000000 +1100 @@ -315,8 +315,11 @@ if(preg_match('{.*?(.+?).*?}is', $tagcontents, $matches)){ $group->coursecode = trim($matches[1]); } + if(preg_match('{.*?(.*?).*?}is', $tagcontents, $matches)){ + $group->description = trim($matches[1]); + } if(preg_match('{.*?(.*?).*?}is', $tagcontents, $matches)){ - $group->description = trim($matches[1]); + $group->shortName = trim($matches[1]); } if(preg_match('{.*?(.*?).*?}is', $tagcontents, $matches)){ $group->category = trim($matches[1]); @@ -354,11 +357,23 @@ if(!$DB->get_field('course', 'id', array('idnumber'=>$coursecode))) { if(!$createnewcourses) { $this->log_line("Course $coursecode not found in Moodle's course idnumbers."); - } else { + } 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 $course = new stdClass(); $course->fullname = $group->description; - $course->shortname = $coursecode; + $course->shortname = $group->shortName; $course->idnumber = $coursecode; $course->format = 'topics'; $course->visible = 0;