MDL-49953 enrol_cohort: correction to string

This commit is contained in:
Marina Glancy 2015-04-09 12:43:53 +08:00
parent 42c92eef33
commit 5894432c50
3 changed files with 6 additions and 6 deletions

View file

@ -26,7 +26,7 @@ $string['addgroup'] = 'Add to group';
$string['assignrole'] = 'Assign role';
$string['cohort:config'] = 'Configure cohort instances';
$string['cohort:unenrol'] = 'Unenrol suspended users';
$string['defaultgroupnametext'] = '{$a->name} cohort{$a->increment}';
$string['defaultgroupnametext'] = '{$a->name} cohort {$a->increment}';
$string['instanceexists'] = 'Cohort is already synchronised with selected role';
$string['pluginname'] = 'Cohort sync';
$string['pluginname_desc'] = 'Cohort enrolment plugin synchronises cohort members with course participants.';

View file

@ -343,12 +343,12 @@ function enrol_cohort_create_new_group($courseid, $cohortid) {
$a = new stdClass();
$a->name = $groupname;
$a->increment = '';
$groupname = get_string('defaultgroupnametext', 'enrol_cohort', $a);
$groupname = trim(get_string('defaultgroupnametext', 'enrol_cohort', $a));
$inc = 1;
// Check to see if the cohort group name already exists. Add an incremented number if it does.
while ($DB->record_exists('groups', array('name' => $groupname, 'courseid' => $courseid))) {
$a->increment = '(' . (++$inc) . ')';
$newshortname = get_string('defaultgroupnametext', 'enrol_cohort', $a);
$newshortname = trim(get_string('defaultgroupnametext', 'enrol_cohort', $a));
$groupname = $newshortname;
}
// Create a new group for the cohort.

View file

@ -69,18 +69,18 @@ class enrol_cohort_lib_testcase extends advanced_testcase {
$groupid = enrol_cohort_create_new_group($course2->id, $cohort->id);
$groupinfo = $DB->get_record('groups', array('id' => $groupid));
// Check that the group name has been changed.
$this->assertEquals($cohort->name . ' cohort(2)', $groupinfo->name);
$this->assertEquals($cohort->name . ' cohort (2)', $groupinfo->name);
// Create another group that will have the same name as a generated cohort.
$groupdata = new stdClass();
$groupdata->courseid = $course2->id;
$groupdata->name = $cohort->name . ' cohort(2)';
$groupdata->name = $cohort->name . ' cohort (2)';
groups_create_group($groupdata);
// Create a group for the cohort in course 2.
$groupid = enrol_cohort_create_new_group($course2->id, $cohort->id);
$groupinfo = $DB->get_record('groups', array('id' => $groupid));
// Check that the group name has been changed.
$this->assertEquals($cohort->name . ' cohort(3)', $groupinfo->name);
$this->assertEquals($cohort->name . ' cohort (3)', $groupinfo->name);
}
}