]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10481 fixing broken form defaults - sorry
authorskodak <skodak>
Tue, 17 Jul 2007 19:38:27 +0000 (19:38 +0000)
committerskodak <skodak>
Tue, 17 Jul 2007 19:38:27 +0000 (19:38 +0000)
grade/edit/item.php

index 013af496becb89b7388c617fb54a38c5a3263b20..4da1c2f04e7acf3d188cdf42ef66a1ce142a84aa 100644 (file)
@@ -25,21 +25,22 @@ $mform = new edit_item_form(null, array('gpr'=>$gpr));
 
 if ($mform->is_cancelled()) {
     redirect($returnurl);
+}
 
-} else if (!$mform->is_submitted()) {
-    if ($item = get_record('grade_items', 'id', $id, 'courseid', $course->id)) {
-       // Get Item preferences
-       $item->pref_gradedisplaytype = get_user_preferences('grade_report_gradedisplaytype' . $id, 'default');
-       $item->pref_decimalpoints    = get_user_preferences('grade_report_decimalpoints' . $id, 'default');
+if ($item = get_record('grade_items', 'id', $id, 'courseid', $course->id)) {
+    // Get Item preferences
+    $item->pref_gradedisplaytype = get_user_preferences('grade_report_gradedisplaytype' . $id, 'default');
+    $item->pref_decimalpoints    = get_user_preferences('grade_report_decimalpoints' . $id, 'default');
 
-       $item->calculation = grade_item::denormalize_formula($item->calculation, $course->id);
-       $mform->set_data($item);
+    $item->calculation = grade_item::denormalize_formula($item->calculation, $course->id);
+    $mform->set_data($item);
 
-   } else {
-       $mform->set_data(array('courseid'=>$course->id, 'itemtype'=>'manual'));
-   }
+} else {
+    // defaults for new items
+    $mform->set_data(array('courseid'=>$course->id, 'itemtype'=>'manual'));
+}
 
-} else if ($data = $mform->get_data()) {
+if ($data = $mform->get_data()) {
     $errors = array();
 
     if (array_key_exists('calculation', $data)) {