MDL-12598 use user context instead of personal; merged from MOODLE_19_STABLE
[moodle.git] / admin / settings / grades.php
CommitLineData
28e2c556 1<?php // $Id$
2
3// This file defines settingpages and externalpages under the "grades" section
4
a559f630 5if (has_capability('moodle/grade:manage', $systemcontext)
6 or has_capability('moodle/grade:manageletters', $systemcontext)) { // speedup for non-admins, add all caps used on this page
7
28e2c556 8// General settings
9
d622930b 10require_once $CFG->libdir.'/grade/constants.php';
11
3d5c00b3 12$temp = new admin_settingpage('gradessettings', get_string('generalsettings', 'grades'), 'moodle/grade:manage');
13
14// new CFG variable for gradebook (what roles to display)
15$temp->add(new admin_setting_special_gradebookroles());
864d1f8c 16
4e67c97b 17// enable outcomes checkbox
5df8b070 18$temp->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0, PARAM_INT));
d622930b 19
0a784551 20$temp->add(new admin_setting_grade_profilereport());
21
e0724506 22$temp->add(new admin_setting_configselect('grade_aggregationposition', get_string('aggregationposition', 'grades'),
23 get_string('configaggregationposition', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST,
24 array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'),
25 GRADE_REPORT_AGGREGATION_POSITION_LAST => get_string('positionlast', 'grades'))));
26
d297269d 27$temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', get_string('hiddenasdate', 'grades'), get_string('confighiddenasdate', 'grades'), 0, PARAM_INT));
28
29// enable publishing in exports/imports
30$temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('configgradepublishing', 'grades'), 0, PARAM_INT));
31
864d1f8c 32$temp->add(new admin_setting_configselect('grade_export_displaytype', get_string('gradeexportdisplaytype', 'grades'),
33 get_string('configgradeexportdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
34 array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
35 GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
36 GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'))));
37
38$temp->add(new admin_setting_configselect('grade_export_decimalpoints', get_string('gradeexportdecimalpoints', 'grades'),
39 get_string('configexportdecimalpoints', 'grades'), 2,
40 array( '0' => '0',
41 '1' => '1',
42 '2' => '2',
43 '3' => '3',
44 '4' => '4',
d297269d 45 '5' => '5')));
46
864d1f8c 47$temp->add(new admin_setting_special_gradeexport());
28e2c556 48$ADMIN->add('grades', $temp);
49
53461661 50/// Grade category settings
a559f630 51$temp = new admin_settingpage('gradecategorysettings', get_string('gradecategorysettings', 'grades'), 'moodle/grade:manage');
d622930b 52
f9124bd2 53$temp->add(new admin_setting_configcheckbox('grade_hideforcedsettings', get_string('hideforcedsettings', 'grades'), get_string('confighideforcedsettings', 'grades'), 1, PARAM_INT));
89a5f827 54
53461661 55$strnoforce = get_string('noforce', 'grades');
56
89a5f827 57// Aggregation type
190af29f 58$options = array(GRADE_AGGREGATE_MEAN =>get_string('aggregatemean', 'grades'),
b80377b4 59 GRADE_AGGREGATE_WEIGHTED_MEAN =>get_string('aggregateweightedmean', 'grades'),
60 GRADE_AGGREGATE_WEIGHTED_MEAN2 =>get_string('aggregateweightedmean2', 'grades'),
61 GRADE_AGGREGATE_EXTRACREDIT_MEAN=>get_string('aggregateextracreditmean', 'grades'),
53461661 62 GRADE_AGGREGATE_MEDIAN =>get_string('aggregatemedian', 'grades'),
63 GRADE_AGGREGATE_MIN =>get_string('aggregatemin', 'grades'),
64 GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'),
65 GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'),
190af29f 66 GRADE_AGGREGATE_SUM =>get_string('aggregatesum', 'grades'));
0c87b5aa 67$defaults = array('value'=>GRADE_AGGREGATE_WEIGHTED_MEAN2, 'forced'=>false, 'adv'=>false);
190af29f 68$temp->add(new admin_setting_gradecat_combo('grade_aggregation', get_string('aggregation', 'grades'), get_string('aggregationhelp', 'grades'), $defaults, $options));
69
70$options = array(0 => get_string('no'), 1 => get_string('yes'));
71
0c87b5aa 72$defaults = array('value'=>1, 'forced'=>false, 'adv'=>true);
190af29f 73$temp->add(new admin_setting_gradecat_combo('grade_aggregateonlygraded', get_string('aggregateonlygraded', 'grades'),
74 get_string('aggregateonlygradedhelp', 'grades'), $defaults, $options));
75$temp->add(new admin_setting_gradecat_combo('grade_aggregateoutcomes', get_string('aggregateoutcomes', 'grades'),
76 get_string('aggregateoutcomeshelp', 'grades'), $defaults, $options));
77$temp->add(new admin_setting_gradecat_combo('grade_aggregatesubcats', get_string('aggregatesubcats', 'grades'),
78 get_string('aggregatesubcatshelp', 'grades'), $defaults, $options));
79
80$options = array(0 => get_string('none'));
53461661 81for ($i=1; $i<=20; $i++) {
82 $options[$i] = $i;
83}
84
f9124bd2 85$defaults['value'] = 0;
86$defaults['forced'] = true;
190af29f 87$temp->add(new admin_setting_gradecat_combo('grade_keephigh', get_string('keephigh', 'grades'),
88 get_string('keephighhelp', 'grades'), $defaults, $options));
f9124bd2 89$defaults['forced'] = false;
190af29f 90$temp->add(new admin_setting_gradecat_combo('grade_droplow', get_string('droplow', 'grades'),
91 get_string('droplowhelp', 'grades'), $defaults, $options));
53461661 92
93$ADMIN->add('grades', $temp);
173a9d21 94
3d5c00b3 95
96/// Grade item settings
97$temp = new admin_settingpage('gradeitemsettings', get_string('gradeitemsettings', 'grades'), 'moodle/grade:manage');
98
99
100$temp->add(new admin_setting_configselect('grade_displaytype', get_string('gradedisplaytype', 'grades'),
101 get_string('configgradedisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
102 array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
103 GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
104 GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'))));
105
106$temp->add(new admin_setting_configselect('grade_decimalpoints', get_string('decimalpoints', 'grades'),
107 get_string('configdecimalpoints', 'grades'), 2,
108 array( '0' => '0',
109 '1' => '1',
110 '2' => '2',
111 '3' => '3',
112 '4' => '4',
113 '5' => '5')));
114
115$temp->add(new admin_setting_configmultiselect('grade_item_advanced', get_string('gradeitemadvanced', 'grades'), get_string('configgradeitemadvanced', 'grades'),
116 array('iteminfo', 'idnumber', 'gradepass', 'plusfactor', 'multfactor', 'display', 'decimals', 'hiddenuntil', 'locktime'),
117 array('iteminfo' => get_string('iteminfo', 'grades'),
118 'idnumber' => get_string('idnumber'),
119 'gradetype' => get_string('gradetype', 'grades'),
120 'scaleid' => get_string('scale'),
121 'grademin' => get_string('grademin', 'grades'),
122 'grademax' => get_string('grademax', 'grades'),
123 'gradepass' => get_string('gradepass', 'grades'),
124 'plusfactor' => get_string('plusfactor', 'grades'),
125 'multfactor' => get_string('multfactor', 'grades'),
126 'display' => get_string('gradedisplaytype', 'grades'),
127 'decimals' => get_string('decimalpoints', 'grades'),
128 'hidden' => get_string('hidden', 'grades'),
129 'hiddenuntil' => get_string('hiddenuntil', 'grades'),
130 'locked' => get_string('locked', 'grades'),
131 'locktime' => get_string('locktime', 'grades'),
132 'aggregationcoef' => get_string('aggregationcoef', 'grades'),
133 'parentcategory' => get_string('parentcategory', 'grades'))));
134
135$ADMIN->add('grades', $temp);
136
137
d297269d 138/// Scales and outcomes
139
140$scales = new admin_externalpage('scales', get_string('scales'), $CFG->wwwroot.'/grade/edit/scale/index.php', 'moodle/grade:manage');
141$ADMIN->add('grades', $scales);
142$outcomes = new admin_externalpage('outcomes', get_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage');
143$ADMIN->add('grades', $outcomes);
144$letters = new admin_externalpage('letters', get_string('letters', 'grades'), $CFG->wwwroot.'/grade/edit/letter/edit.php', 'moodle/grade:manageletters');
145$ADMIN->add('grades', $letters);
146
28e2c556 147// The plugins must implement a settings.php file that adds their admin settings to the $settings object
148
149// Reports
150
151$first = true;
152foreach (get_list_of_plugins('grade/report') as $plugin) {
153 // Include all the settings commands for this plugin if there are any
4e67c97b 154 if ($first) {
173a9d21 155 $ADMIN->add('grades', new admin_category('gradereports', get_string('reportsettings', 'grades')));
4e67c97b 156 $first = false;
5df8b070 157 }
158
173a9d21 159 if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php')) {
28e2c556 160
a559f630 161 $settings = new admin_settingpage('gradereport'.$plugin, get_string('modulename', 'gradereport_'.$plugin), 'moodle/grade:manage');
02973505 162 include($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php');
28e2c556 163 $ADMIN->add('gradereports', $settings);
164 }
165}
166
28e2c556 167// Imports
168
169$first = true;
170foreach (get_list_of_plugins('grade/import') as $plugin) {
4e67c97b 171
28e2c556 172 // Include all the settings commands for this plugin if there are any
173 if (file_exists($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php')) {
174 if ($first) {
175 $ADMIN->add('grades', new admin_category('gradeimports', get_string('imports')));
176 $first = false;
177 }
178
a559f630 179 $settings = new admin_settingpage('gradeimport'.$plugin, get_string('modulename', 'gradeimport_'.$plugin), 'moodle/grade:manage');
02973505 180 include($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php');
28e2c556 181 $ADMIN->add('gradeimports', $settings);
182 }
183}
184
185
186// Exports
187
188$first = true;
189foreach (get_list_of_plugins('grade/export') as $plugin) {
190 // Include all the settings commands for this plugin if there are any
191 if (file_exists($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php')) {
192 if ($first) {
193 $ADMIN->add('grades', new admin_category('gradeexports', get_string('exports')));
194 $first = false;
195 }
196
a559f630 197 $settings = new admin_settingpage('gradeexport'.$plugin, get_string('modulename', 'gradeexport_'.$plugin), 'moodle/grade:manage');
02973505 198 include($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php');
28e2c556 199 $ADMIN->add('gradeexports', $settings);
200 }
201}
a559f630 202
203} // end of speedup
204
28e2c556 205?>