// General settings
+require_once $CFG->libdir.'/grade/constants.php';
+
$temp = new admin_settingpage('gradessettings', get_string('gradessettings', 'grades'));
$temp->add(new admin_setting_special_gradeexport());
// enable outcomes checkbox
$temp->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0, PARAM_INT));
// 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_configselect('grade_displaytype', get_string('gradedisplaytype', 'grades'),
+ get_string('configgradedisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
+ array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
+ GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
+ GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'))));
+
+$temp->add(new admin_setting_configselect('grade_decimalpoints', get_string('decimalpoints', 'grades'),
+ get_string('configdecimalpoints', 'grades'), 2,
+ array( '0' => '0',
+ '1' => '1',
+ '2' => '2',
+ '3' => '3',
+ '4' => '4',
+ '5' => '5')));
+
$ADMIN->add('grades', $temp);
/// Scales and outcomes
$ADMIN->add('grades', $letters);
/// Grade category settings
-require_once $CFG->libdir . '/grade/constants.php';
$temp = new admin_settingpage('gradecategorysettings', get_string('gradecategorysettings', 'grades'));
+
$strnoforce = get_string('noforce', 'grades');
// Aggregation type
$decimalpoints = $item->get_decimals();
// Determine which display type to use for this average
- $gradedisplaytype = $item->get_displaytype();
-
if ($USER->gradeediting[$this->courseid]) {
$displaytype = GRADE_DISPLAY_TYPE_REAL;
- } elseif ($averagesdisplaytype == GRADE_REPORT_PREFERENCE_INHERIT) { // Inherit specific column or general preference
- $displaytype = $gradedisplaytype;
- } else { // General preference overrides specific column display type
+
+ } else if ($averagesdisplaytype == GRADE_REPORT_PREFERENCE_DEFAULT
+ or $averagesdisplaytype == GRADE_REPORT_PREFERENCE_INHERIT) {
+ $displaytype = $item->get_displaytype();
+
+ } else {
$displaytype = $averagesdisplaytype;
}
// Override grade_item setting if a display preference (not inherit) was set for the averages
- if ($averagesdecimalpoints != GRADE_REPORT_PREFERENCE_INHERIT) {
+ if ($averagesdecimalpoints == GRADE_REPORT_PREFERENCE_DEFAULT
+ or $averagesdecimalpoints == GRADE_REPORT_PREFERENCE_INHERIT) {
+ $decimalpoints = $item->get_decimals();
+
+ } else {
$decimalpoints = $averagesdecimalpoints;
}
$avghtml .= '<td class="cell c' . $columncount++.'">-</td>';
} else {
$sum = $sum_array[$item->id];
-
- if ($item->scaleid) {
- if ($grouponly) {
- $finalsum = $sum_array[$item->id];
- $finalavg = $finalsum/$mean_count;
- } else {
- $finalavg = $sum/$mean_count;
- }
- $scaleval = round($finalavg);
- $scale_object = new grade_scale(array('id' => $item->scaleid), false);
- $gradehtml = $scale_object->get_nearest_item($scaleval);
- $rawvalue = $scaleval;
- } else {
- $rawgradeval = $sum/$mean_count;
- $gradeval = format_float($sum/$mean_count, $decimalpoints);
- $gradehtml = $gradeval;
- }
-
- if ($displaytype == GRADE_DISPLAY_TYPE_PERCENTAGE or $displaytype == GRADE_DISPLAY_TYPE_LETTER) {
- $gradeshtml = grade_format_gradevalue($rawgradeval, $item, true, $displaytype, null);
- }
+ $avgradeval = $sum/$mean_count;
+ $gradehtml = grade_format_gradevalue($avgradeval, $item, true, $displaytype, $decimalpoints);
$numberofgrades = '';
-
if ($shownumberofgrades) {
$numberofgrades = " ($mean_count)";
}
$scalehtml = '';
if ($this->get_pref('showranges')) {
- $rangesdisplaytype = $this->get_pref('rangesdisplaytype');
+ $rangesdisplaytype = $this->get_pref('rangesdisplaytype');
$rangesdecimalpoints = $this->get_pref('rangesdecimalpoints');
+
$scalehtml = '<tr class="r'.$this->rowcount++.'">'
. '<th class="header c0 range" scope="row">'.$this->get_lang_string('range','grades').'</th>';
$columncount = 1;
foreach ($this->items as $item) {
- // Determine which display type to use for this range
- $decimalpoints = $item->get_decimals();
- $gradedisplaytype = $item->get_displaytype();
-
+ // Determine which display type to use for this average
if ($USER->gradeediting[$this->courseid]) {
$displaytype = GRADE_DISPLAY_TYPE_REAL;
- } elseif ($rangesdisplaytype == GRADE_REPORT_PREFERENCE_INHERIT) { // Inherit specific column or general preference
- $displaytype = $gradedisplaytype;
- } else { // General preference overrides specific column display type
+
+ } else if ($rangesdisplaytype == GRADE_REPORT_PREFERENCE_DEFAULT
+ or $rangesdisplaytype == GRADE_REPORT_PREFERENCE_INHERIT) {
+ $displaytype = $item->get_displaytype();
+
+ } else {
$displaytype = $rangesdisplaytype;
}
- // If ranges decimal points pref is set (but not to inherit), override grade_item setting
- if ($rangesdecimalpoints != GRADE_REPORT_PREFERENCE_INHERIT) {
+ // Override grade_item setting if a display preference (not default) was set for the averages
+ if ($rangesdecimalpoints == GRADE_REPORT_PREFERENCE_DEFAULT
+ or $rangesdecimalpoints == GRADE_REPORT_PREFERENCE_INHERIT) {
+ $decimalpoints = $item->get_decimals();
+
+ } else {
$decimalpoints = $rangesdecimalpoints;
}
- $grademin = 0;
- $grademax = 100;
-
- if ($displaytype == GRADE_DISPLAY_TYPE_REAL) {
- $grademin = format_float($item->grademin, $decimalpoints);
- $grademax = format_float($item->grademax, $decimalpoints);
- } elseif ($displaytype == GRADE_DISPLAY_TYPE_PERCENTAGE) {
- $grademin = 0;
- $grademax = 100;
- } elseif ($displaytype == GRADE_DISPLAY_TYPE_LETTER) {
- $letters = grade_report::get_grade_letters();
- $grademin = end($letters);
- $grademax = reset($letters);
+ if ($displaytype == GRADE_DISPLAY_TYPE_PERCENTAGE) {
+ $grademin = "0 %";
+ $grademax = "100 %";
+
+ } else {
+ $grademin = grade_format_gradevalue($item->grademin, $item, true, $displaytype, $decimalpoints);
+ $grademax = grade_format_gradevalue($item->grademax, $item, true, $displaytype, $decimalpoints);
}
- $scalehtml .= '<th class="header c'.$columncount++.' range">'. $grademin.'-'. $grademax.'</th>';
+ $scalehtml .= '<th class="header c'.$columncount++.' range">'. $grademin.'–'. $grademax.'</th>';
}
$scalehtml .= '</tr>';
}
}
}
- redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid, get_string('changessaved'), 1);
+ redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid); // message here breaks accessability and is sloooowww
exit;
}
$strconfiggradeboundary = get_string('configgradeboundary', 'grades');
$strgradeletter = get_string('gradeletter', 'grades');
$strconfiggradeletter = get_string('configgradeletter', 'grades');
- $strinherit = get_string('inherit', 'grades');
$stryes = get_string('yes');
$strno = get_string('no');
- $checkbox_default = array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default', 0 => $strno, 1 => $stryes);
+ $checkbox_default = array(GRADE_REPORT_PREFERENCE_DEFAULT => '*default*', 0 => $strno, 1 => $stryes);
/// form definition with preferences defaults
//--------------------------------------------------------------------------------
// Initialise the preferences arrays with grade:manage capabilities
if (has_capability('moodle/grade:manage', $context)) {
$preferences['prefgeneral'] = array(
- 'aggregationview' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
+ 'aggregationview' => array(GRADE_REPORT_PREFERENCE_DEFAULT => '*default*',
GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('fullmode', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY => get_string('aggregatesonly', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_GRADES_ONLY => get_string('gradesonly', 'grades')),
- 'meanselection' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
+ 'meanselection' => array(GRADE_REPORT_PREFERENCE_DEFAULT => '*default*',
GRADE_REPORT_MEAN_ALL => get_string('meanall', 'grades'),
GRADE_REPORT_MEAN_GRADED => get_string('meangraded', 'grades')));
'showlocks' => $checkbox_default);
$preferences['prefrows'] = array(
- 'averagesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
- GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
+ 'averagesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => get_string('default'),
GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
- 'rangesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
- GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
+ 'rangesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => get_string('default'),
GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
- 'averagesdecimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
- GRADE_REPORT_PREFERENCE_INHERIT => $strinherit, 0, 1, 2, 3, 4, 5),
- 'rangesdecimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
- GRADE_REPORT_PREFERENCE_INHERIT => $strinherit, 0, 1, 2, 3, 4, 5));
+ 'averagesdecimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => get_string('default'),
+ '0'=>0, '1'=>1, '2'=>2, '3'=>3, '4'=>4, '5'=>5),
+ 'rangesdecimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => get_string('default'),
+ '0'=>0, '1'=>1, '2'=>2, '3'=>3, '4'=>4, '5'=>5));
}
// View capability is the lowest permission. Users with grade:manage or grade:edit must also have grader:view
if (has_capability('gradereport/grader:view', $context)) {
$preferences['prefgeneral']['studentsperpage'] = 'text';
- $preferences['prefgeneral']['aggregationposition'] = array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
+ $preferences['prefgeneral']['aggregationposition'] = array(GRADE_REPORT_PREFERENCE_DEFAULT => '*default*',
GRADE_REPORT_AGGREGATION_POSITION_LEFT => get_string('left', 'grades'),
GRADE_REPORT_AGGREGATION_POSITION_RIGHT => get_string('right', 'grades'));
// $preferences['prefgeneral']['enableajax'] = $checkbox_default;
$help_string = get_string("config$lang_string", 'grades');
- // Replace the 'default' value with the site default language string
- if (!is_null($options) AND isset($options[GRADE_REPORT_PREFERENCE_DEFAULT]) && $options[GRADE_REPORT_PREFERENCE_DEFAULT] == 'default') {
+ // Replace the '*default*' value with the site default language string - 'default' might collide with custom language packs
+ if (!is_null($options) AND isset($options[GRADE_REPORT_PREFERENCE_DEFAULT]) && $options[GRADE_REPORT_PREFERENCE_DEFAULT] == '*default*') {
$options[GRADE_REPORT_PREFERENCE_DEFAULT] = get_string('sitedefault', 'grades', $default);
} elseif ($type == 'text') {
$help_string = get_string("config{$lang_string}default", 'grades', $default);
$this->add_action_buttons();
}
-
/// perform some extra moodle validation
function validation($data){
$errors= array();
$strpercentage = get_string('percentage', 'grades');
$strreal = get_string('real', 'grades');
$strletter = get_string('letter', 'grades');
+$strdefault = get_string('default');
/// Add settings for this module to the $settings object (it's already defined)
$settings->add(new admin_setting_configtext('grade_report_studentsperpage', get_string('studentsperpage', 'grades'),
$settings->add(new admin_setting_configcheckbox('grade_report_quickfeedback', get_string('quickfeedback', 'grades'),
get_string('configquickfeedback', 'grades'), 1));
-$settings->add(new admin_setting_configselect('grade_report_decimalpoints', get_string('decimalpoints', 'grades'),
- get_string('configdecimalpoints', 'grades'), 2,
- array( '0' => '0',
- '1' => '1',
- '2' => '2',
- '3' => '3',
- '4' => '4',
- '5' => '5')));
-
$settings->add(new admin_setting_configselect('grade_report_aggregationposition', get_string('aggregationposition', 'grades'),
get_string('configaggregationposition', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_RIGHT,
array(GRADE_REPORT_AGGREGATION_POSITION_LEFT => get_string('left', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY => get_string('aggregatesonly', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_GRADES_ONLY => get_string('gradesonly', 'grades'))));
-$settings->add(new admin_setting_configselect('grade_report_gradedisplaytype', get_string('gradedisplaytype', 'grades'),
- get_string('configgradedisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
- array(GRADE_DISPLAY_TYPE_REAL => $strreal,
- GRADE_DISPLAY_TYPE_PERCENTAGE => $strpercentage,
- GRADE_DISPLAY_TYPE_LETTER => $strletter)));
-
$settings->add(new admin_setting_configselect('grade_report_meanselection', get_string('meanselection', 'grades'),
get_string('configmeanselection', 'grades'), GRADE_REPORT_MEAN_ALL,
array(GRADE_REPORT_MEAN_ALL => get_string('meanall', 'grades'),
get_string('configshownumberofgrades', 'grades'), 0));
$settings->add(new admin_setting_configselect('grade_report_averagesdisplaytype', get_string('averagesdisplaytype', 'grades'),
- get_string('configaveragesdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
- array(GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
+ get_string('configaveragesdisplaytype', 'grades'), GRADE_REPORT_PREFERENCE_DEFAULT,
+ array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
GRADE_DISPLAY_TYPE_REAL => $strreal,
GRADE_DISPLAY_TYPE_PERCENTAGE => $strpercentage,
GRADE_DISPLAY_TYPE_LETTER => $strletter)));
$settings->add(new admin_setting_configselect('grade_report_rangesdisplaytype', get_string('rangesdisplaytype', 'grades'),
- get_string('configrangesdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
- array(GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
+ get_string('configrangesdisplaytype', 'grades'), GRADE_REPORT_PREFERENCE_DEFAULT,
+ array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
GRADE_DISPLAY_TYPE_REAL => $strreal,
GRADE_DISPLAY_TYPE_PERCENTAGE => $strpercentage,
GRADE_DISPLAY_TYPE_LETTER => $strletter)));
$settings->add(new admin_setting_configselect('grade_report_averagesdecimalpoints', get_string('averagesdecimalpoints', 'grades'),
get_string('configaveragesdecimalpoints', 'grades'), 2,
- array(GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
+ array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
'0' => '0',
'1' => '1',
'2' => '2',
'5' => '5')));
$settings->add(new admin_setting_configselect('grade_report_rangesdecimalpoints', get_string('rangesdecimalpoints', 'grades'),
get_string('configrangesdecimalpoints', 'grades'), 2,
- array(GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
+ array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
'0' => '0',
'1' => '1',
'2' => '2',
$string['compact'] = 'Compact';
$string['configaggregationposition'] = 'The position of the aggregation column in the grader report table, in reference to the real grades.';
$string['configaggregationview'] = 'Each category can be displayed in three ways: Full mode (aggregated column and grade item columns), the aggregated column only, or the grade items alone.';
-$string['configaveragesdecimalpoints'] = 'The number of decimal points to display for each average (group or whole), below a column of grades. This can be overriden per grading item.';
-$string['configaveragesdisplaytype'] = 'Specifies how to display the averages for each column in the grader report. The default and recommended value is Inherit, which first checks the display type of each column, and if such is not set explicitly, defaults to the more general Grade Display Type. If other display types are selected, they ignore the individual settings for each column, and use exclusively the selected type.';
+$string['configaveragesdecimalpoints'] = 'The number of decimal points to display for each average (group or whole), below a column of grades.';
+$string['configaveragesdisplaytype'] = 'Specifies how to display the averages for each column in the grader report. Default means to use the display type of each column.';
$string['configbulkcheckboxes'] = 'Checkboxes near each grade for Bulk grade operations.';
$string['configcoursegradedisplaytype'] = 'Select the default display type of grades for this course. You can also select the site default value. Grades can be shown as real grades, as percentages (in reference to the minimum and maximum grades) or as letters (A, B, C etc..). Selecting Letters will allow you to define your own grade letters and boundaries.';
$string['configdecimalpoints'] = 'The number of decimal points to display for each grade. This can be overriden per grading item.';
$string['configquickfeedback'] = 'Quick Feedback adds a text input element in each grade cell on the grader report, allowing you to edit 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['configquickgrading'] = 'Quick Grading 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['configrangesdecimalpoints'] = 'The number of decimal points to display for each range, above a column of grades. This can be overriden per grading item.';
-$string['configrangesdisplaytype'] = 'Specifies how to display the range for each column in the grader report. The default and recommended value is Inherit, which first checks the display type of each column, and if such is not set explicitly, defaults to the more general Grade Display Type. If other display types are selected, they ignore the individual settings for each column, and use exclusively the selected type.';
+$string['configrangesdisplaytype'] = 'Specifies how to display the range for each column in the grader report. Default means to use the display type of each column.';
$string['configshowcalculations'] = 'Whether to show calculator icons near each grade item and category, tooltips over calculated items and a visual indicator that a column is calculated.';
$string['configshoweyecons'] = 'Whether to show a show/hide icon near each grade (controlling its visibility to the user).';
$string['configshowactivityicons'] = 'Show an activity icon next to each grade item linked to an activity, in the grader report.';
$gradedisplaytype = get_field('grade_items', 'display', 'courseid', $this->courseid, 'itemtype', 'course');
if ($gradedisplaytype == GRADE_DISPLAY_TYPE_DEFAULT) {
- $gradedisplaytype = $CFG->grade_report_gradedisplaytype;
+ $gradedisplaytype = $CFG->grade_displaytype;
}
$cache[$this->courseid] = $gradedisplaytype;
return $gradedisplaytype;
}
$gradedecimals = get_field('grade_items', 'decimals', 'courseid', $this->courseid, 'itemtype', 'course');
if (is_null($gradedecimals)) {
- $gradedecimals = $CFG->grade_report_decimalpoints;
+ $gradedecimals = $CFG->grade_decimalpoints;
}
$cache[$this->courseid] = $gradedecimals;
return $gradedecimals;
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2007100700; // YYYYMMDD = date
+ $version = 2007100701; // YYYYMMDD = date
// XY = increments within a single day
$release = '1.9 Beta +'; // Human-friendly version name