]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13730 site setting for aggregation of scales; merged from MOODLE_19_STABLE
authorskodak <skodak>
Mon, 3 Mar 2008 11:03:54 +0000 (11:03 +0000)
committerskodak <skodak>
Mon, 3 Mar 2008 11:03:54 +0000 (11:03 +0000)
admin/settings/grades.php
lang/en_utf8/grades.php
lib/adminlib.php
lib/db/upgrade.php
lib/grade/grade_category.php
lib/grade/grade_item.php

index 668e15e3acc79487a28b6045f0e10496ee1e9e2f..05ea2f682d810d6dc0bab1b93345f6d77baa6f55 100644 (file)
@@ -24,10 +24,12 @@ if (has_capability('moodle/grade:manage', $systemcontext)
                                                   array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'),
                                                         GRADE_REPORT_AGGREGATION_POSITION_LAST => get_string('positionlast', 'grades'))));
 
-        $temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', get_string('hiddenasdate', 'grades'), get_string('confighiddenasdate', 'grades'), 0, PARAM_INT));
+        $temp->add(new admin_setting_regradingcheckbox('grade_includescalesinaggregation', get_string('includescalesinaggregation', 'grades'), get_string('configincludescalesinaggregation', 'grades'), 1));
+
+        $temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', get_string('hiddenasdate', 'grades'), get_string('confighiddenasdate', 'grades'), 0));
 
         // enable publishing in exports/imports
-        $temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('configgradepublishing', 'grades'), 0, PARAM_INT));
+        $temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('configgradepublishing', 'grades'), 0));
 
         $temp->add(new admin_setting_configselect('grade_export_displaytype', get_string('gradeexportdisplaytype', 'grades'),
                                                   get_string('configgradeexportdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
index 8bc775967a0beaf3e0ac19e7aa3c9bbe667510bd..c5dae01d41a7ea60a13707bfbbcb3e951388a7dd 100644 (file)
@@ -79,6 +79,7 @@ $string['configgradeletter'] = 'A letter or other symbol used to represent a ran
 $string['configgradeletterdefault'] = 'A letter or other symbol used to represent a range of grades. Leave this field empty to use the site default (currently $a).';
 $string['configgradepublishing'] = 'Enable publishing in exports and imports: Exported grades can be accessed by accessing a URL, without having to log on to a Moodle site. Grades can be imported by accessing such a URL (which means that a Moodle site can import grades published by another site). By default only administrators may use this feature, please educate users before adding required capabilities to other roles (dangers of bookmark sharing and download accelerators, IP restrictions, etc.).';
 $string['confighiddenasdate'] = 'If user can not see hidden grades show date of submission instead of \'-\'.';
+$string['configincludescalesinaggregation'] = 'You can change whether scales are to be included as numbers in all aggregated grades across all gradebooks in all courses. CAUTION: changing this setting will force all aggregated grades to be recalculated.';
 $string['configmeanselection'] = 'Whether cells with no grade should be included when calculating the mean for each column.';
 $string['configprofilereport'] = 'Grade report used on user profile page.';
 $string['configshowquickfeedback'] = 'Quick Feedback adds a text input element in each grade cell on the grader report, allowing you to edit the feedback for many grades at once. You can then click the Update button to perform all these changes at once, instead of one at a time.';
@@ -257,6 +258,7 @@ $string['importskippednomanagescale'] = 'You don\'t have permission to add a new
 $string['importskippedoutcome'] = 'An outcome with shortname \"$a\" already exists in this context, the one in the imported file was skipped.';
 $string['importsuccess'] = 'Grade import success';
 $string['importxml'] = 'Import XML';
+$string['includescalesinaggregation'] = 'Include scales in aggregation';
 $string['incorrectcourseid'] = 'Course ID was incorrect';
 $string['incorrectminmax'] = 'The minimum must be lower than the maximum';
 $string['inherit'] = 'Inherit';
index 092985354eca28c0df39f10c49f1ffb2ae16a89a..39f1dba8234d1f8f5f32801c635176f1719a7ba2 100644 (file)
@@ -3243,6 +3243,23 @@ class admin_setting_special_gradebookroles extends admin_setting_configmultichec
     }
 }
 
+class admin_setting_regradingcheckbox extends admin_setting_configcheckbox {
+    function write_setting($data) {
+        global $CFG;
+
+        $oldvalue  = $this->config_read($this->name);
+        $return    = parent::write_setting($data);
+        $newvalue  = $this->config_read($this->name);
+
+        if ($oldvalue !== $newvalue) {
+            // force full regrading
+            set_field('grade_items', 'needsupdate', 1, 'needsupdate', 0);
+        }
+
+        return $return;
+    }    
+}
+
 /**
  * Which roles to show on course decription page
  */
index 9c377d8688972e90519f76af53588903940b87b0..40d5fa16cf13b5991f5af09ba106058e0ff2d504 100644 (file)
@@ -2945,6 +2945,10 @@ function xmldb_main_upgrade($oldversion=0) {
         upgrade_main_savepoint($result, 2007101508.08);
     }
 
+    if ($result && $oldversion < 2007101509) {
+        // force full regrading
+        set_field('grade_items', 'needsupdate', 1, 'needsupdate', 0);
+    }
 
     return $result;
 }
index 495001b6b5a53aca9779dedba617b5845d57e580..545f9343ffc5e1c956b40f9a38e405b5ea57e318 100644 (file)
@@ -697,16 +697,15 @@ class grade_category extends grade_object {
 
         //find max grade
         foreach ($items as $item) {
-            if ($item->gradetype != GRADE_TYPE_VALUE) {
-                // sum only items with value grades, no scales and outcomes!
-                unset($grade_values[$item->id]);
-                continue;
-            }
             if ($item->aggregationcoef > 0) {
                 // extra credit from this activity - does not affect total
                 continue;
             }
-            $max += $item->grademax;
+            if ($item->gradetype == GRADE_TYPE_VALUE) {
+                $max += $item->grademax;
+            } else if ($item->gradetype == GRADE_TYPE_SCALE) {
+                $max += $item->grademax - 1; // scales min is 1
+            }
         }
 
         if ($this->grade_item->grademax != $max or $this->grade_item->grademin != 0 or $this->grade_item->gradetype != GRADE_TYPE_VALUE){
index 86b01b7761a6010b4aeb2acb4dcd1237f9f655cb..8ad789c34dea18422897641133476f27fcf9ad8b 100644 (file)
@@ -1236,11 +1236,17 @@ class grade_item extends grade_object {
                 $outcomes_sql = "AND gi.outcomeid IS NULL";
             }
 
+            if (empty($CFG->grade_includescalesinaggregation)) {
+                $gtypes = "gi.gradetype = ".GRADE_TYPE_VALUE;
+            } else {
+                $gtypes = "(gi.gradetype = ".GRADE_TYPE_VALUE." OR gi.gradetype = ".GRADE_TYPE_SCALE.")";
+            }
+
             if ($grade_category->aggregatesubcats) {
                 // return all children excluding category items
                 $sql = "SELECT gi.id
                           FROM {$CFG->prefix}grade_items gi
-                         WHERE (gi.gradetype = ".GRADE_TYPE_VALUE." OR gi.gradetype = ".GRADE_TYPE_SCALE.")
+                         WHERE $gtypes 
                                $outcomes_sql
                                AND gi.categoryid IN (
                                   SELECT gc.id
@@ -1251,7 +1257,7 @@ class grade_item extends grade_object {
                 $sql = "SELECT gi.id
                           FROM {$CFG->prefix}grade_items gi
                          WHERE gi.categoryid = {$grade_category->id}
-                               AND (gi.gradetype = ".GRADE_TYPE_VALUE." OR gi.gradetype = ".GRADE_TYPE_SCALE.")
+                               AND $gtypes
                                $outcomes_sql
 
                         UNION
@@ -1260,7 +1266,7 @@ class grade_item extends grade_object {
                           FROM {$CFG->prefix}grade_items gi, {$CFG->prefix}grade_categories gc
                          WHERE (gi.itemtype = 'category' OR gi.itemtype = 'course') AND gi.iteminstance=gc.id
                                AND gc.parent = {$grade_category->id}
-                               AND (gi.gradetype = ".GRADE_TYPE_VALUE." OR gi.gradetype = ".GRADE_TYPE_SCALE.")
+                               AND $gtypes
                                $outcomes_sql";
             }