MDL-17405 moved unsetting of old flag to correct place, thanks Jerome
[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
220a90c5 8 // General settings
28e2c556 9
220a90c5 10 $temp = new admin_settingpage('gradessettings', get_string('generalsettings', 'grades'), 'moodle/grade:manage');
11 if ($ADMIN->fulltree) {
12 require_once $CFG->libdir.'/grade/constants.php';
5df8b070 13
220a90c5 14 // new CFG variable for gradebook (what roles to display)
15 $temp->add(new admin_setting_special_gradebookroles());
28e2c556 16
220a90c5 17 $temp->add(new admin_setting_grade_profilereport());
18
19 $temp->add(new admin_setting_configselect('grade_aggregationposition', get_string('aggregationposition', 'grades'),
20 get_string('configaggregationposition', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST,
21 array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'),
22 GRADE_REPORT_AGGREGATION_POSITION_LAST => get_string('positionlast', 'grades'))));
28e2c556 23
91f9a62c 24 $temp->add(new admin_setting_regradingcheckbox('grade_includescalesinaggregation', get_string('includescalesinaggregation', 'grades'), get_string('configincludescalesinaggregation', 'grades'), 1));
25
26 $temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', get_string('hiddenasdate', 'grades'), get_string('confighiddenasdate', 'grades'), 0));
28e2c556 27
220a90c5 28 // enable publishing in exports/imports
91f9a62c 29 $temp->add(new admin_setting_configcheckbox('gradepublishing', get_string('gradepublishing', 'grades'), get_string('configgradepublishing', 'grades'), 0));
4e67c97b 30
220a90c5 31 $temp->add(new admin_setting_configselect('grade_export_displaytype', get_string('gradeexportdisplaytype', 'grades'),
32 get_string('configgradeexportdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
33 array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
34 GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
35 GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'))));
36
37 $temp->add(new admin_setting_configselect('grade_export_decimalpoints', get_string('gradeexportdecimalpoints', 'grades'),
38 get_string('configexportdecimalpoints', 'grades'), 2,
39 array( '0' => '0',
40 '1' => '1',
41 '2' => '2',
42 '3' => '3',
43 '4' => '4',
44 '5' => '5')));
45
46 $temp->add(new admin_setting_special_gradeexport());
47 }
48 $ADMIN->add('grades', $temp);
49
50 /// Grade category settings
51 $temp = new admin_settingpage('gradecategorysettings', get_string('gradecategorysettings', 'grades'), 'moodle/grade:manage');
52 if ($ADMIN->fulltree) {
53 $temp->add(new admin_setting_configcheckbox('grade_hideforcedsettings', get_string('hideforcedsettings', 'grades'), get_string('confighideforcedsettings', 'grades'), '1'));
54
55 $strnoforce = get_string('noforce', 'grades');
56
57 // Aggregation type
58 $options = array(GRADE_AGGREGATE_MEAN =>get_string('aggregatemean', 'grades'),
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'),
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'),
66 GRADE_AGGREGATE_SUM =>get_string('aggregatesum', 'grades'));
67 $defaults = array('value'=>GRADE_AGGREGATE_WEIGHTED_MEAN2, 'forced'=>false, 'adv'=>false);
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
72 $defaults = array('value'=>1, 'forced'=>false, 'adv'=>true);
73 $temp->add(new admin_setting_gradecat_combo('grade_aggregateonlygraded', get_string('aggregateonlygraded', 'grades'),
74 get_string('aggregateonlygradedhelp', 'grades'), $defaults, $options));
ee982b07 75 $defaults = array('value'=>0, 'forced'=>false, 'adv'=>true);
220a90c5 76 $temp->add(new admin_setting_gradecat_combo('grade_aggregateoutcomes', get_string('aggregateoutcomes', 'grades'),
77 get_string('aggregateoutcomeshelp', 'grades'), $defaults, $options));
78 $temp->add(new admin_setting_gradecat_combo('grade_aggregatesubcats', get_string('aggregatesubcats', 'grades'),
79 get_string('aggregatesubcatshelp', 'grades'), $defaults, $options));
80
81 $options = array(0 => get_string('none'));
82 for ($i=1; $i<=20; $i++) {
83 $options[$i] = $i;
28e2c556 84 }
85
220a90c5 86 $defaults['value'] = 0;
87 $defaults['forced'] = true;
88 $temp->add(new admin_setting_gradecat_combo('grade_keephigh', get_string('keephigh', 'grades'),
89 get_string('keephighhelp', 'grades'), $defaults, $options));
90 $defaults['forced'] = false;
91 $temp->add(new admin_setting_gradecat_combo('grade_droplow', get_string('droplow', 'grades'),
92 get_string('droplowhelp', 'grades'), $defaults, $options));
93 }
94 $ADMIN->add('grades', $temp);
95
96
97 /// Grade item settings
98 $temp = new admin_settingpage('gradeitemsettings', get_string('gradeitemsettings', 'grades'), 'moodle/grade:manage');
99 if ($ADMIN->fulltree) {
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'),
d343bd21 118 'idnumber' => get_string('idnumbermod'),
220a90c5 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
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);
90658eef 142 $outcomes = new admin_externalpage('outcomes', get_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage', empty($CFG->enableoutcomes));
220a90c5 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
147 // The plugins must implement a settings.php file that adds their admin settings to the $settings object
148
149 // Reports
150 $ADMIN->add('grades', new admin_category('gradereports', get_string('reportsettings', 'grades')));
151 foreach (get_list_of_plugins('grade/report') as $plugin) {
152 // Include all the settings commands for this plugin if there are any
153 if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php')) {
154 $settings = new admin_settingpage('gradereport'.$plugin, get_string('modulename', 'gradereport_'.$plugin), 'moodle/grade:manage');
155 if ($ADMIN->fulltree) {
156 include($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php');
157 }
158 $ADMIN->add('gradereports', $settings);
159 }
28e2c556 160 }
28e2c556 161
220a90c5 162 // Imports
c8fbaa75 163 $ADMIN->add('grades', new admin_category('gradeimports', get_string('importsettings', 'grades')));
220a90c5 164 foreach (get_list_of_plugins('grade/import') as $plugin) {
165
166 // Include all the settings commands for this plugin if there are any
167 if (file_exists($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php')) {
168 $settings = new admin_settingpage('gradeimport'.$plugin, get_string('modulename', 'gradeimport_'.$plugin), 'moodle/grade:manage');
169 if ($ADMIN->fulltree) {
170 include($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php');
171 }
172 $ADMIN->add('gradeimports', $settings);
173 }
174 }
28e2c556 175
28e2c556 176
220a90c5 177 // Exports
c8fbaa75 178 $ADMIN->add('grades', new admin_category('gradeexports', get_string('exportsettings', 'grades')));
220a90c5 179 foreach (get_list_of_plugins('grade/export') as $plugin) {
180 // Include all the settings commands for this plugin if there are any
181 if (file_exists($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php')) {
182 $settings = new admin_settingpage('gradeexport'.$plugin, get_string('modulename', 'gradeexport_'.$plugin), 'moodle/grade:manage');
183 if ($ADMIN->fulltree) {
184 include($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php');
185 }
186 $ADMIN->add('gradeexports', $settings);
28e2c556 187 }
28e2c556 188 }
a559f630 189
190} // end of speedup
191
28e2c556 192?>