diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index bbf636e7129..fcd35658fa8 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -197,8 +197,6 @@ function quiz_print_question_list($quiz, $allowdelete=true, $showbreaks=true) { return; } - $order = explode(",", $quiz->questions); - if (!$questions = get_records_sql("SELECT q.*,c.course FROM {$CFG->prefix}quiz_questions q, {$CFG->prefix}quiz_categories c @@ -213,7 +211,13 @@ function quiz_print_question_list($quiz, $allowdelete=true, $showbreaks=true) { $count = 0; $qno = 1; $sumgrade = 0; - $total = count($order); + $order = explode(",", $quiz->questions); + $lastindex = count($order)-1; + // If the list does not end with a pagebreak then add it on. + if ($order[$lastindex] != 0) { + $order[] = 0; + $lastindex++; + } echo "
"; echo "sesskey\" />"; @@ -229,12 +233,12 @@ function quiz_print_question_list($quiz, $allowdelete=true, $showbreaks=true) { echo '
'; echo 'Page break'; echo '
'; - if ($count != 1) { + if ($count > 1) { echo "sesskey\">\"$strmoveup\""; } echo ' '; - if ($count < $total-1) { + if ($count < $lastindex) { echo "sesskey\">\"$strmovedown\""; @@ -261,7 +265,7 @@ function quiz_print_question_list($quiz, $allowdelete=true, $showbreaks=true) { } echo ""; echo ""; - if ($count != $total-2) { + if ($count < $lastindex-1) { echo "sesskey\">\"$strmovedown\""; }