lang files in plugin folder support for gradebook plugin types.
[moodle.git] / grade / report / overview / index.php
CommitLineData
aa330ebb 1<?php // $Id$
2
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///////////////////////////////////////////////////////////////////////////
24
25require_once '../../../config.php';
26require_once $CFG->libdir.'/gradelib.php';
27require_once $CFG->dirroot.'/grade/lib.php';
28require_once $CFG->dirroot.'/grade/report/overview/lib.php';
29
30$userid = optional_param('userid', $USER->id, PARAM_INT);
31
32/// basic access checks
33if (!$course = get_record('course', 'id', $COURSE->id)) {
34 print_error('nocourseid');
35}
36require_login($course);
37
38if (!$user = get_complete_user_data('id', $userid)) {
39 error("Incorrect userid");
40}
41
42$context = get_context_instance(CONTEXT_COURSE, $course->id);
43$usercontext = get_context_instance(CONTEXT_PERSONAL, $user->id);
44require_capability('gradereport/overview:view', $context);
45
46$access = true;
47if (has_capability('moodle/grade:viewall', $context)) {
48 //ok - can view all course grades
49
50} else if ($user->id == $USER->id and has_capability('moodle/grade:view', $context) and $course->showgrades) {
51 //ok - can view own grades
52
53} else if (has_capability('moodle/grade:view', $usercontext) and $course->showgrades) {
54 // ok - can view grades of this user- parent most probably
55
56} else {
57 $acces = false;
58}
59
60/// return tracking object
61$gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'user', 'courseid'=>$course->id, 'userid'=>$userid));
62
63/// last selected report session tracking
64if (!isset($USER->grade_last_report)) {
65 $USER->grade_last_report = array();
66}
67$USER->grade_last_report[$course->id] = 'user';
68
69/// Build navigation
70$strgrades = get_string('grades');
71$reportname = get_string('modulename', 'gradereport_overview');
72
73$navigation = grade_build_nav(__FILE__, $reportname, $course->id);
74
75/// Print header
76print_header_simple($strgrades.': '.$reportname, ': '.$strgrades, $navigation,
77 '', '', true, '', navmenu($course));
78
79/// Print the plugin selector at the top
80print_grade_plugin_selector($course->id, 'report', 'user');
81
82if ($access) {
83
84 //first make sure we have proper final grades - this must be done before constructing of the grade tree
85 grade_regrade_final_grades($course->id);
86
87 // Create a report instance
88 $report = new grade_report_overview($userid, $gpr, $context);
89
90 $gradetotal = 0;
91 $gradesum = 0;
92
93 // print the page
94 print_heading(get_string('modulename', 'gradereport_user'). ' - '.fullname($report->user));
95
96 if ($report->fill_table()) {
97 echo $report->print_table(true);
98 }
99
100} else {
101 // no access to grades!
102 echo "Can not view grades."; //TODO: localize
103}
104print_footer($course);
105
106?>