Fixes bug MDL-9753, "THEME->larrow, rarrow don't work in stock IE6"
[moodle-pu.git] / grade / index.php
bloba93069997a05d1dbe9e7db2dad900a0f7e589f20
1 <?PHP
2 require_once("../config.php");
3 require_once("lib.php");
5 $id = required_param('id'); // course id
6 $download = optional_param('download');
7 $user = optional_param('user', -1);
8 $group = optional_param('group', -1);
9 $action = optional_param('action', 'grades');
10 $cview = optional_param('cview', -1);
12 if (!$course = get_record('course', 'id', $id)) {
13 error('No course ID');
16 require_login($course->id);
18 /*
19 if (has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
20 $group = get_and_set_current_group($course, $course->groupmode, $group);
21 } else {
22 $group = get_current_group($course->id);
26 // if the user set new prefs make sure they happen now
27 if ($action == 'set_grade_preferences' && $prefs = data_submitted()) {
28 if (!confirm_sesskey()) {
29 error(get_string('confirmsesskeybad', 'error'));
31 grade_set_preferences($course, $prefs);
34 $preferences = grade_get_preferences($course->id);
37 // we want this in its own window
38 if ($action == 'stats') {
39 grade_stats();
40 exit();
41 } else if ($action == 'ods') {
42 grade_download('ods', $id);
43 exit();
44 } else if ($action == 'excel') {
45 grade_download('xls', $id);
46 exit();
47 } else if ($action == 'text') {
48 grade_download('txt', $id);
49 exit();
52 print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
54 grade_preferences_menu($action, $course, $group);
56 /// copied code from assignment module, if this is not the way to do this please change it
57 /// the above code does not work
58 /// set_and_print_groups() is not fully implemented as function groups_instance_print_grouping_selector()
59 /// and function groups_instance_print_group_selector() are missing.
60 $context = get_context_instance(CONTEXT_COURSE, $course->id);
61 $changegroup = optional_param('group', -1, PARAM_INT); // choose the current group
62 $groupmode = groupmode($course);
63 $currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
65 /// Now we need a menu for separategroups as well!
66 if ($groupmode == VISIBLEGROUPS || ($groupmode
67 && has_capability('moodle/site:accessallgroups', $context))) {
69 //the following query really needs to change
70 if ($groups = groups_get_groups_names($course->id)) { //TODO:
71 print_box_start('groupmenu');
72 print_group_menu($groups, $groupmode, $currentgroup, 'index.php?id='.$course->id);
73 print_box_end(); // groupmenu
77 grade_set_uncategorized();
79 if (has_capability('moodle/course:viewcoursegrades', get_context_instance(CONTEXT_COURSE, $course->id))) {
80 switch ($action) {
81 case "cats":
82 grade_set_categories();
83 break;
84 case "insert_category":
85 grade_insert_category();
86 grade_set_categories();
87 break;
88 case "assign_categories":
89 grade_assign_categories();
90 grade_set_categories();
91 break;
92 case "set_grade_weights":
93 grade_set_grade_weights();
94 grade_display_grade_weights();
95 break;
96 case "weights":
97 grade_display_grade_weights();
98 break;
99 case "grades":
100 if ($preferences->use_advanced == 1) {
101 grade_view_all_grades($user);
103 else {
104 // all the grades will be in the 'uncategorized' category
105 grade_view_category_grades($user);
107 break;
108 case "vcats":
109 grade_view_category_grades($user);
110 break;
111 case "prefs":
112 case "set_grade_preferences":
113 grade_display_grade_preferences($course, $preferences);
114 break;
115 case "letters":
116 grade_display_letter_grades();
117 break;
118 case "set_letter_grades":
119 grade_set_letter_grades();
120 grade_display_letter_grades();
121 break;
122 case "delete_category":
123 grade_delete_category();
124 // re-run set_uncategorized as they may have deleted a category that had items in it
125 grade_set_uncategorized();
126 grade_set_categories();
127 break;
128 case "view_student_grades":
129 grade_view_all_grades($user);
130 break;
131 case "view_student_category_grades":
132 grade_view_category_grades($user);
133 break;
134 default:
135 if ($preferences->use_advanced == 1) {
136 grade_view_all_grades($user);
138 else {
139 grade_view_category_grades($user);
141 } // end switch
142 } // end if isTeacher
143 else {
144 if ($preferences->show_weighted || $preferences->show_points || $preferences->show_percent) {
146 if ($preferences->use_advanced == 1) {
147 if($action != 'vcats') {
148 grade_view_all_grades($USER->id);
150 else {
151 grade_view_category_grades($USER->id);
153 } else {
154 grade_view_category_grades($USER->id);
157 } else {
158 error(get_string('gradebookhiddenerror','grades'));
160 } // end else (!teacher)
162 print_footer($course);