Permalink
Browse files

MDL-32662 core_group_xxx_groupings: Fixed integrator review potential…

  • Loading branch information...
1 parent 67aa60f commit 2c8ad38effa7389655c4a99d28cfe466d09b51be @jleyva jleyva committed May 16, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 group/externallib.php
View
@@ -574,7 +574,7 @@ public static function create_groupings_parameters() {
/**
* Create groupings
- *
+ *
* @param array $groupings array of grouping description arrays (with keys groupname and courseid)
* @return array of newly created groupings
* @since Moodle 2.3
@@ -690,6 +690,13 @@ public static function update_groupings($groupings) {
if (! $currentgrouping = $DB->get_record('groupings', array('id'=>$grouping->id))) {
throw new invalid_parameter_exception("Grouping $grouping->id does not exist in the course");
}
+
+ // Check if the new modified grouping name already exists in the course.
+ if ($grouping->name != $currentgrouping->name and
+ $DB->count_records('groupings', array('courseid'=>$currentgrouping->courseid, 'name'=>$grouping->name))) {
+ throw new invalid_parameter_exception('A different grouping with the same name already exists in the course');
+ }
+
$grouping->courseid = $currentgrouping->courseid;
// Now security checks.

0 comments on commit 2c8ad38

Please sign in to comment.