-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassign.submissions.fn.php
128 lines (113 loc) · 4.89 KB
/
assign.submissions.fn.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package block_ned_teacher_tools
* @copyright Michael Gardener <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// Get the assignment.
if (! $assign = $DB->get_record("assign", array("id" => $iid))) {
print_error("Course module is incorrect");
}
// Get the course module entry.
if (! $cm = get_coursemodule_from_instance("assign", $assign->id, $course->id)) {
print_error("Course Module ID was incorrect");
}
$ctx = context_module::instance($cm->id);
require_once("$CFG->dirroot/repository/lib.php");
require_once("$CFG->dirroot/grade/grading/lib.php");
require_once($CFG->dirroot.'/mod/assign/lib.php');
require_once($CFG->dirroot.'/mod/assign/locallib.php');
require_once($CFG->dirroot.'/blocks/ned_teacher_tools/assign_edit_grade_form.php');
$assign = new assign($ctx, $cm, $course);
$o = '';
$mform = null;
$notices = array();
if (($show == 'unmarked') || ($show == 'saved')) {
if ($action == 'submitgrade') {
if (optional_param('saveandshownext', null, PARAM_RAW)) {
// Save and show next.
$action = 'grade';
if (block_ned_teacher_tools_process_save_grade($mform, $assign, $ctx, $course, $pageparams, $gradingonly)) {
$action = 'nextgrade';
}
} else if (optional_param('nosaveandprevious', null, PARAM_RAW)) {
$action = 'previousgrade';
} else if (optional_param('nosaveandnext', null, PARAM_RAW)) {
// Show next button.
$action = 'nextgrade';
} else if (optional_param('savegrade', null, PARAM_RAW)) {
// Save changes button.
$action = 'grade';
if (block_ned_teacher_tools_process_save_grade($mform, $assign, $ctx, $course, $pageparams, $gradingonly)) {
$action = 'grade';
}
} else {
// Cancel button.
$action = 'grading';
}
} else {
$action = 'grade';
}
if (!$gradingonly) {
$returnparams = array('rownum' => optional_param('rownum', 0, PARAM_INT));
$assign->register_return_link($action, $returnparams);
if (isset($_POST['onlinetext'])) {
unset($_POST['onlinetext']);
}
// Now show the right view page.
if ($action == 'previousgrade') {
$mform = null;
$_POST = null;
$o .= block_ned_teacher_tools_view_single_grade_page($mform, -1, $assign, $ctx, $cm, $course, $pageparams);
} else if ($action == 'nextgrade') {
$mform = null;
$_POST = null;
$o .= block_ned_teacher_tools_view_single_grade_page($mform, 1, $assign, $ctx, $cm, $course, $pageparams);
} else if ($action == 'grade') {
$mform = null;
$_POST = null;
$o .= block_ned_teacher_tools_view_single_grade_page($mform, 0, $assign, $ctx, $cm, $course, $pageparams);
}
}
} else if ($show == 'marked') {
if ($expand) {
if (($action == 'submitgrade') && (optional_param('savegrade', null, PARAM_RAW))) {
block_ned_teacher_tools_process_save_grade($mform, $assign, $ctx, $course, $pageparams, $gradingonly);
}
if (optional_param('nosaveandprevious', null, PARAM_RAW)) {
$mform = null;
$_POST = null;
$o .= block_ned_teacher_tools_view_single_grade_page($mform, -1, $assign, $ctx, $cm, $course, $pageparams);
} else if (optional_param('nosaveandnext', null, PARAM_RAW)) {
$mform = null;
$_POST = null;
$o .= block_ned_teacher_tools_view_single_grade_page($mform, 1, $assign, $ctx, $cm, $course, $pageparams);
} else {
$mform = null;
$_POST = null;
$o .= block_ned_teacher_tools_view_single_grade_page($mform, 0, $assign, $ctx, $cm, $course, $pageparams);
}
} else {
$o .= block_ned_teacher_tools_view_submissions($mform, $offset = 0, $showattemptnumber = null,
$assign, $ctx, $cm, $course, $pageparams);
}
// echo $o;
} else if ($show == 'unsubmitted') {
$o .= block_ned_teacher_tools_view_submissions($mform, $offset = 0, $showattemptnumber = null,
$assign, $ctx, $cm, $course, $pageparams);
// echo $o;
}