MDL-47253 core_grades: set def aggregation method to Natural
[moodle.git] / admin / settings / grades.php
1 <?php
3 // This file defines settingpages and externalpages under the "grades" section
5 if (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
8     require_once $CFG->libdir.'/grade/constants.php';
9     $display_types = array(GRADE_DISPLAY_TYPE_REAL => new lang_string('real', 'grades'),
10                            GRADE_DISPLAY_TYPE_PERCENTAGE => new lang_string('percentage', 'grades'),
11                            GRADE_DISPLAY_TYPE_LETTER => new lang_string('letter', 'grades'),
12                            GRADE_DISPLAY_TYPE_REAL_PERCENTAGE => new lang_string('realpercentage', 'grades'),
13                            GRADE_DISPLAY_TYPE_REAL_LETTER => new lang_string('realletter', 'grades'),
14                            GRADE_DISPLAY_TYPE_LETTER_REAL => new lang_string('letterreal', 'grades'),
15                            GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE => new lang_string('letterpercentage', 'grades'),
16                            GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER => new lang_string('percentageletter', 'grades'),
17                            GRADE_DISPLAY_TYPE_PERCENTAGE_REAL => new lang_string('percentagereal', 'grades')
18                            );
19     asort($display_types);
21     // General settings
23     $temp = new admin_settingpage('gradessettings', new lang_string('generalsettings', 'grades'), 'moodle/grade:manage');
24     if ($ADMIN->fulltree) {
26         // new CFG variable for gradebook (what roles to display)
27         $temp->add(new admin_setting_special_gradebookroles());
29         // enable outcomes checkbox now in subsystems area
31         $temp->add(new admin_setting_grade_profilereport());
33         $temp->add(new admin_setting_configselect('grade_aggregationposition', new lang_string('aggregationposition', 'grades'),
34                                                   new lang_string('aggregationposition_help', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST,
35                                                   array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => new lang_string('positionfirst', 'grades'),
36                                                         GRADE_REPORT_AGGREGATION_POSITION_LAST => new lang_string('positionlast', 'grades'))));
38         $temp->add(new admin_setting_regradingcheckbox('grade_includescalesinaggregation', new lang_string('includescalesinaggregation', 'grades'), new lang_string('includescalesinaggregation_help', 'grades'), 1));
40         $temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', new lang_string('hiddenasdate', 'grades'), new lang_string('hiddenasdate_help', 'grades'), 0));
42         // enable publishing in exports/imports
43         $temp->add(new admin_setting_configcheckbox('gradepublishing', new lang_string('gradepublishing', 'grades'), new lang_string('gradepublishing_help', 'grades'), 0));
45         $temp->add(new admin_setting_configselect('grade_export_displaytype', new lang_string('gradeexportdisplaytype', 'grades'),
46                                                   new lang_string('gradeexportdisplaytype_desc', 'grades'), GRADE_DISPLAY_TYPE_REAL, $display_types));
48         $temp->add(new admin_setting_configselect('grade_export_decimalpoints', new lang_string('gradeexportdecimalpoints', 'grades'),
49                                                   new lang_string('gradeexportdecimalpoints_desc', 'grades'), 2,
50                                                   array( '0' => '0',
51                                                          '1' => '1',
52                                                          '2' => '2',
53                                                          '3' => '3',
54                                                          '4' => '4',
55                                                          '5' => '5')));
56         $temp->add(new admin_setting_configselect('grade_navmethod', new lang_string('navmethod', 'grades'), null, 0,
57                                                   array(GRADE_NAVMETHOD_DROPDOWN => new lang_string('dropdown', 'grades'),
58                                                         GRADE_NAVMETHOD_TABS => new lang_string('tabs', 'grades'),
59                                                         GRADE_NAVMETHOD_COMBO => new lang_string('combo', 'grades'))));
61         $temp->add(new admin_setting_configtext('grade_export_userprofilefields', new lang_string('gradeexportuserprofilefields', 'grades'), new lang_string('gradeexportuserprofilefields_desc', 'grades'), 'firstname,lastname,idnumber,institution,department,email', PARAM_TEXT));
63         $temp->add(new admin_setting_configtext('grade_export_customprofilefields', new lang_string('gradeexportcustomprofilefields', 'grades'), new lang_string('gradeexportcustomprofilefields_desc', 'grades'), '', PARAM_TEXT));
65         $temp->add(new admin_setting_configcheckbox('recovergradesdefault', new lang_string('recovergradesdefault', 'grades'), new lang_string('recovergradesdefault_help', 'grades'), 0));
67         $temp->add(new admin_setting_special_gradeexport());
69         $temp->add(new admin_setting_special_gradelimiting());
71         $temp->add(new admin_setting_configcheckbox('grade_report_showmin',
72                                                     get_string('minimum_show', 'grades'),
73                                                     get_string('minimum_show_help', 'grades'), '1'));
75         $temp->add(new admin_setting_special_gradepointmax());
77         $temp->add(new admin_setting_special_gradepointdefault());
78     }
79     $ADMIN->add('grades', $temp);
81     /// Grade category settings
82     $temp = new admin_settingpage('gradecategorysettings', new lang_string('gradecategorysettings', 'grades'), 'moodle/grade:manage');
83     if ($ADMIN->fulltree) {
84         $temp->add(new admin_setting_configcheckbox('grade_hideforcedsettings', new lang_string('hideforcedsettings', 'grades'), new lang_string('hideforcedsettings_help', 'grades'), '1'));
86         $strnoforce = new lang_string('noforce', 'grades');
88         // Aggregation type
89         $options = array(GRADE_AGGREGATE_MEAN            =>new lang_string('aggregatemean', 'grades'),
90                          GRADE_AGGREGATE_WEIGHTED_MEAN   =>new lang_string('aggregateweightedmean', 'grades'),
91                          GRADE_AGGREGATE_WEIGHTED_MEAN2  =>new lang_string('aggregateweightedmean2', 'grades'),
92                          GRADE_AGGREGATE_EXTRACREDIT_MEAN=>new lang_string('aggregateextracreditmean', 'grades'),
93                          GRADE_AGGREGATE_MEDIAN          =>new lang_string('aggregatemedian', 'grades'),
94                          GRADE_AGGREGATE_MIN             =>new lang_string('aggregatemin', 'grades'),
95                          GRADE_AGGREGATE_MAX             =>new lang_string('aggregatemax', 'grades'),
96                          GRADE_AGGREGATE_MODE            =>new lang_string('aggregatemode', 'grades'),
97                          GRADE_AGGREGATE_SUM             =>new lang_string('aggregatesum', 'grades'));
99         $defaultvisible = array(GRADE_AGGREGATE_SUM);
101         $defaults = array('value' => GRADE_AGGREGATE_SUM, 'forced' => false, 'adv' => false);
102         $temp->add(new admin_setting_gradecat_combo('grade_aggregation', new lang_string('aggregation', 'grades'), new lang_string('aggregation_help', 'grades'), $defaults, $options));
104         $temp->add(new admin_setting_configmultiselect('grade_aggregations_visible', new lang_string('aggregationsvisible', 'grades'),
105                                                        new lang_string('aggregationsvisiblehelp', 'grades'), $defaultvisible, $options));
107         $options = array(0 => new lang_string('no'), 1 => new lang_string('yes'));
109         $defaults = array('value'=>1, 'forced'=>false, 'adv'=>true);
110         $temp->add(new admin_setting_gradecat_combo('grade_aggregateonlygraded', new lang_string('aggregateonlygraded', 'grades'),
111                     new lang_string('aggregateonlygraded_help', 'grades'), $defaults, $options));
112         $defaults = array('value'=>0, 'forced'=>false, 'adv'=>true);
113         $temp->add(new admin_setting_gradecat_combo('grade_aggregateoutcomes', new lang_string('aggregateoutcomes', 'grades'),
114                     new lang_string('aggregateoutcomes_help', 'grades'), $defaults, $options));
115         $temp->add(new admin_setting_gradecat_combo('grade_aggregatesubcats', new lang_string('aggregatesubcats', 'grades'),
116                     new lang_string('aggregatesubcats_help', 'grades'), $defaults, $options));
118         $options = array(0 => new lang_string('none'));
119         for ($i=1; $i<=20; $i++) {
120             $options[$i] = $i;
121         }
123         $defaults['value'] = 0;
124         $defaults['forced'] = true;
125         $temp->add(new admin_setting_gradecat_combo('grade_keephigh', new lang_string('keephigh', 'grades'),
126                     new lang_string('keephigh_help', 'grades'), $defaults, $options));
127         $defaults['forced'] = false;
128         $temp->add(new admin_setting_gradecat_combo('grade_droplow', new lang_string('droplow', 'grades'),
129                     new lang_string('droplow_help', 'grades'), $defaults, $options));
131         $temp->add(new admin_setting_configcheckbox('grade_overridecat', new lang_string('overridecat', 'grades'),
132                    new lang_string('overridecat_help', 'grades'), 1));
133     }
134     $ADMIN->add('grades', $temp);
137     /// Grade item settings
138     $temp = new admin_settingpage('gradeitemsettings', new lang_string('gradeitemsettings', 'grades'), 'moodle/grade:manage');
139     if ($ADMIN->fulltree) {
140         $temp->add(new admin_setting_configselect('grade_displaytype', new lang_string('gradedisplaytype', 'grades'),
141                                                   new lang_string('gradedisplaytype_help', 'grades'), GRADE_DISPLAY_TYPE_REAL, $display_types));
143         $temp->add(new admin_setting_configselect('grade_decimalpoints', new lang_string('decimalpoints', 'grades'),
144                                                   new lang_string('decimalpoints_help', 'grades'), 2,
145                                                   array( '0' => '0',
146                                                          '1' => '1',
147                                                          '2' => '2',
148                                                          '3' => '3',
149                                                          '4' => '4',
150                                                          '5' => '5')));
152         $temp->add(new admin_setting_configmultiselect('grade_item_advanced', new lang_string('gradeitemadvanced', 'grades'), new lang_string('gradeitemadvanced_help', 'grades'),
153                                                        array('iteminfo', 'idnumber', 'gradepass', 'plusfactor', 'multfactor', 'display', 'decimals', 'hiddenuntil', 'locktime'),
154                                                        array('iteminfo' => new lang_string('iteminfo', 'grades'),
155                                                              'idnumber' => new lang_string('idnumbermod'),
156                                                              'gradetype' => new lang_string('gradetype', 'grades'),
157                                                              'scaleid' => new lang_string('scale'),
158                                                              'grademin' => new lang_string('grademin', 'grades'),
159                                                              'grademax' => new lang_string('grademax', 'grades'),
160                                                              'gradepass' => new lang_string('gradepass', 'grades'),
161                                                              'plusfactor' => new lang_string('plusfactor', 'grades'),
162                                                              'multfactor' => new lang_string('multfactor', 'grades'),
163                                                              'display' => new lang_string('gradedisplaytype', 'grades'),
164                                                              'decimals' => new lang_string('decimalpoints', 'grades'),
165                                                              'hidden' => new lang_string('hidden', 'grades'),
166                                                              'hiddenuntil' => new lang_string('hiddenuntil', 'grades'),
167                                                              'locked' => new lang_string('locked', 'grades'),
168                                                              'locktime' => new lang_string('locktime', 'grades'),
169                                                              'aggregationcoef' => new lang_string('aggregationcoef', 'grades'),
170                                                              'parentcategory' => new lang_string('parentcategory', 'grades'))));
171     }
172     $ADMIN->add('grades', $temp);
175     /// Scales and outcomes
177     $scales = new admin_externalpage('scales', new lang_string('scales'), $CFG->wwwroot.'/grade/edit/scale/index.php', 'moodle/grade:manage');
178     $ADMIN->add('grades', $scales);
179     if (!empty($CFG->enableoutcomes)) {
180         $outcomes = new admin_externalpage('outcomes', new lang_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage');
181         $ADMIN->add('grades', $outcomes);
182     }
183     $letters = new admin_externalpage('letters', new lang_string('letters', 'grades'), $CFG->wwwroot.'/grade/edit/letter/index.php', 'moodle/grade:manageletters');
184     $ADMIN->add('grades', $letters);
186     // The plugins must implement a settings.php file that adds their admin settings to the $settings object
188     // Reports
189     $ADMIN->add('grades', new admin_category('gradereports', new lang_string('reportsettings', 'grades')));
190     foreach (core_component::get_plugin_list('gradereport') as $plugin => $plugindir) {
191      // Include all the settings commands for this plugin if there are any
192         if (file_exists($plugindir.'/settings.php')) {
193             $settings = new admin_settingpage('gradereport'.$plugin, new lang_string('pluginname', 'gradereport_'.$plugin), 'moodle/grade:manage');
194             include($plugindir.'/settings.php');
195             if ($settings) {
196                 $ADMIN->add('gradereports', $settings);
197             }
198         }
199     }
201     // Imports
202     $ADMIN->add('grades', new admin_category('gradeimports', new lang_string('importsettings', 'grades')));
203     foreach (core_component::get_plugin_list('gradeimport') as $plugin => $plugindir) {
205      // Include all the settings commands for this plugin if there are any
206         if (file_exists($plugindir.'/settings.php')) {
207             $settings = new admin_settingpage('gradeimport'.$plugin, new lang_string('pluginname', 'gradeimport_'.$plugin), 'moodle/grade:manage');
208             include($plugindir.'/settings.php');
209             if ($settings) {
210                 $ADMIN->add('gradeimports', $settings);
211             }
212         }
213     }
216     // Exports
217     $ADMIN->add('grades', new admin_category('gradeexports', new lang_string('exportsettings', 'grades')));
218     foreach (core_component::get_plugin_list('gradeexport') as $plugin => $plugindir) {
219      // Include all the settings commands for this plugin if there are any
220         if (file_exists($plugindir.'/settings.php')) {
221             $settings = new admin_settingpage('gradeexport'.$plugin, new lang_string('pluginname', 'gradeexport_'.$plugin), 'moodle/grade:manage');
222             include($plugindir.'/settings.php');
223             if ($settings) {
224                 $ADMIN->add('gradeexports', $settings);
225             }
226         }
227     }
229 } // end of speedup