Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/grade/edit/settings/index.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 require_once '../../../config.php';
00019 require_once $CFG->dirroot.'/grade/lib.php';
00020 require_once $CFG->libdir.'/gradelib.php';
00021 require_once 'form.php';
00022 
00023 $courseid  = optional_param('id', SITEID, PARAM_INT);
00024 
00025 $PAGE->set_url('/grade/edit/settings/index.php', array('id'=>$courseid));
00026 $PAGE->set_pagelayout('admin');
00027 
00028 if (!$course = $DB->get_record('course', array('id' => $courseid))) {
00029     print_error('nocourseid');
00030 }
00031 require_login($course);
00032 $context = get_context_instance(CONTEXT_COURSE, $course->id);
00033 
00034 require_capability('moodle/grade:manage', $context);
00035 
00036 $gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'settings', 'courseid'=>$courseid));
00037 
00038 $strgrades = get_string('grades');
00039 $pagename  = get_string('coursesettings', 'grades');
00040 
00041 $navigation = grade_build_nav(__FILE__, $pagename, $courseid);
00042 
00043 $returnurl = $CFG->wwwroot.'/grade/index.php?id='.$course->id;
00044 
00045 $mform = new course_settings_form();
00046 
00047 $settings = grade_get_settings($course->id);
00048 
00049 $mform->set_data($settings);
00050 
00051 if ($mform->is_cancelled()) {
00052     redirect($returnurl);
00053 
00054 } else if ($data = $mform->get_data()) {
00055     $data = (array)$data;
00056     $general = array('displaytype', 'decimalpoints', 'aggregationposition');
00057     foreach ($data as $key=>$value) {
00058         if (!in_array($key, $general) and strpos($key, 'report_') !== 0
00059                                       and strpos($key, 'import_') !== 0
00060                                       and strpos($key, 'export_') !== 0) {
00061             continue;
00062         }
00063         if ($value == -1) {
00064             $value = null;
00065         }
00066         grade_set_setting($course->id, $key, $value);
00067     }
00068 
00069     redirect($returnurl);
00070 }
00071 
00072 print_grade_page_head($courseid, 'settings', 'coursesettings', get_string('coursesettings', 'grades'));
00073 
00074 echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal centerpara');
00075 echo get_string('coursesettingsexplanation', 'grades');
00076 echo $OUTPUT->box_end();
00077 
00078 $mform->display();
00079 
00080 echo $OUTPUT->footer();
00081 
00082 
 All Data Structures Namespaces Files Functions Variables Enumerations