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,
$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.';
$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';
}
}
+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
*/
upgrade_main_savepoint($result, 2007101508.08);
}
+ if ($result && $oldversion < 2007101509) {
+ // force full regrading
+ set_field('grade_items', 'needsupdate', 1, 'needsupdate', 0);
+ }
return $result;
}
//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){
$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
$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
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";
}