]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11495 removed GRADE_DECIMALS_DEFAULT null constant, is_null() used instead for...
authorskodak <skodak>
Fri, 28 Sep 2007 11:08:44 +0000 (11:08 +0000)
committerskodak <skodak>
Fri, 28 Sep 2007 11:08:44 +0000 (11:08 +0000)
grade/edit/gradedisplay/gradedisplay_form.php
grade/edit/gradedisplay/index.php
grade/edit/tree/item.php
grade/edit/tree/item_form.php
lib/grade/constants.php
lib/grade/grade_item.php

index 5c4f04a7db0848252ef857ce97aa2770c2fccc8b..ab332611ca193468cb7292e1808201b57a513b1e 100644 (file)
@@ -27,7 +27,7 @@ class edit_grade_display_form extends moodleform {
         $mform->setDefault('display', $coursegradedisplaytype);
         $mform->setType($coursegradedisplaytype, PARAM_INT);
 
-        $options = array(GRADE_DECIMALS_DEFAULT => get_string('default', 'grades'), 0, 1, 2, 3, 4, 5);
+        $options = array(-1=>get_string('default', 'grades'), 0, 1, 2, 3, 4, 5);
         $label = get_string('decimalpoints', 'grades') . ' (' . get_string('default', 'grades') . ': ' . $options[$CFG->grade_report_decimalpoints] . ')';
         $mform->addElement('select', 'decimals', $label, $options);
         $mform->setHelpButton('decimals', array(false, get_string('decimalpoints', 'grades'), false, true, false, get_string("configdecimalpoints", 'grades')));
index e0ab28c94a105ebf80983b2285eba3092467e189..a06cc8c23d99dd4e0b76f05e037e1c2f54d57de4 100644 (file)
@@ -57,7 +57,7 @@ if ($mform->is_cancelled()) {
 
     // Update course item's decimals type
     if (isset($data->decimals)) {
-        if (strlen($data->decimals) < 1) {
+        if ($data->decimals < 0) {
             $data->decimals = null;
         }
         set_field('grade_items', 'decimals', $data->decimals, 'courseid', $courseid, 'itemtype', 'course');
index a44b87e63f00db24e93aa238d0ce4a80692a83e3..e48199d0e120166ee759767aec86a428edd05319 100644 (file)
@@ -83,7 +83,7 @@ if ($data = $mform->get_data(false)) {
     $grade_item->outcomeid = null;
 
     // Handle null decimals value
-    if (strlen($data->decimals) < 1) {
+    if (!array_key_exists('decimals', $data) or $data->decimals < 0) {
         $grade_item->decimals = null;
     }
 
index 4a6297306951d6300255d42162ff6ee69259b956..2254dd7e67b5c98f82f450a1c73e8bb5c38bc0c9 100644 (file)
@@ -98,14 +98,11 @@ class edit_item_form extends moodleform {
                               false, true, false, get_string("configgradedisplaytype", 'grades')));
 
         // Determine default value for decimalpoints (site or course)
-        $course_gradedecimals = get_field('grade_items', 'decimals', 'courseid', $COURSE->id, 'itemtype', 'course');
-        $site_gradedecimals = $CFG->grade_report_decimalpoints;
-        $default_gradedecimals = $course_gradedecimals;
-
-        if ($course_gradedecimals == GRADE_DECIMALS_DEFAULT) {
-            $default_gradedecimals = $site_gradedecimals;
+        $default_gradedecimals = get_field('grade_items', 'decimals', 'courseid', $COURSE->id, 'itemtype', 'course');
+        if (is_null($default_gradedecimals)) {
+            $default_gradedecimals = $CFG->grade_report_decimalpoints;
         }
-        $options = array(GRADE_DECIMALS_DEFAULT => get_string('default', 'grades'), 0, 1, 2, 3, 4, 5);
+        $options = array(-1=>get_string('default', 'grades'), 0, 1, 2, 3, 4, 5);
         $label = get_string('decimalpoints', 'grades') . ' (' . get_string('default', 'grades') . ': ' . $options[$default_gradedecimals] . ')';
         $mform->addElement('select', 'decimals', $label, $options);
         $mform->setHelpButton('decimals', array(false, get_string('decimalpoints', 'grades'),
index 3ca326b4144b085ef67a4385c93ab9c152b4a48a..b56b0f33d8253eec9fe3485630f728eda3f3355c 100644 (file)
@@ -64,7 +64,6 @@ define('GRADE_DISPLAY_TYPE_DEFAULT', 0);
 define('GRADE_DISPLAY_TYPE_REAL', 1);
 define('GRADE_DISPLAY_TYPE_PERCENTAGE', 2);
 define('GRADE_DISPLAY_TYPE_LETTER', 3);
-define('GRADE_DECIMALS_DEFAULT', null);
 
 define('GRADE_REPORT_AGGREGATION_POSITION_LEFT', 0);
 define('GRADE_REPORT_AGGREGATION_POSITION_RIGHT', 1);
index 26b20e908e4821c56a0d4a430c4e5da84cfa88d5..c3e4b464314738765551bd96e34c3b4d1498d484 100644 (file)
@@ -212,7 +212,7 @@ class grade_item extends grade_object {
      * The number of digits after the decimal point symbol. Applies only to REAL and PERCENTAGE grade display types.
      * @var int $decimals
      */
-    var $decimals = GRADE_DECIMALS_DEFAULT;
+    var $decimals = null;
 
     /**
      * 0 if visible, 1 always hidden or date not visible until
@@ -1722,14 +1722,14 @@ class grade_item extends grade_object {
         global $CFG;
         static $cache = array();
 
-        if ($this->decimals == GRADE_DECIMALS_DEFAULT) {
+        if (is_null($this->decimals)) {
             if (array_key_exists($this->courseid, $cache)) {
                 return $cache[$this->courseid];
             } else if (count($cache) > 100) {
                 $cache = array(); // cache size limit
             }
             $gradedecimals = get_field('grade_items', 'decimals', 'courseid', $this->courseid, 'itemtype', 'course');
-            if ($gradedecimals == GRADE_DECIMALS_DEFAULT) {
+            if (is_null($gradedecimals)) {
                 $gradedecimals = $CFG->grade_report_decimalpoints;
             }
             $cache[$this->courseid] = $gradedecimals;