MDL-38173 Swap conditions to make CI servers happy.
[moodle.git] / mod / assignment / grade.php
blobf73b88b32dbc0bf108a696029eab16c32cba1daf
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Redirect the user to the appropriate submission related page within /mod/assignment
20 * Based on the supplied parameters and the user's capabilities the user will be redirected
21 * to either their own submission, a particular student's submission or a summary of all submissions
23 * @package mod_assignment
24 * @category grade
25 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29 require_once("../../config.php");
31 $id = required_param('id', PARAM_INT); // Course module ID
32 $userid = optional_param('userid', 0, PARAM_INT); // Graded user ID (optional)
34 $PAGE->set_url('/mod/assignment/grade.php', array('id'=>$id));
35 if (! $cm = get_coursemodule_from_id('assignment', $id)) {
36 print_error('invalidcoursemodule');
39 if (! $assignment = $DB->get_record("assignment", array("id"=>$cm->instance))) {
40 print_error('invalidid', 'assignment');
43 if (! $course = $DB->get_record("course", array("id"=>$assignment->course))) {
44 print_error('coursemisconf', 'assignment');
47 require_login($course, false, $cm);
49 if (has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
50 if ($userid) {
51 redirect('submissions.php?id='.$cm->id.'&userid='.$userid.'&mode=single&filter=0&offset=0');
52 } else {
53 redirect('submissions.php?id='.$cm->id);
55 } else {
56 // user will view his own submission, parameter $userid is ignored
57 redirect('view.php?id='.$cm->id);