adding some strings
[moodle-linuxchix.git] / grade / report / index.php
blobc53d4f9f3ec7b97f711a4f341e4d887a119190b3
1 <?php //$Id$
3 ///////////////////////////////////////////////////////////////////////////
4 // NOTICE OF COPYRIGHT //
5 // //
6 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
7 // http://moodle.org //
8 // //
9 // Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
10 // //
11 // This program is free software; you can redistribute it and/or modify //
12 // it under the terms of the GNU General Public License as published by //
13 // the Free Software Foundation; either version 2 of the License, or //
14 // (at your option) any later version. //
15 // //
16 // This program is distributed in the hope that it will be useful, //
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
19 // GNU General Public License for more details: //
20 // //
21 // http://www.gnu.org/copyleft/gpl.html //
22 // //
23 ///////////////////////////////////////////////////////////////////////////
25 require '../../config.php';
27 $courseid = required_param('id', PARAM_INT);
29 /// basic access checks
30 if (!$course = get_record('course', 'id', $courseid)) {
31 print_error('nocourseid');
33 require_login($course);
34 $context = get_context_instance(CONTEXT_COURSE, $course->id);
36 /// find all accessible reports
37 if ($reports = get_list_of_plugins('grade/report', 'CVS')) { // Get all installed reports
38 foreach ($reports as $key => $plugin) { // Remove ones we can't see
39 if (!has_capability('gradereport/'.$plugin.':view', $context)) {
40 unset($reports[$key]);
45 if (empty($reports)) {
46 error('No reports accessible', $CFG->wwwroot.'/course/view.php:id='.$course->id); // TODO: localize
49 if (!isset($USER->grade_last_report)) {
50 $USER->grade_last_report = array();
53 if (!empty($USER->grade_last_report[$course->id])) {
54 $last = $USER->grade_last_report[$course->id];
55 } else {
56 $last = null;
59 if (!in_array($last, $reports)) {
60 $last = null;
63 if (empty($last)) {
64 if (in_array('grader', $reports)) {
65 $last = 'grader';
67 } else if (in_array('user', $reports)) {
68 $last = 'user';
70 } else {
71 $last = reset($reports);
75 //redirect to last or guessed report
76 redirect($CFG->wwwroot.'/grade/report/'.$last.'/index.php?id='.$course->id);