From ed3cdf07fcf4294a208ae65e244c12804314e2f5 Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Wed, 1 Aug 2007 07:40:40 +0000 Subject: [PATCH] scales should be (courseid, scale) unique, since it's already abused it's not possible to add a unique in db, so we add additional check in GUI. Duplicate scale, course causes mapping problems in backup/restore --- grade/edit/scale/edit_form.php | 12 ++++++++++-- lang/en_utf8/grades.php | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/grade/edit/scale/edit_form.php b/grade/edit/scale/edit_form.php index 7539410f37..d617b187dd 100644 --- a/grade/edit/scale/edit_form.php +++ b/grade/edit/scale/edit_form.php @@ -81,7 +81,17 @@ class edit_scale_form extends moodleform { /// perform extra validation before submission function validation($data){ + + global $CFG; + $errors= array(); + + // we can not allow 2 scales with the same exact scale as this creates + // problems for backup/restore + $courseid = empty($data['courseid'])?0:$data['courseid']; + if (count_records('scale', 'courseid', $courseid, 'scale', $data['scale'])) { + $errors['scale'] = get_string('duplicatescale', 'grades'); + } $options = explode(',', $data['scale']); if (count($options) < 2) { @@ -94,8 +104,6 @@ class edit_scale_form extends moodleform { return $errors; } } - - } ?> diff --git a/lang/en_utf8/grades.php b/lang/en_utf8/grades.php index afe9f8152d..c7940cae39 100644 --- a/lang/en_utf8/grades.php +++ b/lang/en_utf8/grades.php @@ -94,6 +94,7 @@ $string['droplow'] = 'Drop the lowest'; $string['dropped'] = 'Dropped'; $string['dropxlowest'] = 'Drop X Lowest'; $string['dropxlowestwarning'] = 'Note: If you use drop x lowest the grading assumes that all items in the category have the same point value. If point values differ results will be unpredictable'; +$string['duplicatescale'] = 'Duplicate scale'; $string['edit'] = 'Edit'; $string['editcalculation'] = 'Edit Calculation'; $string['editfeedback'] = 'Edit Feedback'; -- 2.39.5