--- lib_old.php 2011-09-05 11:28:54.000000000 +1000 +++ lib.php 2011-09-12 11:05:15.000000000 +1000 @@ -315,9 +315,12 @@ if(preg_match('{.*?(.+?).*?}is', $tagcontents, $matches)){ $group->coursecode = trim($matches[1]); } - if(preg_match('{.*?(.*?).*?}is', $tagcontents, $matches)){ + if(preg_match('{.*?(.*?).*?}is', $tagcontents, $matches)){ $group->description = trim($matches[1]); } + if(preg_match('{.*?(.*?).*?}is', $tagcontents, $matches)){ + $group->shortName = trim($matches[1]); + } if(preg_match('{.*?(.*?).*?}is', $tagcontents, $matches)){ $group->category = trim($matches[1]); } @@ -355,10 +358,22 @@ 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 $course = new stdClass(); $course->fullname = $group->description; - $course->shortname = $coursecode; + $course->shortname = $group->shortName; $course->idnumber = $coursecode; $course->format = 'topics'; $course->visible = 0;