MDL-31910 Quiz : Error on Manual Grading report

This commit is contained in:
M Kassaei
2012-03-13 10:13:27 +08:00
committed by Aparup Banerjee
parent e281281b84
commit 137d60b66f
+20 -19
View File
@@ -126,11 +126,28 @@ class quiz_grading_report extends quiz_default_report {
$this->currentgroup, '', false);
}
$questionsinquiz = quiz_questions_in_quiz($quiz->questions);
$counts = null;
if ($slot && $questionsinquiz) {
// Make sure there is something to do.
$statecounts = $this->get_question_state_summary(array($slot));
foreach ($statecounts as $record) {
if ($record->questionid == $questionid) {
$counts = $record;
break;
}
}
// If not, redirect back to the list.
if (!$counts || $counts->$grade == 0) {
redirect($this->list_questions_url(), get_string('alldoneredirecting', 'quiz_grading'));
}
}
// Start output.
$this->print_header_and_tabs($cm, $course, $quiz, 'grading');
// What sort of page to display?
if (!quiz_questions_in_quiz($quiz->questions)) {
if (!$questionsinquiz) {
echo quiz_no_questions_message($quiz, $cm, $this->context);
} else if (!$slot) {
@@ -138,7 +155,7 @@ class quiz_grading_report extends quiz_default_report {
} else {
$this->display_grading_interface($slot, $questionid, $grade,
$pagesize, $page, $shownames, $showidnumbers, $order);
$pagesize, $page, $shownames, $showidnumbers, $order, $counts);
}
return true;
}
@@ -313,25 +330,9 @@ class quiz_grading_report extends quiz_default_report {
}
protected function display_grading_interface($slot, $questionid, $grade,
$pagesize, $page, $shownames, $showidnumbers, $order) {
$pagesize, $page, $shownames, $showidnumbers, $order, $counts) {
global $OUTPUT;
// Make sure there is something to do.
$statecounts = $this->get_question_state_summary(array($slot));
$counts = null;
foreach ($statecounts as $record) {
if ($record->questionid == $questionid) {
$counts = $record;
break;
}
}
// If not, redirect back to the list.
if (!$counts || $counts->$grade == 0) {
redirect($this->list_questions_url(), get_string('alldoneredirecting', 'quiz_grading'));
}
if ($pagesize * $page >= $counts->$grade) {
$page = 0;
}