adding some strings
[moodle-linuxchix.git] / grade / report / grader / index.php
blob342cc782a46caaa642d607681ab5cfce687a0a96
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 ///////////////////////////////////////////////////////////////////////////
26 require_once '../../../config.php';
27 require_once $CFG->libdir.'/gradelib.php';
28 require_once $CFG->dirroot.'/grade/lib.php';
29 require_once $CFG->dirroot.'/grade/report/grader/lib.php';
31 $courseid = required_param('id'); // course id
32 $page = optional_param('page', 0, PARAM_INT); // active page
33 $perpageurl = optional_param('perpage', 0, PARAM_INT);
34 $edit = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
36 $sortitemid = optional_param('sortitemid', 0, PARAM_ALPHANUM); // sort by which grade item
37 $action = optional_param('action', 0, PARAM_ALPHAEXT);
38 $move = optional_param('move', 0, PARAM_INT);
39 $type = optional_param('type', 0, PARAM_ALPHA);
40 $target = optional_param('target', 0, PARAM_ALPHANUM);
41 $toggle = optional_param('toggle', NULL, PARAM_INT);
42 $toggle_type = optional_param('toggle_type', 0, PARAM_ALPHANUM);
44 /// basic access checks
45 if (!$course = get_record('course', 'id', $courseid)) {
46 print_error('nocourseid');
48 require_login($course);
49 $context = get_context_instance(CONTEXT_COURSE, $course->id);
51 require_capability('gradereport/grader:view', $context);
52 require_capability('moodle/grade:viewall', $context);
54 /// return tracking object
55 $gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'grader', 'courseid'=>$courseid, 'page'=>$page));
57 /// last selected report session tracking
58 if (!isset($USER->grade_last_report)) {
59 $USER->grade_last_report = array();
61 $USER->grade_last_report[$course->id] = 'grader';
63 /// Build navigation
65 $strgrades = get_string('grades');
66 $reportname = get_string('modulename', 'gradereport_grader');
68 $navlinks = array(array('name'=>$strgrades, 'link'=>$CFG->wwwroot.'/grade/index.php?id='.$courseid, 'type'=>'misc'),
69 array('name'=>$reportname, 'link'=>'', 'type'=>'misc'));
70 $navigation = build_navigation($navlinks);
73 /// Build editing on/off buttons
75 if (!isset($USER->gradeediting)) {
76 $USER->gradeediting = array();
79 if (has_capability('moodle/grade:override', $context)) {
80 if (!isset($USER->gradeediting[$course->id])) {
81 $USER->gradeediting[$course->id] = 0;
84 if (($edit == 1) and confirm_sesskey()) {
85 $USER->gradeediting[$course->id] = 1;
86 } else if (($edit == 0) and confirm_sesskey()) {
87 $USER->gradeediting[$course->id] = 0;
90 // page params for the turn editting on
91 $options = $gpr->get_options();
92 $options['sesskey'] = sesskey();
94 if ($USER->gradeediting[$course->id]) {
95 $options['edit'] = 0;
96 $string = get_string('turneditingoff');
97 } else {
98 $options['edit'] = 1;
99 $string = get_string('turneditingon');
102 $buttons = print_single_button('index.php', $options, $string, 'get', '_self', true);
104 } else {
105 $USER->gradeediting[$course->id] = 0;
106 $buttons = '';
109 $gradeserror = array();
111 // Handle toggle change request
112 if (!is_null($toggle) && !empty($toggle_type)) {
113 set_user_preferences(array('grade_report_show'.$toggle_type => $toggle));
116 //first make sure we have proper final grades - this must be done before constructing of the grade tree
117 grade_regrade_final_grades($courseid);
119 // Perform actions
120 if (!empty($target) && !empty($action) && confirm_sesskey()) {
121 grade_report_grader::process_action($target, $action);
124 // Initialise the grader report object
125 $report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid);
127 /// processing posted grades & feedback here
128 if ($data = data_submitted() and confirm_sesskey()) {
129 $report->process_data($data);
132 // Override perpage if set in URL
133 if ($perpageurl) {
134 $report->user_prefs['studentsperpage'] = $perpageurl;
137 $report->load_users();
138 $numusers = $report->get_numusers();
139 $report->load_final_grades();
141 /// Print header
142 print_header_simple($strgrades.': '.$reportname, ': '.$strgrades, $navigation,
143 '', '', true, $buttons, navmenu($course));
145 /// Print the plugin selector at the top
146 print_grade_plugin_selector($courseid, 'report', 'grader');
148 // Add tabs
149 $currenttab = 'graderreport';
150 require('tabs.php');
152 echo $report->group_selector;
154 echo '<div class="clearer"></div>';
156 echo $report->get_toggles_html();
157 print_paging_bar($numusers, $report->page, $report->get_pref('studentsperpage'), $report->pbarurl);
159 $reporthtml = '<table class="gradestable">';
160 $reporthtml .= $report->get_headerhtml();
161 $reporthtml .= $report->get_rangehtml();
162 $reporthtml .= $report->get_studentshtml();
163 $reporthtml .= $report->get_avghtml(true);
164 $reporthtml .= $report->get_avghtml();
165 $reporthtml .= "</table>";
167 // print submit button
168 if ($USER->gradeediting[$course->id]) {
169 echo '<form action="index.php" method="post">';
170 echo '<div>';
171 echo '<input type="hidden" value="'.$courseid.'" name="id" />';
172 echo '<input type="hidden" value="'.sesskey().'" name="sesskey" />';
173 echo '<input type="hidden" value="grader" name="report"/>';
176 echo $reporthtml;
178 // print submit button
179 if ($USER->gradeediting[$course->id] && ($report->get_pref('quickfeedback') || $report->get_pref('quickgrading'))) {
180 echo '<div class="submit"><input type="submit" value="'.get_string('update').'" /></div>';
181 echo '</div></form>';
184 // prints paging bar at bottom for large pages
185 if ($report->get_pref('studentsperpage') >= 20) {
186 print_paging_bar($numusers, $report->page, $report->get_pref('studentsperpage'), $report->pbarurl);
189 print_footer($course);