MDL-13730 site setting for aggregation of scales
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -80,6 +80,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.';
|
||||
@@ -258,6 +259,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';
|
||||
|
||||
@@ -3194,6 +3194,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
|
||||
*/
|
||||
|
||||
@@ -2939,6 +2939,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;
|
||||
}
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user