- $options = explode(',', $data['scale']);
- if (count($options) < 2) {
- $errors['scale'] = get_string('badlyformattedscale', 'grades');
+ if ($count) {
+ //if this is a new scale but we found a duplice in the DB
+ //or we found a duplicate in another course report the error
+ if (empty($old->id) or $old->courseid != $courseid) {
+ $errors['scale'] = get_string('duplicatescale', 'grades');
+ } else if ($old->scale !== $thescale and $old->scale !== $data['scale']) {
+ //if the old scale from DB is different but we found a duplicate then we're trying to modify a scale to be a duplicate
+ $errors['scale'] = get_string('duplicatescale', 'grades');
+ }
+ }