Permalink
Browse files

MDL-31910 Quiz : Error on Manual Grading report

  • Loading branch information...
1 parent 66e23d6 commit 52b26f8a5be86dbd50631f3bf97b9f9da5ec4291 @mkassaei mkassaei committed with nebgor Mar 9, 2012
Showing with 20 additions and 19 deletions.
  1. +20 −19 mod/quiz/report/grading/report.php
@@ -126,19 +126,36 @@ public function display($quiz, $cm, $course) {
$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) {
$this->display_index($includeauto);
} 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 @@ protected function display_index($includeauto) {
}
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;
}

0 comments on commit 52b26f8

Please sign in to comment.