| Línea 26... |
Línea 26... |
| 26 |
require_once($CFG->libdir.'/gradelib.php');
|
26 |
require_once($CFG->libdir.'/gradelib.php');
|
| 27 |
require_once($CFG->dirroot.'/user/renderer.php');
|
27 |
require_once($CFG->dirroot.'/user/renderer.php');
|
| 28 |
require_once($CFG->dirroot.'/grade/lib.php');
|
28 |
require_once($CFG->dirroot.'/grade/lib.php');
|
| 29 |
require_once($CFG->dirroot.'/grade/report/grader/lib.php');
|
29 |
require_once($CFG->dirroot.'/grade/report/grader/lib.php');
|
| Línea -... |
Línea 30... |
| - |
|
30 |
|
| - |
|
31 |
// This report may require a lot of memory and time on large courses.
|
| - |
|
32 |
raise_memory_limit(MEMORY_HUGE);
|
| - |
|
33 |
set_time_limit(120);
|
| 30 |
|
34 |
|
| 31 |
$courseid = required_param('id', PARAM_INT); // course id
|
35 |
$courseid = required_param('id', PARAM_INT); // course id
|
| 32 |
$page = optional_param('page', 0, PARAM_INT); // active page
|
36 |
$page = optional_param('page', 0, PARAM_INT); // active page
|
| Línea 33... |
Línea 37... |
| 33 |
$edit = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
|
37 |
$edit = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
|
| Línea 43... |
Línea 47... |
| 43 |
|
47 |
|
| 44 |
$graderreportsifirst = optional_param('sifirst', null, PARAM_NOTAGS);
|
48 |
$graderreportsifirst = optional_param('sifirst', null, PARAM_NOTAGS);
|
| Línea 45... |
Línea 49... |
| 45 |
$graderreportsilast = optional_param('silast', null, PARAM_NOTAGS);
|
49 |
$graderreportsilast = optional_param('silast', null, PARAM_NOTAGS);
|
| - |
|
50 |
|
| Línea 46... |
Línea 51... |
| 46 |
|
51 |
$studentsperpage = optional_param('perpage', null, PARAM_INT);
|
| 47 |
$studentsperpage = optional_param('perpage', null, PARAM_INT);
|
52 |
$baseurl = new moodle_url('/grade/report/grader/index.php', ['id' => $courseid]);
|
| 48 |
|
- |
|
| 49 |
$PAGE->set_url(new moodle_url('/grade/report/grader/index.php', array('id'=>$courseid)));
|
- |
|
| 50 |
$PAGE->set_pagelayout('report');
|
- |
|
| 51 |
$PAGE->requires->js_call_amd('gradereport_grader/stickycolspan', 'init');
|
- |
|
| Línea 52... |
Línea 53... |
| 52 |
$PAGE->requires->js_call_amd('gradereport_grader/user', 'init');
|
53 |
|
| 53 |
$PAGE->requires->js_call_amd('gradereport_grader/feedback_modal', 'init');
|
54 |
$PAGE->set_url(new moodle_url('/grade/report/grader/index.php', array('id'=>$courseid)));
|
| 54 |
$PAGE->requires->js_call_amd('core_grades/gradebooksetup_forms', 'init');
|
55 |
$PAGE->set_pagelayout('report');
|
| 55 |
|
56 |
|
| Línea 56... |
Línea 57... |
| 56 |
// basic access checks
|
57 |
// basic access checks
|
| 57 |
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
58 |
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
| 58 |
throw new \moodle_exception('invalidcourseid');
|
59 |
throw new \moodle_exception('invalidcourseid');
|
| 59 |
}
|
60 |
}
|
| Línea 60... |
Línea 61... |
| 60 |
|
61 |
|
| 61 |
// Conditionally add the group JS if we have groups enabled.
|
62 |
// Conditionally add the group JS if we have groups enabled.
|
| Línea 122... |
Línea 123... |
| 122 |
if (!empty($target) && !empty($action) && confirm_sesskey()) {
|
123 |
if (!empty($target) && !empty($action) && confirm_sesskey()) {
|
| 123 |
grade_report_grader::do_process_action($target, $action, $courseid);
|
124 |
grade_report_grader::do_process_action($target, $action, $courseid);
|
| 124 |
}
|
125 |
}
|
| Línea 125... |
Línea 126... |
| 125 |
|
126 |
|
| 126 |
$reportname = get_string('pluginname', 'gradereport_grader');
|
- |
|
| - |
|
127 |
$reportname = get_string('pluginname', 'gradereport_grader');
|
| - |
|
128 |
$regradetask = \core_course\task\regrade_final_grades::create($courseid);
|
| - |
|
129 |
$indicatorheading = get_string('recalculatinggrades', 'grades');
|
| - |
|
130 |
$indicatormessage = get_string('recalculatinggradesadhoc', 'grades');
|
| - |
|
131 |
$taskindicator = new \core\output\task_indicator($regradetask, $indicatorheading, $indicatormessage, $PAGE->url);
|
| 127 |
|
132 |
if (!$taskindicator->has_task_record()) {
|
| 128 |
// Do this check just before printing the grade header (and only do it once).
|
133 |
// Do this check just before printing the grade header (and only do it once).
|
| - |
|
134 |
grade_regrade_final_grades_if_required($course);
|
| Línea 129... |
Línea 135... |
| 129 |
grade_regrade_final_grades_if_required($course);
|
135 |
}
|
| 130 |
|
136 |
|
| 131 |
//Initialise the grader report object that produces the table
|
137 |
//Initialise the grader report object that produces the table
|
| 132 |
//the class grade_report_grader_ajax was removed as part of MDL-21562
|
138 |
//the class grade_report_grader_ajax was removed as part of MDL-21562
|
| Línea 136... |
Línea 142... |
| 136 |
// We have lots of hardcoded 'ASC' and 'DESC' strings in grade/report/grader.lib :(. So we need to uppercase the sort.
|
142 |
// We have lots of hardcoded 'ASC' and 'DESC' strings in grade/report/grader.lib :(. So we need to uppercase the sort.
|
| 137 |
$sort = strtoupper($sort);
|
143 |
$sort = strtoupper($sort);
|
| Línea 138... |
Línea 144... |
| 138 |
|
144 |
|
| Línea 139... |
Línea -... |
| 139 |
$report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid, $sort);
|
- |
|
| 140 |
|
- |
|
| 141 |
// We call this a little later since we need some info from the grader report.
|
- |
|
| 142 |
$PAGE->requires->js_call_amd('gradereport_grader/collapse', 'init', [
|
- |
|
| 143 |
'userID' => $USER->id,
|
- |
|
| 144 |
'courseID' => $courseid,
|
- |
|
| 145 |
'defaultSort' => $report->get_default_sortable()
|
- |
|
| 146 |
]);
|
145 |
$report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid, $sort);
|
| Línea 147... |
Línea 146... |
| 147 |
|
146 |
|
| 148 |
$numusers = $report->get_numusers(true, true);
|
147 |
$numusers = $report->get_numusers(true, true);
|
| 149 |
|
148 |
|
| Línea 163... |
Línea 162... |
| 163 |
if ($isediting && ($data = data_submitted()) && confirm_sesskey()) {
|
162 |
if ($isediting && ($data = data_submitted()) && confirm_sesskey()) {
|
| 164 |
// Processing posted grades here.
|
163 |
// Processing posted grades here.
|
| 165 |
$warnings = $report->process_data($data);
|
164 |
$warnings = $report->process_data($data);
|
| 166 |
}
|
165 |
}
|
| Línea -... |
Línea 166... |
| - |
|
166 |
|
| - |
|
167 |
if ($taskindicator->has_task_record()) {
|
| - |
|
168 |
echo $OUTPUT->render($taskindicator);
|
| - |
|
169 |
echo $OUTPUT->footer();
|
| - |
|
170 |
exit;
|
| - |
|
171 |
}
|
| - |
|
172 |
|
| - |
|
173 |
// We call this a little later since we need some info from the grader report.
|
| - |
|
174 |
$PAGE->requires->js_call_amd('gradereport_grader/collapse', 'init', [
|
| - |
|
175 |
'userID' => $USER->id,
|
| - |
|
176 |
'courseID' => $courseid,
|
| - |
|
177 |
'defaultSort' => $report->get_default_sortable(),
|
| - |
|
178 |
]);
|
| - |
|
179 |
$PAGE->requires->js_call_amd('gradereport_grader/stickycolspan', 'init');
|
| - |
|
180 |
$PAGE->requires->js_call_amd('gradereport_grader/user', 'init', [$baseurl->out(false)]);
|
| - |
|
181 |
$PAGE->requires->js_call_amd('gradereport_grader/feedback_modal', 'init');
|
| - |
|
182 |
$PAGE->requires->js_call_amd('core_grades/gradebooksetup_forms', 'init');
|
| 167 |
|
183 |
|
| 168 |
// Final grades MUST be loaded after the processing.
|
184 |
// Final grades MUST be loaded after the processing.
|
| 169 |
$report->load_users();
|
185 |
$report->load_users();
|
| Línea 170... |
Línea 186... |
| 170 |
$report->load_final_grades();
|
186 |
$report->load_final_grades();
|
| Línea 189... |
Línea 205... |
| 189 |
$pagingoptions[] = $studentsperpage; // To make sure the current preference is within the options.
|
205 |
$pagingoptions[] = $studentsperpage; // To make sure the current preference is within the options.
|
| 190 |
}
|
206 |
}
|
| 191 |
$pagingoptions = array_unique($pagingoptions);
|
207 |
$pagingoptions = array_unique($pagingoptions);
|
| 192 |
sort($pagingoptions);
|
208 |
sort($pagingoptions);
|
| 193 |
$pagingoptions = array_combine($pagingoptions, $pagingoptions);
|
209 |
$pagingoptions = array_combine($pagingoptions, $pagingoptions);
|
| 194 |
if ($numusers > grade_report_grader::MAX_STUDENTS_PER_PAGE) {
|
210 |
$maxusers = $report->get_max_students_per_page();
|
| - |
|
211 |
if ($numusers > $maxusers) {
|
| 195 |
$pagingoptions['0'] = grade_report_grader::MAX_STUDENTS_PER_PAGE;
|
212 |
$pagingoptions['0'] = $maxusers;
|
| 196 |
} else {
|
213 |
} else {
|
| 197 |
$pagingoptions['0'] = get_string('all');
|
214 |
$pagingoptions['0'] = get_string('all');
|
| 198 |
}
|
215 |
}
|
| Línea 199... |
Línea 216... |
| 199 |
|
216 |
|
| 200 |
$perpagedata = [
|
217 |
$perpagedata = [
|
| 201 |
'baseurl' => new moodle_url('/grade/report/grader/index.php', ['id' => s($courseid), 'report' => 'grader']),
|
218 |
'baseurl' => (new moodle_url('/grade/report/grader/index.php', ['id' => s($courseid), 'report' => 'grader']))->out(false),
|
| 202 |
'options' => []
|
219 |
'options' => []
|
| 203 |
];
|
220 |
];
|
| 204 |
foreach ($pagingoptions as $key => $name) {
|
221 |
foreach ($pagingoptions as $key => $name) {
|
| 205 |
$perpagedata['options'][] = [
|
222 |
$perpagedata['options'][] = [
|
| Línea 213... |
Línea 230... |
| 213 |
$OUTPUT->render_from_template('gradereport_grader/perpage', $perpagedata)
|
230 |
$OUTPUT->render_from_template('gradereport_grader/perpage', $perpagedata)
|
| 214 |
, 'col-auto'
|
231 |
, 'col-auto'
|
| 215 |
);
|
232 |
);
|
| Línea 216... |
Línea 233... |
| 216 |
|
233 |
|
| 217 |
// The number of students per page is always limited even if it is claimed to be unlimited.
|
234 |
// The number of students per page is always limited even if it is claimed to be unlimited.
|
| 218 |
$studentsperpage = $studentsperpage ?: grade_report_grader::MAX_STUDENTS_PER_PAGE;
|
235 |
$studentsperpage = $studentsperpage ?: $maxusers;
|
| 219 |
$footercontent .= html_writer::div(
|
236 |
$footercontent .= html_writer::div(
|
| 220 |
$OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl),
|
237 |
$OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl),
|
| 221 |
'col'
|
238 |
'col'
|