]> git.mjollnir.org Git - moodle.git/commitdiff
scales should be (courseid, scale) unique, since it's already abused it's not possibl...
authortoyomoyo <toyomoyo>
Wed, 1 Aug 2007 07:40:40 +0000 (07:40 +0000)
committertoyomoyo <toyomoyo>
Wed, 1 Aug 2007 07:40:40 +0000 (07:40 +0000)
grade/edit/scale/edit_form.php
lang/en_utf8/grades.php

index 7539410f373ecee58044fc1eb728af57e685199d..d617b187dd6c9053a36d5349b8088915c1dedbf8 100644 (file)
@@ -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;
         }
     }
-
-
 }
 
 ?>
index afe9f8152d6e9e522d06911360ed3d4bd4420d15..c7940cae392f645f59dcbd3d0233f2da69b818e7 100644 (file)
@@ -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';