]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9628 Fixed typos and added language strings. Corrected a bug that prevented a...
authornicolasconnault <nicolasconnault>
Fri, 20 Jul 2007 07:31:13 +0000 (07:31 +0000)
committernicolasconnault <nicolasconnault>
Fri, 20 Jul 2007 07:31:13 +0000 (07:31 +0000)
grade/edit/category_form.php
grade/report/lib.php
lang/en_utf8/grades.php
lib/grade/grade_category.php

index 01597f132116ced4cd397af2a408c46c38db8688..2ceaac302f6c18e701109f0f54d7ef029d87c017 100644 (file)
@@ -11,14 +11,14 @@ class edit_category_form extends moodleform {
         $mform->addElement('header', 'general', get_string('gradecategory', 'grades'));
         $mform->addElement('text', 'fullname', get_string('categoryname', 'grades'));
 
-        $options = array(GRADE_AGGREGATE_MEAN_ALL   =>get_string('aggregatemeanall', 'grades'),
-                         GRADE_AGGREGATE_MEAN_GRADED=>get_string('aggregatemeangraded', 'grades'),
-                         GRADE_AGGREGATE_MEDIAN     =>get_string('aggregatemedian', 'grades'),
-                         GRADE_AGGREGATE_MIN        =>get_string('aggregatemin', 'grades'),
-                         GRADE_AGGREGATE_MAX        =>get_string('aggregatemax', 'grades'),
-                         GRADE_AGGREGATE_MODE       =>get_string('aggregatemode', 'grades'),
+        $options = array(GRADE_AGGREGATE_MEAN_ALL               =>get_string('aggregatemeanall', 'grades'),
+                         GRADE_AGGREGATE_MEAN_GRADED            =>get_string('aggregatemeangraded', 'grades'),
+                         GRADE_AGGREGATE_MEDIAN                 =>get_string('aggregatemedian', 'grades'),
+                         GRADE_AGGREGATE_MIN                    =>get_string('aggregatemin', 'grades'),
+                         GRADE_AGGREGATE_MAX                    =>get_string('aggregatemax', 'grades'),
+                         GRADE_AGGREGATE_MODE                   =>get_string('aggregatemode', 'grades'),
                          GRADE_AGGREGATE_WEIGHTED_MEAN_ALL      =>get_string('aggregateweightedmeanall', 'grades'),
-                         GRADE_AGGREGATE_WEIGHTED_MEAN_GRADED   =>get_string('aggregateweightedgraded', 'grades'),
+                         GRADE_AGGREGATE_WEIGHTED_MEAN_GRADED   =>get_string('aggregateweightedmeangraded', 'grades'),
                          GRADE_AGGREGATE_EXTRACREDIT_MEAN_ALL   =>get_string('aggregateextracreditmeanall', 'grades'),
                          GRADE_AGGREGATE_EXTRACREDIT_MEAN_GRADED=>get_string('aggregateextracreditmeangraded', 'grades'));
 
index eb9d9ba11e006512247ea0ae06ddb0932d82f05f..5c9799103173d1ae3d65f5606966d9a0dd200b12 100755 (executable)
@@ -234,7 +234,7 @@ class grade_report {
             $gradeval = '';
         } else {
             // decimal points as specified by user
-            if (empty($decimalpoints)) {
+            if (is_null($decimalpoints)) {
                 $decimalpoints = $this->get_pref('decimalpoints');
             }
             $gradeval = number_format($gradeval, $decimalpoints, $this->get_lang_string('decpoint', 'langconfig'),
index 818d08991ac2dae51b0fd5a132f2769128cbdae6..1cb217cdfd835d1d43e93b2129c7e948d5af8d0e 100644 (file)
@@ -7,12 +7,16 @@ $string['addcategoryerror'] = 'Could not add category.';
 $string['addexceptionerror'] = 'Error occurred while adding exception for userid:gradeitem';
 $string['addfeedback'] = 'Add Feedback';
 $string['additem'] = 'Add Grade Item';
+$string['aggregateextracreditmeanall'] = 'Mean of all grades (extra credits)';
+$string['aggregateextracreditmeangraded'] = 'Mean of non-empty grades (extra credits)';
 $string['aggregatemeanall'] = 'Mean of all grades';
 $string['aggregatemedian'] = 'Median of all grades';
 $string['aggregatemeangraded'] = 'Mean of non-empty grades';
 $string['aggregatemin'] = 'Smallest grade';
 $string['aggregatemax'] = 'Highest grade';
 $string['aggregatemode'] = 'Mode of all grades';
+$string['aggregateweightedmeanall'] = 'Weighted mean of all grades';
+$string['aggregateweightedmeangraded'] = 'Weighted mean of non-empty grades';
 $string['aggregation'] = 'Aggregation';
 $string['aggregationposition'] = 'Aggregation position';
 $string['aggregationview'] = 'Aggregation view';
index ad2ffb7bee74e9dce9fe0aaebb025da27da40314..3a62f8e736cbb0b4f31dafccc14819095e6aa1a9 100644 (file)
@@ -423,7 +423,7 @@ class grade_category extends grade_object {
         }
 
     /// normalize the grades first - all will have value 0...1
-        // ungraded items are not used in aggreagation
+        // ungraded items are not used in aggregation
         foreach ($grade_values as $k=>$v) {
             if (is_null($v)) {
                 // null means no grade
@@ -437,7 +437,7 @@ class grade_category extends grade_object {
         $this->apply_limit_rules($grade_values);
         asort($grade_values, SORT_NUMERIC);
 
-        // let's see we have still enough grades to do any statisctics
+        // let's see we have still enough grades to do any statistics
         if (count($grade_values) == 0) {
             // not enough attempts yet
             $grade->finalgrade = null;
@@ -452,12 +452,18 @@ class grade_category extends grade_object {
         switch ($this->aggregation) {
             case GRADE_AGGREGATE_MEDIAN: // Middle point value in the set: ignores frequencies
                 $num = count($grade_values);
+                // re-index grade_values array
+                $sorted_values = $grade_values;
+                sort($sorted_values);
                 $halfpoint = intval($num / 2);
-
-                if($num % 2 == 0) {
-                    $rawgrade = ($grade_values[ceil($halfpoint)] + $grade_values[floor($halfpoint)]) / 2;
+                if ($num == 0) {
+                    $rawgrade = null;
+                } elseif ($num == 1) {
+                    $rawgrade = reset($sorted_values);
+                } else if($num % 2 == 0) {
+                    $rawgrade = ($sorted_values[ceil($halfpoint)] + $sorted_values[floor($halfpoint)]) / 2;
                 } else {
-                    $rawgrade = $grade_values[$halfpoint];
+                    $rawgrade = $sorted_values[$halfpoint];
                 }
                 break;
 
@@ -550,7 +556,7 @@ class grade_category extends grade_object {
                 }
                 break;
 
-            case GRADE_AGGREGATE_MEAN_ALL:    // Arithmetic average of all grade items including even NULLs; NULL grade caunted as minimum
+            case GRADE_AGGREGATE_MEAN_ALL:    // Arithmetic average of all grade items including even NULLs; NULL grade counted as minimum
                 $num = count($items);     // you can calculate sum from this one if you multiply it with count($this->depends_on() ;-)
                 $sum = array_sum($grade_values);
                 $rawgrade = $sum / $num;