Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
// This file defines settingpages and externalpages under the "grades" section
4
 
1441 ariadna 5
use core\plugininfo\gradepenalty;
6
 
7
$ADMIN->add('grades', new admin_category('gradereports', new lang_string('reportsettings', 'grades')));
8
$ADMIN->add('grades', new admin_category('gradeimports', new lang_string('importsettings', 'grades')));
9
$ADMIN->add('grades', new admin_category('gradeexports', new lang_string('exportsettings', 'grades')));
10
$ADMIN->add('grades', new admin_category('gradepenalty', new lang_string('gradepenalty', 'grades')));
11
 
1 efrain 12
if (has_capability('moodle/grade:manage', $systemcontext)
13
 or has_capability('moodle/grade:manageletters', $systemcontext)) { // speedup for non-admins, add all caps used on this page
14
 
15
    require_once $CFG->libdir.'/grade/constants.php';
16
    $display_types = array(GRADE_DISPLAY_TYPE_REAL => new lang_string('real', 'grades'),
17
                           GRADE_DISPLAY_TYPE_PERCENTAGE => new lang_string('percentage', 'grades'),
18
                           GRADE_DISPLAY_TYPE_LETTER => new lang_string('letter', 'grades'),
19
                           GRADE_DISPLAY_TYPE_REAL_PERCENTAGE => new lang_string('realpercentage', 'grades'),
20
                           GRADE_DISPLAY_TYPE_REAL_LETTER => new lang_string('realletter', 'grades'),
21
                           GRADE_DISPLAY_TYPE_LETTER_REAL => new lang_string('letterreal', 'grades'),
22
                           GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE => new lang_string('letterpercentage', 'grades'),
23
                           GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER => new lang_string('percentageletter', 'grades'),
24
                           GRADE_DISPLAY_TYPE_PERCENTAGE_REAL => new lang_string('percentagereal', 'grades')
25
                           );
26
    asort($display_types);
27
 
28
    // General settings
29
 
30
    $temp = new admin_settingpage('gradessettings', new lang_string('generalsettings', 'grades'), 'moodle/grade:manage');
31
    if ($ADMIN->fulltree) {
32
 
33
        // new CFG variable for gradebook (what roles to display)
34
        $temp->add(new admin_setting_special_gradebookroles());
35
 
36
        // enable outcomes checkbox now in subsystems area
37
 
38
        $temp->add(new admin_setting_grade_profilereport());
39
 
40
        $temp->add(new admin_setting_configselect('grade_aggregationposition', new lang_string('aggregationposition', 'grades'),
41
                                                  new lang_string('aggregationposition_help', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST,
42
                                                  array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => new lang_string('positionfirst', 'grades'),
43
                                                        GRADE_REPORT_AGGREGATION_POSITION_LAST => new lang_string('positionlast', 'grades'))));
44
 
45
        $temp->add(new admin_setting_regradingcheckbox('grade_includescalesinaggregation', new lang_string('includescalesinaggregation', 'grades'), new lang_string('includescalesinaggregation_help', 'grades'), 1));
46
 
47
        $temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', new lang_string('hiddenasdate', 'grades'), new lang_string('hiddenasdate_help', 'grades'), 0));
48
 
49
        // enable publishing in exports/imports
50
        $temp->add(new admin_setting_configcheckbox('gradepublishing', new lang_string('gradepublishing', 'grades'), new lang_string('gradepublishing_help', 'grades'), 0));
51
 
52
        $temp->add(new admin_setting_configcheckbox('grade_export_exportfeedback', new lang_string('exportfeedback', 'grades'),
53
                                                  new lang_string('exportfeedback_desc', 'grades'), 0));
54
 
55
        $temp->add(new admin_setting_configselect('grade_export_displaytype', new lang_string('gradeexportdisplaytype', 'grades'),
56
                                                  new lang_string('gradeexportdisplaytype_desc', 'grades'), GRADE_DISPLAY_TYPE_REAL, $display_types));
57
 
58
        $temp->add(new admin_setting_configselect('grade_export_decimalpoints', new lang_string('gradeexportdecimalpoints', 'grades'),
59
                                                  new lang_string('gradeexportdecimalpoints_desc', 'grades'), 2,
60
                                                  array( '0' => '0',
61
                                                         '1' => '1',
62
                                                         '2' => '2',
63
                                                         '3' => '3',
64
                                                         '4' => '4',
65
                                                         '5' => '5')));
66
 
67
        $setting = new admin_setting_configtext('grade_export_userprofilefields',
68
            new lang_string('gradeexportuserprofilefields', 'grades'),
69
            new lang_string('gradeexportuserprofilefields_desc', 'grades'),
70
            'firstname,lastname,idnumber,institution,department,email', PARAM_TEXT);
71
        $setting->set_force_ltr(true);
72
        $temp->add($setting);
73
 
74
        $setting = new admin_setting_configtext('grade_export_customprofilefields',
75
            new lang_string('gradeexportcustomprofilefields', 'grades'),
76
            new lang_string('gradeexportcustomprofilefields_desc', 'grades'), '', PARAM_TEXT);
77
        $setting->set_force_ltr(true);
78
        $temp->add($setting);
79
 
80
        $temp->add(new admin_setting_configcheckbox('recovergradesdefault', new lang_string('recovergradesdefault', 'grades'), new lang_string('recovergradesdefault_help', 'grades'), 0));
81
 
82
        $temp->add(new admin_setting_special_gradeexport());
83
 
84
        $temp->add(new admin_setting_special_gradeexportdefault());
85
 
86
        $temp->add(new admin_setting_special_gradelimiting());
87
 
88
        $temp->add(new admin_setting_configcheckbox('grade_report_showmin',
89
                                                    get_string('minimum_show', 'grades'),
90
                                                    get_string('minimum_show_help', 'grades'), '1'));
91
 
92
        $temp->add(new admin_setting_special_gradepointmax());
93
 
94
        $temp->add(new admin_setting_special_gradepointdefault());
95
 
96
        $temp->add(new admin_setting_special_grademinmaxtouse());
97
 
98
        $temp->add(new admin_setting_my_grades_report());
99
 
100
        $temp->add(new admin_setting_configtext('gradereport_mygradeurl', new lang_string('externalurl', 'grades'),
1441 ariadna 101
            new lang_string('externalurl_desc', 'grades'), ''));
1 efrain 102
    }
103
    $ADMIN->add('grades', $temp);
104
 
105
    /// Grade category settings
106
    $temp = new admin_settingpage('gradecategorysettings', new lang_string('gradecategorysettings', 'grades'), 'moodle/grade:manage');
107
    if ($ADMIN->fulltree) {
108
        $temp->add(new admin_setting_configcheckbox('grade_hideforcedsettings', new lang_string('hideforcedsettings', 'grades'), new lang_string('hideforcedsettings_help', 'grades'), '1'));
109
 
110
        $strnoforce = new lang_string('noforce', 'grades');
111
 
112
        // Aggregation type
113
        $options = array(GRADE_AGGREGATE_MEAN            =>new lang_string('aggregatemean', 'grades'),
114
                         GRADE_AGGREGATE_WEIGHTED_MEAN   =>new lang_string('aggregateweightedmean', 'grades'),
115
                         GRADE_AGGREGATE_WEIGHTED_MEAN2  =>new lang_string('aggregateweightedmean2', 'grades'),
116
                         GRADE_AGGREGATE_EXTRACREDIT_MEAN=>new lang_string('aggregateextracreditmean', 'grades'),
117
                         GRADE_AGGREGATE_MEDIAN          =>new lang_string('aggregatemedian', 'grades'),
118
                         GRADE_AGGREGATE_MIN             =>new lang_string('aggregatemin', 'grades'),
119
                         GRADE_AGGREGATE_MAX             =>new lang_string('aggregatemax', 'grades'),
120
                         GRADE_AGGREGATE_MODE            =>new lang_string('aggregatemode', 'grades'),
121
                         GRADE_AGGREGATE_SUM             =>new lang_string('aggregatesum', 'grades'));
122
 
123
        $defaultvisible = array(GRADE_AGGREGATE_SUM);
124
 
125
        $defaults = array('value' => GRADE_AGGREGATE_SUM, 'forced' => false);
126
        $temp->add(new admin_setting_gradecat_combo('grade_aggregation', new lang_string('aggregation', 'grades'), new lang_string('aggregation_help', 'grades'), $defaults, $options));
127
 
128
        $temp->add(new admin_setting_configmultiselect('grade_aggregations_visible', new lang_string('aggregationsvisible', 'grades'),
129
                                                       new lang_string('aggregationsvisiblehelp', 'grades'), $defaultvisible, $options));
130
 
131
        $options = array(0 => new lang_string('no'), 1 => new lang_string('yes'));
132
 
133
        $defaults = array('value' => 1, 'forced' => false);
134
        $temp->add(new admin_setting_gradecat_combo('grade_aggregateonlygraded', new lang_string('aggregateonlygraded', 'grades'),
135
                    new lang_string('aggregateonlygraded_help', 'grades'), $defaults, $options));
136
        $defaults = array('value' => 0, 'forced' => false);
137
        $temp->add(new admin_setting_gradecat_combo('grade_aggregateoutcomes', new lang_string('aggregateoutcomes', 'grades'),
138
                    new lang_string('aggregateoutcomes_help', 'grades'), $defaults, $options));
139
 
140
        $options = array(0 => new lang_string('none'));
141
        for ($i=1; $i<=20; $i++) {
142
            $options[$i] = $i;
143
        }
144
 
145
        $defaults['value'] = 0;
146
        $defaults['forced'] = true;
147
        $temp->add(new admin_setting_gradecat_combo('grade_keephigh', new lang_string('keephigh', 'grades'),
148
                    new lang_string('keephigh_help', 'grades'), $defaults, $options));
149
        $defaults['forced'] = false;
150
        $temp->add(new admin_setting_gradecat_combo('grade_droplow', new lang_string('droplow', 'grades'),
151
                    new lang_string('droplow_help', 'grades'), $defaults, $options));
152
 
153
        $temp->add(new admin_setting_configcheckbox('grade_overridecat', new lang_string('overridecat', 'grades'),
154
                   new lang_string('overridecat_help', 'grades'), 1));
155
    }
156
    $ADMIN->add('grades', $temp);
157
 
158
 
159
    /// Grade item settings
160
    $temp = new admin_settingpage('gradeitemsettings', new lang_string('gradeitemsettings', 'grades'), 'moodle/grade:manage');
161
    if ($ADMIN->fulltree) {
162
        $temp->add(new admin_setting_configselect('grade_displaytype', new lang_string('gradedisplaytype', 'grades'),
163
                                                  new lang_string('gradedisplaytype_help', 'grades'), GRADE_DISPLAY_TYPE_REAL, $display_types));
164
 
165
        $temp->add(new admin_setting_configselect('grade_decimalpoints', new lang_string('decimalpoints', 'grades'),
166
                                                  new lang_string('decimalpoints_help', 'grades'), 2,
167
                                                  array( '0' => '0',
168
                                                         '1' => '1',
169
                                                         '2' => '2',
170
                                                         '3' => '3',
171
                                                         '4' => '4',
172
                                                         '5' => '5')));
173
    }
174
    $ADMIN->add('grades', $temp);
175
 
176
 
177
    /// Scales and outcomes
178
 
179
    $scales = new admin_externalpage('scales', new lang_string('scales'), $CFG->wwwroot.'/grade/edit/scale/index.php', 'moodle/grade:manage');
180
    $ADMIN->add('grades', $scales);
181
    if (!empty($CFG->enableoutcomes)) {
182
        $outcomes = new admin_externalpage('outcomes', new lang_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage');
183
        $ADMIN->add('grades', $outcomes);
184
    }
185
    $letters = new admin_externalpage('letters', new lang_string('letters', 'grades'), $CFG->wwwroot.'/grade/edit/letter/index.php', 'moodle/grade:manageletters');
186
    $ADMIN->add('grades', $letters);
187
 
188
    // The plugins must implement a settings.php file that adds their admin settings to the $settings object
189
 
190
    // Reports
191
    foreach (core_component::get_plugin_list('gradereport') as $plugin => $plugindir) {
192
     // Include all the settings commands for this plugin if there are any
193
        if (file_exists($plugindir.'/settings.php')) {
194
            $settings = new admin_settingpage('gradereport'.$plugin, new lang_string('pluginname', 'gradereport_'.$plugin), 'moodle/grade:manage');
195
            include($plugindir.'/settings.php');
196
            if ($settings) {
197
                $ADMIN->add('gradereports', $settings);
198
            }
199
        }
200
    }
201
 
202
    // Imports
203
    foreach (core_component::get_plugin_list('gradeimport') as $plugin => $plugindir) {
204
 
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
    }
214
 
215
 
216
    // Exports
217
    foreach (core_component::get_plugin_list('gradeexport') as $plugin => $plugindir) {
218
     // Include all the settings commands for this plugin if there are any
219
        if (file_exists($plugindir.'/settings.php')) {
220
            $settings = new admin_settingpage('gradeexport'.$plugin, new lang_string('pluginname', 'gradeexport_'.$plugin), 'moodle/grade:manage');
221
            include($plugindir.'/settings.php');
222
            if ($settings) {
223
                $ADMIN->add('gradeexports', $settings);
224
            }
225
        }
226
    }
227
 
1441 ariadna 228
    // Penalty.
229
 
230
    // Supported modules.
231
    $modules = core_grades\penalty_manager::get_supported_modules();
232
    if (!empty($modules)) {
233
        $temp = new admin_settingpage('supportedplugins', new lang_string('gradepenalty_supportedplugins', 'grades'),
234
            'moodle/grade:manage');
235
 
236
        $options = [];
237
        foreach ($modules as $module) {
238
            $options[$module] = new lang_string('modulename', $module);
239
        }
240
        $temp->add(new admin_setting_configmultiselect('gradepenalty_enabledmodules',
241
            new lang_string('gradepenalty_enabledmodules', 'grades'),
242
            new lang_string('gradepenalty_enabledmodules_help', 'grades'), [], $options));
243
 
244
        $ADMIN->add('gradepenalty', $temp);
245
    }
246
 
247
    // External page to manage the penalty plugins.
248
    $temp = new admin_externalpage(
249
        'managepenaltyplugins',
250
        get_string('managepenaltyplugins', 'grades'),
251
        new moodle_url('/grade/penalty/manage_penalty_plugins.php'),
252
        'moodle/grade:manage'
253
    );
254
    $ADMIN->add('gradepenalty', $temp);
255
 
256
    // Settings from each penalty plugin.
257
    foreach (core_component::get_plugin_list('gradepenalty') as $plugin => $plugindir) {
258
        // Check if the plugin is enabled.
259
        if (gradepenalty::is_plugin_enabled($plugin)) {
260
            // Include all the settings commands for this plugin if there are any.
261
            if (file_exists($plugindir . '/settings.php')) {
262
                include($plugindir . '/settings.php');
263
            }
264
        }
265
    }
1 efrain 266
} // end of speedup