MDL-26140 hide unfinished experimental DTL pages
[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 => get_string('real', 'grades'),
10                            GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
11                            GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'),
12                            GRADE_DISPLAY_TYPE_REAL_PERCENTAGE => get_string('realpercentage', 'grades'),
13                            GRADE_DISPLAY_TYPE_REAL_LETTER => get_string('realletter', 'grades'),
14                            GRADE_DISPLAY_TYPE_LETTER_REAL => get_string('letterreal', 'grades'),
15                            GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE => get_string('letterpercentage', 'grades'),
16                            GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER => get_string('percentageletter', 'grades'),
17                            GRADE_DISPLAY_TYPE_PERCENTAGE_REAL => get_string('percentagereal', 'grades')
18                            );
19     asort($display_types);
21     // General settings
23     $temp = new admin_settingpage('gradessettings', get_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', get_string('aggregationposition', 'grades'),
34                                                   get_string('aggregationposition_help', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST,
35                                                   array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'),
36                                                         GRADE_REPORT_AGGREGATION_POSITION_LAST => get_string('positionlast', 'grades'))));
38         $temp->add(new admin_setting_regradingcheckbox('grade_includescalesinaggregation', get_string('includescalesinaggregation', 'grades'), get_string('includescalesinaggregation_help', 'grades'), 1));
40         $temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', get_string('hiddenasdate', 'grades'), get_string('hiddenasdate_help', 'grades'), 0));
42         // enable publishing in exports/imports
43         $temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('gradepublishing_help', 'grades'), 0));
45         $temp->add(new admin_setting_configselect('grade_export_displaytype', get_string('gradeexportdisplaytype', 'grades'),
46                                                   get_string('gradeexportdisplaytype_desc', 'grades'), GRADE_DISPLAY_TYPE_REAL, $display_types));
48         $temp->add(new admin_setting_configselect('grade_export_decimalpoints', get_string('gradeexportdecimalpoints', 'grades'),
49                                                   get_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', get_string('navmethod', 'grades'), null, 0,
57                                                   array(GRADE_NAVMETHOD_DROPDOWN => get_string('dropdown', 'grades'),
58                                                         GRADE_NAVMETHOD_TABS => get_string('tabs', 'grades'),
59                                                         GRADE_NAVMETHOD_COMBO => get_string('combo', 'grades'))));
61         $temp->add(new admin_setting_special_gradeexport());
63         $temp->add(new admin_setting_special_gradelimiting());
64     }
65     $ADMIN->add('grades', $temp);
67     /// Grade category settings
68     $temp = new admin_settingpage('gradecategorysettings', get_string('gradecategorysettings', 'grades'), 'moodle/grade:manage');
69     if ($ADMIN->fulltree) {
70         $temp->add(new admin_setting_configcheckbox('grade_hideforcedsettings', get_string('hideforcedsettings', 'grades'), get_string('hideforcedsettings_help', 'grades'), '1'));
72         $strnoforce = get_string('noforce', 'grades');
74         // Aggregation type
75         $options = array(GRADE_AGGREGATE_MEAN            =>get_string('aggregatemean', 'grades'),
76                          GRADE_AGGREGATE_WEIGHTED_MEAN   =>get_string('aggregateweightedmean', 'grades'),
77                          GRADE_AGGREGATE_WEIGHTED_MEAN2  =>get_string('aggregateweightedmean2', 'grades'),
78                          GRADE_AGGREGATE_EXTRACREDIT_MEAN=>get_string('aggregateextracreditmean', 'grades'),
79                          GRADE_AGGREGATE_MEDIAN          =>get_string('aggregatemedian', 'grades'),
80                          GRADE_AGGREGATE_MIN             =>get_string('aggregatemin', 'grades'),
81                          GRADE_AGGREGATE_MAX             =>get_string('aggregatemax', 'grades'),
82                          GRADE_AGGREGATE_MODE            =>get_string('aggregatemode', 'grades'),
83                          GRADE_AGGREGATE_SUM             =>get_string('aggregatesum', 'grades'));
85         $defaultvisible = array(GRADE_AGGREGATE_MEAN, GRADE_AGGREGATE_WEIGHTED_MEAN, GRADE_AGGREGATE_WEIGHTED_MEAN2,
86                                 GRADE_AGGREGATE_EXTRACREDIT_MEAN, GRADE_AGGREGATE_MEDIAN, GRADE_AGGREGATE_MIN,
87                                 GRADE_AGGREGATE_MAX, GRADE_AGGREGATE_MODE, GRADE_AGGREGATE_SUM);
89         $defaults = array('value'=>GRADE_AGGREGATE_WEIGHTED_MEAN2, 'forced'=>false, 'adv'=>false);
90         $temp->add(new admin_setting_gradecat_combo('grade_aggregation', get_string('aggregation', 'grades'), get_string('aggregation_help', 'grades'), $defaults, $options));
92         $temp->add(new admin_setting_configmultiselect('grade_aggregations_visible', get_string('aggregationsvisible', 'grades'),
93                                                        get_string('aggregationsvisiblehelp', 'grades'), $defaultvisible, $options));
95         $options = array(0 => get_string('no'), 1 => get_string('yes'));
97         $defaults = array('value'=>1, 'forced'=>false, 'adv'=>true);
98         $temp->add(new admin_setting_gradecat_combo('grade_aggregateonlygraded', get_string('aggregateonlygraded', 'grades'),
99                     get_string('aggregateonlygraded_help', 'grades'), $defaults, $options));
100         $defaults = array('value'=>0, 'forced'=>false, 'adv'=>true);
101         $temp->add(new admin_setting_gradecat_combo('grade_aggregateoutcomes', get_string('aggregateoutcomes', 'grades'),
102                     get_string('aggregateoutcomes_help', 'grades'), $defaults, $options));
103         $temp->add(new admin_setting_gradecat_combo('grade_aggregatesubcats', get_string('aggregatesubcats', 'grades'),
104                     get_string('aggregatesubcats_help', 'grades'), $defaults, $options));
106         $options = array(0 => get_string('none'));
107         for ($i=1; $i<=20; $i++) {
108             $options[$i] = $i;
109         }
111         $defaults['value'] = 0;
112         $defaults['forced'] = true;
113         $temp->add(new admin_setting_gradecat_combo('grade_keephigh', get_string('keephigh', 'grades'),
114                     get_string('keephigh_help', 'grades'), $defaults, $options));
115         $defaults['forced'] = false;
116         $temp->add(new admin_setting_gradecat_combo('grade_droplow', get_string('droplow', 'grades'),
117                     get_string('droplow_help', 'grades'), $defaults, $options));
118     }
119     $ADMIN->add('grades', $temp);
122     /// Grade item settings
123     $temp = new admin_settingpage('gradeitemsettings', get_string('gradeitemsettings', 'grades'), 'moodle/grade:manage');
124     if ($ADMIN->fulltree) {
125         $temp->add(new admin_setting_configselect('grade_displaytype', get_string('gradedisplaytype', 'grades'),
126                                                   get_string('gradedisplaytype_help', 'grades'), GRADE_DISPLAY_TYPE_REAL, $display_types));
128         $temp->add(new admin_setting_configselect('grade_decimalpoints', get_string('decimalpoints', 'grades'),
129                                                   get_string('decimalpoints_help', 'grades'), 2,
130                                                   array( '0' => '0',
131                                                          '1' => '1',
132                                                          '2' => '2',
133                                                          '3' => '3',
134                                                          '4' => '4',
135                                                          '5' => '5')));
137         $temp->add(new admin_setting_configmultiselect('grade_item_advanced', get_string('gradeitemadvanced', 'grades'), get_string('gradeitemadvanced_help', 'grades'),
138                                                        array('iteminfo', 'idnumber', 'gradepass', 'plusfactor', 'multfactor', 'display', 'decimals', 'hiddenuntil', 'locktime'),
139                                                        array('iteminfo' => get_string('iteminfo', 'grades'),
140                                                              'idnumber' => get_string('idnumbermod'),
141                                                              'gradetype' => get_string('gradetype', 'grades'),
142                                                              'scaleid' => get_string('scale'),
143                                                              'grademin' => get_string('grademin', 'grades'),
144                                                              'grademax' => get_string('grademax', 'grades'),
145                                                              'gradepass' => get_string('gradepass', 'grades'),
146                                                              'plusfactor' => get_string('plusfactor', 'grades'),
147                                                              'multfactor' => get_string('multfactor', 'grades'),
148                                                              'display' => get_string('gradedisplaytype', 'grades'),
149                                                              'decimals' => get_string('decimalpoints', 'grades'),
150                                                              'hidden' => get_string('hidden', 'grades'),
151                                                              'hiddenuntil' => get_string('hiddenuntil', 'grades'),
152                                                              'locked' => get_string('locked', 'grades'),
153                                                              'locktime' => get_string('locktime', 'grades'),
154                                                              'aggregationcoef' => get_string('aggregationcoef', 'grades'),
155                                                              'parentcategory' => get_string('parentcategory', 'grades'))));
156     }
157     $ADMIN->add('grades', $temp);
160     /// Scales and outcomes
162     $scales = new admin_externalpage('scales', get_string('scales'), $CFG->wwwroot.'/grade/edit/scale/index.php', 'moodle/grade:manage');
163     $ADMIN->add('grades', $scales);
164     if (!empty($CFG->enableoutcomes)) {
165         $outcomes = new admin_externalpage('outcomes', get_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage');
166         $ADMIN->add('grades', $outcomes);
167     }
168     $letters = new admin_externalpage('letters', get_string('letters', 'grades'), $CFG->wwwroot.'/grade/edit/letter/index.php', 'moodle/grade:manageletters');
169     $ADMIN->add('grades', $letters);
171     // The plugins must implement a settings.php file that adds their admin settings to the $settings object
173     // Reports
174     $ADMIN->add('grades', new admin_category('gradereports', get_string('reportsettings', 'grades')));
175     foreach (get_plugin_list('gradereport') as $plugin => $plugindir) {
176      // Include all the settings commands for this plugin if there are any
177         if (file_exists($plugindir.'/settings.php')) {
178             $settings = new admin_settingpage('gradereport'.$plugin, get_string('pluginname', 'gradereport_'.$plugin), 'moodle/grade:manage');
179             include($plugindir.'/settings.php');
180             if ($settings) {
181                 $ADMIN->add('gradereports', $settings);
182             }
183         }
184     }
186     // Imports
187     $ADMIN->add('grades', new admin_category('gradeimports', get_string('importsettings', 'grades')));
188     foreach (get_plugin_list('gradeimport') as $plugin => $plugindir) {
190      // Include all the settings commands for this plugin if there are any
191         if (file_exists($plugindir.'/settings.php')) {
192             $settings = new admin_settingpage('gradeimport'.$plugin, get_string('pluginname', 'gradeimport_'.$plugin), 'moodle/grade:manage');
193             include($plugindir.'/settings.php');
194             if ($settings) {
195                 $ADMIN->add('gradeimports', $settings);
196             }
197         }
198     }
201     // Exports
202     $ADMIN->add('grades', new admin_category('gradeexports', get_string('exportsettings', 'grades')));
203     foreach (get_plugin_list('gradeexport') as $plugin => $plugindir) {
204      // Include all the settings commands for this plugin if there are any
205         if (file_exists($plugindir.'/settings.php')) {
206             $settings = new admin_settingpage('gradeexport'.$plugin, get_string('pluginname', 'gradeexport_'.$plugin), 'moodle/grade:manage');
207             include($plugindir.'/settings.php');
208             if ($settings) {
209                 $ADMIN->add('gradeexports', $settings);
210             }
211         }
212     }
214 } // end of speedup