[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * A form for editing course grade settings 19 * 20 * @package core_grades 21 * @copyright 2007 Petr Skoda 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 if (!defined('MOODLE_INTERNAL')) { 26 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page 27 } 28 29 require_once($CFG->libdir.'/formslib.php'); 30 31 /** 32 * First implementation of the preferences in the form of a moodleform. 33 * TODO add "reset to site defaults" button 34 */ 35 class course_settings_form extends moodleform { 36 37 function definition() { 38 global $USER, $CFG; 39 40 $mform =& $this->_form; 41 42 $systemcontext = context_system::instance(); 43 $can_view_admin_links = false; 44 if (has_capability('moodle/grade:manage', $systemcontext)) { 45 $can_view_admin_links = true; 46 } 47 48 // General settings 49 $strchangedefaults = get_string('changedefaults', 'grades'); 50 $mform->addElement('header', 'general', get_string('generalsettings', 'grades')); 51 if ($can_view_admin_links) { 52 $link = '<a href="' . $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradessettings">' . $strchangedefaults . '</a>'; 53 $mform->addElement('static', 'generalsettingslink', null, $link); 54 } 55 $options = array(-1 => get_string('default', 'grades'), 56 GRADE_REPORT_AGGREGATION_POSITION_FIRST => get_string('positionfirst', 'grades'), 57 GRADE_REPORT_AGGREGATION_POSITION_LAST => get_string('positionlast', 'grades')); 58 $default_gradedisplaytype = $CFG->grade_aggregationposition; 59 foreach ($options as $key=>$option) { 60 if ($key == $default_gradedisplaytype) { 61 $options[-1] = get_string('defaultprev', 'grades', $option); 62 break; 63 } 64 } 65 $mform->addElement('select', 'aggregationposition', get_string('aggregationposition', 'grades'), $options); 66 $mform->addHelpButton('aggregationposition', 'aggregationposition', 'grades'); 67 68 // Grade item settings 69 $mform->addElement('header', 'grade_item_settings', get_string('gradeitemsettings', 'grades')); 70 $mform->setExpanded('grade_item_settings'); 71 if ($can_view_admin_links) { 72 $link = '<a href="' . $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradeitemsettings">' . $strchangedefaults . '</a>'; 73 $mform->addElement('static', 'gradeitemsettingslink', null, $link); 74 } 75 76 $options = array(-1 => get_string('default', 'grades'), 77 GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'), 78 GRADE_DISPLAY_TYPE_REAL_PERCENTAGE => get_string('realpercentage', 'grades'), 79 GRADE_DISPLAY_TYPE_REAL_LETTER => get_string('realletter', 'grades'), 80 GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'), 81 GRADE_DISPLAY_TYPE_PERCENTAGE_REAL => get_string('percentagereal', 'grades'), 82 GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER => get_string('percentageletter', 'grades'), 83 GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'), 84 GRADE_DISPLAY_TYPE_LETTER_REAL => get_string('letterreal', 'grades'), 85 GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE => get_string('letterpercentage', 'grades')); 86 87 $default_gradedisplaytype = $CFG->grade_displaytype; 88 foreach ($options as $key=>$option) { 89 if ($key == $default_gradedisplaytype) { 90 $options[-1] = get_string('defaultprev', 'grades', $option); 91 break; 92 } 93 } 94 $mform->addElement('select', 'displaytype', get_string('gradedisplaytype', 'grades'), $options); 95 $mform->addHelpButton('displaytype', 'gradedisplaytype', 'grades'); 96 $mform->setDefault('displaytype', -1); 97 98 $options = array(-1=> get_string('defaultprev', 'grades', $CFG->grade_decimalpoints), 0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5); 99 $mform->addElement('select', 'decimalpoints', get_string('decimalpoints', 'grades'), $options); 100 $mform->addHelpButton('decimalpoints', 'decimalpoints', 'grades'); 101 102 // add setting options for plugins 103 $types = array('report', 'export', 'import'); 104 105 foreach($types as $type) { 106 foreach (core_component::get_plugin_list('grade'.$type) as $plugin => $plugindir) { 107 // Include all the settings commands for this plugin if there are any 108 if (file_exists($plugindir.'/lib.php')) { 109 require_once ($plugindir.'/lib.php'); 110 $functionname = 'grade_'.$type.'_'.$plugin.'_settings_definition'; 111 if (function_exists($functionname)) { 112 $mform->addElement('header', 'grade_'.$type.$plugin, get_string('pluginname', 'grade'.$type.'_'.$plugin, NULL)); 113 $mform->setExpanded('grade_'.$type.$plugin); 114 if ($can_view_admin_links) { 115 $link = '<a href="' . $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradereport' . $plugin . '">' . $strchangedefaults . '</a>'; 116 $mform->addElement('static', 'gradeitemsettingslink', null, $link); 117 } 118 $functionname($mform); 119 } 120 } 121 } 122 } 123 124 $mform->addElement('hidden', 'id'); 125 $mform->setType('id', PARAM_INT); 126 127 $this->add_action_buttons(); 128 } 129 } 130
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |