Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/grade/edit/settings/form.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 if (!defined('MOODLE_INTERNAL')) {
00019     die('Direct access to this script is forbidden.');    
00020 }
00021 
00022 require_once($CFG->libdir.'/formslib.php');
00023 
00028 class course_settings_form extends moodleform {
00029 
00030     function definition() {
00031         global $USER, $CFG;
00032 
00033         $mform =& $this->_form;
00034 
00035         $systemcontext = get_context_instance(CONTEXT_SYSTEM);
00036         $can_view_admin_links = false;
00037         if (has_capability('moodle/grade:manage', $systemcontext)) {
00038             $can_view_admin_links = true;
00039         }
00040 
00041         // General settings
00042         $strchangedefaults = get_string('changedefaults', 'grades');
00043         $mform->addElement('header', 'general', get_string('generalsettings', 'grades'));
00044         if ($can_view_admin_links) {
00045             $link = '<a href="' . $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradessettings">' . $strchangedefaults . '</a>';
00046             $mform->addElement('static', 'generalsettingslink', null, $link);
00047         }
00048         $options = array(-1                                      => get_string('default', 'grades'),
00049                          GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'),
00050                          GRADE_REPORT_AGGREGATION_POSITION_LAST  => get_string('positionlast', 'grades'));
00051         $default_gradedisplaytype = $CFG->grade_aggregationposition;
00052         foreach ($options as $key=>$option) {
00053             if ($key == $default_gradedisplaytype) {
00054                 $options[-1] = get_string('defaultprev', 'grades', $option);
00055                 break;
00056             }
00057         }
00058         $mform->addElement('select', 'aggregationposition', get_string('aggregationposition', 'grades'), $options);
00059         $mform->addHelpButton('aggregationposition', 'aggregationposition', 'grades');
00060 
00061         // Grade item settings
00062         $mform->addElement('header', 'grade_item_settings', get_string('gradeitemsettings', 'grades'));
00063         if ($can_view_admin_links) {
00064             $link = '<a href="' . $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradeitemsettings">' . $strchangedefaults . '</a>';
00065             $mform->addElement('static', 'gradeitemsettingslink', null, $link);
00066         }
00067 
00068         $options = array(-1                            => get_string('default', 'grades'),
00069                          GRADE_DISPLAY_TYPE_REAL       => get_string('real', 'grades'),
00070                          GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
00071                          GRADE_DISPLAY_TYPE_LETTER     => get_string('letter', 'grades'),
00072                          GRADE_DISPLAY_TYPE_REAL_PERCENTAGE => get_string('realpercentage', 'grades'),
00073                          GRADE_DISPLAY_TYPE_REAL_LETTER => get_string('realletter', 'grades'),
00074                          GRADE_DISPLAY_TYPE_LETTER_REAL => get_string('letterreal', 'grades'),
00075                          GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE => get_string('letterpercentage', 'grades'),
00076                          GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER => get_string('percentageletter', 'grades'),
00077                          GRADE_DISPLAY_TYPE_PERCENTAGE_REAL => get_string('percentagereal', 'grades'));
00078         asort($options);
00079 
00080         $default_gradedisplaytype = $CFG->grade_displaytype;
00081         foreach ($options as $key=>$option) {
00082             if ($key == $default_gradedisplaytype) {
00083                 $options[-1] = get_string('defaultprev', 'grades', $option);
00084                 break;
00085             }
00086         }
00087         $mform->addElement('select', 'displaytype', get_string('gradedisplaytype', 'grades'), $options);
00088         $mform->addHelpButton('displaytype', 'gradedisplaytype', 'grades');
00089 
00090 
00091         $options = array(-1=> get_string('defaultprev', 'grades', $CFG->grade_decimalpoints), 0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
00092         $mform->addElement('select', 'decimalpoints', get_string('decimalpoints', 'grades'), $options);
00093         $mform->addHelpButton('decimalpoints', 'decimalpoints', 'grades');
00094 
00095 // add setting options for plugins
00096         $types = array('report', 'export', 'import');
00097 
00098         foreach($types as $type) {
00099             foreach (get_plugin_list('grade'.$type) as $plugin => $plugindir) {
00100              // Include all the settings commands for this plugin if there are any
00101                 if (file_exists($plugindir.'/lib.php')) {
00102                     require_once($plugindir.'/lib.php');
00103                     $functionname = 'grade_'.$type.'_'.$plugin.'_settings_definition';
00104                     if (function_exists($functionname)) {
00105                         $mform->addElement('header', 'grade_'.$type.$plugin, get_string('pluginname', 'grade'.$type.'_'.$plugin, NULL));
00106                         if ($can_view_admin_links) {
00107                             $link = '<a href="' . $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradereport' . $plugin . '">' . $strchangedefaults . '</a>';
00108                             $mform->addElement('static', 'gradeitemsettingslink', null, $link);
00109                         }
00110                         $functionname($mform);
00111                     }
00112                 }
00113             }
00114         }
00115 
00116         $mform->addElement('hidden', 'id');
00117         $mform->setType('id', PARAM_INT);
00118 
00119         $this->add_action_buttons();
00120     }
00121 }
00122 
 All Data Structures Namespaces Files Functions Variables Enumerations