Skip to content

Commit

Permalink
MDL-49953 enrol_cohort: correction to string
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Apr 22, 2015
1 parent 42c92ee commit 5894432
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion enrol/cohort/lang/en/enrol_cohort.php
Expand Up @@ -26,7 +26,7 @@
$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.';
Expand Down
4 changes: 2 additions & 2 deletions enrol/cohort/lib.php
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions enrol/cohort/tests/cohortlib_test.php
Expand Up @@ -69,18 +69,18 @@ public function test_enrol_cohort_create_new_group() {
$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);

}
}

0 comments on commit 5894432

Please sign in to comment.