|
Moodle
2.2.1
http://www.collinsharper.com
|
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 00020 $courseid = required_param('id', PARAM_INT); 00021 00022 $PAGE->set_url('/grade/report/index.php', array('id'=>$courseid)); 00023 00025 if (!$course = $DB->get_record('course', array('id' => $courseid))) { 00026 print_error('nocourseid'); 00027 } 00028 require_login($course); 00029 $context = get_context_instance(CONTEXT_COURSE, $course->id); 00030 00032 $reports = get_plugin_list('gradereport'); // Get all installed reports 00033 00034 foreach ($reports as $plugin => $plugindir) { // Remove ones we can't see 00035 if (!has_capability('gradereport/'.$plugin.':view', $context)) { 00036 unset($reports[$plugin]); 00037 } 00038 } 00039 00040 if (empty($reports)) { 00041 print_error('noreports', 'debug', $CFG->wwwroot.'/course/view.php?id='.$course->id); 00042 } 00043 00044 if (!isset($USER->grade_last_report)) { 00045 $USER->grade_last_report = array(); 00046 } 00047 00048 if (!empty($USER->grade_last_report[$course->id])) { 00049 $last = $USER->grade_last_report[$course->id]; 00050 } else { 00051 $last = null; 00052 } 00053 00054 if (!array_key_exists($last, $reports)) { 00055 $last = null; 00056 } 00057 00058 if (empty($last)) { 00059 if (array_key_exists('grader', $reports)) { 00060 $last = 'grader'; 00061 00062 } else if (array_key_exists($CFG->grade_profilereport, $reports)) { 00063 $last = $CFG->grade_profilereport; 00064 00065 } else { 00066 reset($reports); 00067 $last = key($reports); 00068 } 00069 } 00070 00071 //redirect to last or guessed report 00072 redirect($CFG->wwwroot.'/grade/report/'.$last.'/index.php?id='.$course->id); 00073