MDL-10210 Re-organised the gradebook preferences, and now displaying site defaults inside the dropdown menus instead of the labels.

This commit is contained in:
nicolasconnault
2007-07-30 07:12:33 +00:00
parent 9ade462ce1
commit 28c955150e
2 changed files with 92 additions and 75 deletions
+87 -75
View File
@@ -21,98 +21,110 @@ class grader_report_preferences_form extends moodleform {
$strconfiggradeboundary = get_string('configgradeboundary', 'grades');
$strgradeletter = get_string('gradeletter', 'grades');
$strconfiggradeletter = get_string('configgradeletter', 'grades');
$strdefault = get_string('default', 'grades');
$strinherit = get_string('inherit', 'grades');
$stryes = get_string('yes');
$strno = get_string('no');
$percentages = array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
$percentages = array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_UNUSED => get_string('unused', 'grades'));
for ($i=100; $i > -1; $i--) {
$percentages[$i] = "$i%";
}
$checkbox_default = array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault, 0 => $strno, 1 => $stryes);
$checkbox_default = array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default', 0 => $strno, 1 => $stryes);
/// form definition with preferences defaults
//--------------------------------------------------------------------------------
$preferences = array('bulkcheckboxes' => $checkbox_default,
'enableajax' => $checkbox_default,
'showcalculations' => $checkbox_default,
'showeyecons' => $checkbox_default,
'showaverages' => $checkbox_default,
'showgroups' => $checkbox_default,
'showlocks' => $checkbox_default,
'showranges' => $checkbox_default,
'quickgrading' => $checkbox_default,
'quickfeedback' => $checkbox_default,
'showuserimage' => $checkbox_default,
'meanselection' => array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
GRADE_AGGREGATE_MEAN_ALL => get_string('meanall', 'grades'),
GRADE_AGGREGATE_MEAN_GRADED => get_string('meangraded', 'grades')),
'aggregationposition' => array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
GRADE_REPORT_AGGREGATION_POSITION_LEFT => get_string('left', 'grades'),
GRADE_REPORT_AGGREGATION_POSITION_RIGHT => get_string('right', 'grades')),
'aggregationview' => array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('full', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_COMPACT => get_string('compact', 'grades')),
'gradedisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'averagesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'rangesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'averagesdecimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
0, 1, 2, 3, 4, 5),
'rangesdecimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
0, 1, 2, 3, 4, 5),
'decimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => $strdefault,
0, 1, 2, 3, 4, 5),
'studentsperpage' => 'text');
$preferences = array();
$preferences['prefgeneral'] = array(
'studentsperpage' => 'text',
'quickgrading' => $checkbox_default,
'quickfeedback' => $checkbox_default,
'decimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default', 0, 1, 2, 3, 4, 5),
'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')),
'aggregationview' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('full', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_COMPACT => get_string('compact', 'grades')),
'gradedisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'meanselection' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_AGGREGATE_MEAN_ALL => get_string('meanall', 'grades'),
GRADE_AGGREGATE_MEAN_GRADED => get_string('meangraded', 'grades')),
'enableajax' => $checkbox_default);
$preferences['prefshow'] = array('showcalculations' => $checkbox_default,
'showeyecons' => $checkbox_default,
'showaverages' => $checkbox_default,
'showgroups' => $checkbox_default,
'showlocks' => $checkbox_default,
'showranges' => $checkbox_default,
'showuserimage' => $checkbox_default,);
$preferences['prefrows'] = array(
'averagesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'rangesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_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));
for ($i = 1; $i <= 10; $i++) {
$preferences['gradeboundary' . $i] = $percentages;
$preferences['gradeletter' . $i] = 'text';
$preferences['prefletters']['gradeboundary' . $i] = $percentages;
$preferences['prefletters']['gradeletter' . $i] = 'text';
}
foreach ($preferences as $pref => $type) {
if (preg_match('/([^[0-9]+)([0-9]+)/', $pref, $matches)) {
$lang_string = $matches[1];
$number = ' ' . $matches[2];
} else {
$lang_string = $pref;
$number = null;
foreach ($preferences as $group => $prefs) {
$mform->addElement('header', $group, get_string($group, 'grades'));
foreach ($prefs as $pref => $type) {
// Detect and process dynamically numbered preferences
if (preg_match('/([^[0-9]+)([0-9]+)/', $pref, $matches)) {
$lang_string = $matches[1];
$number = ' ' . $matches[2];
} else {
$lang_string = $pref;
$number = null;
}
$full_pref = 'grade_report_' . $pref;
$pref_value = get_user_preferences($full_pref);
$options = null;
if (is_array($type)) {
$options = $type;
$type = 'select';
$default = $options[$CFG->$full_pref];
} else {
$default = $CFG->$full_pref;
}
// Replace the 'default' value with the site default language string
if (!is_null($options) AND $options[GRADE_REPORT_PREFERENCE_DEFAULT] == 'default') {
$options[GRADE_REPORT_PREFERENCE_DEFAULT] = get_string('sitedefault', 'grades', $default);
}
$label = get_string($lang_string, 'grades') . $number;
$mform->addElement($type, $full_pref, $label, $options);
$mform->setHelpButton($full_pref, array(false, get_string($lang_string, 'grades'), false, true, false,
get_string("config$lang_string", 'grades')));
$mform->setDefault($full_pref, $pref_value);
$mform->setType($full_pref, PARAM_ALPHANUM);
}
$full_pref = 'grade_report_' . $pref;
$pref_value = get_user_preferences($full_pref);
$options = null;
if (is_array($type)) {
$options = $type;
$type = 'select';
$default = $options[$CFG->$full_pref];
} else {
$default = $CFG->$full_pref;
}
$default_label = get_string($lang_string, 'grades') . $number . ' (' . $strdefault . ': ' . $default . ')';
$mform->addElement($type, $full_pref, $default_label, $options);
$mform->setHelpButton($full_pref, array(false, get_string($lang_string, 'grades'), false, true, false,
get_string("config$lang_string", 'grades')));
$mform->setDefault($full_pref, $pref_value);
$mform->setType($full_pref, PARAM_ALPHANUM);
}
$mform->addElement('hidden', 'id');
+5
View File
@@ -235,6 +235,10 @@ $string['points'] = 'points';
$string['pointsascending'] = 'Sort by points ascending';
$string['pointsdescending'] = 'Sort by points descdending';
$string['preferences'] = 'Preferences';
$string['prefgeneral'] = 'General';
$string['prefletters'] = 'Grade letters and boundaries';
$string['prefrows'] = 'Special rows';
$string['prefshow'] = 'Show/hide toggles';
$string['quickfeedback'] = 'Quick Feedback';
$string['quickgrading'] = 'Quick Grading';
$string['range'] = 'Range';
@@ -270,6 +274,7 @@ $string['showhiddenitems'] = 'Show Hidden Items';
$string['showlocks'] = 'Show locks';
$string['showranges'] = 'Show ranges';
$string['showuserimage'] = 'Show user profile images';
$string['sitedefault'] = 'Site default ($a)';
$string['sitewide'] = 'Site-wide';
$string['sort'] = 'sort';
$string['sortasc'] = 'Sort in ascending order';