diff --git a/mod/quiz/renderer.php b/mod/quiz/renderer.php index 855a7e9882e..17eed1fa090 100644 --- a/mod/quiz/renderer.php +++ b/mod/quiz/renderer.php @@ -56,7 +56,7 @@ class mod_quiz_renderer extends plugin_renderer_base { $this->questions($attemptobj, true, $slots, $page, $showall, $displayoptions), $attemptobj); - $output .= $this->review_next_navigation($attemptobj, $page, $lastpage); + $output .= $this->review_next_navigation($attemptobj, $page, $lastpage, $showall); $output .= $this->footer(); return $output; } @@ -256,18 +256,22 @@ class mod_quiz_renderer extends plugin_renderer_base { * @param quiz_attempt $attemptobj instance of quiz_attempt * @param int $page the current page * @param bool $lastpage if true current page is the last page + * @param bool|null $showall if true, the URL will be to review the entire attempt on one page, + * and $page will be ignored. If null, a sensible default will be chosen. + * + * @return string HTML fragment. */ - public function review_next_navigation(quiz_attempt $attemptobj, $page, $lastpage) { + public function review_next_navigation(quiz_attempt $attemptobj, $page, $lastpage, $showall = null) { $nav = ''; if ($page > 0) { $nav .= link_arrow_left(get_string('navigateprevious', 'quiz'), - $attemptobj->review_url(null, $page - 1), false, 'mod_quiz-prev-nav'); + $attemptobj->review_url(null, $page - 1, $showall), false, 'mod_quiz-prev-nav'); } if ($lastpage) { $nav .= $this->finish_review_link($attemptobj); } else { $nav .= link_arrow_right(get_string('navigatenext', 'quiz'), - $attemptobj->review_url(null, $page + 1), false, 'mod_quiz-next-nav'); + $attemptobj->review_url(null, $page + 1, $showall), false, 'mod_quiz-next-nav'); } return html_writer::tag('div', $nav, array('class' => 'submitbtns')); } diff --git a/mod/quiz/tests/behat/attempt_basic.feature b/mod/quiz/tests/behat/attempt_basic.feature index f8ff46b341f..cd1fcc9e7ad 100644 --- a/mod/quiz/tests/behat/attempt_basic.feature +++ b/mod/quiz/tests/behat/attempt_basic.feature @@ -115,20 +115,29 @@ Feature: Attemp a quiz where some questions require that the previous question h And I follow "Quiz 1" And I press "Attempt quiz now" Then I should see "Text of the first question" + And I should not see "Text of the second question" And I press "Next page" And I should see "Text of the second question" + And I should not see "Text of the first question" And I click on "Finish attempt ..." "button" in the "region-main" "region" And I should see "Summary of attempt" And I press "Return to attempt" And I should see "Text of the second question" + And I should not see "Text of the first question" And I press "Previous page" And I should see "Text of the first question" + And I should not see "Text of the second question" And I follow "Finish attempt ..." And I press "Submit all and finish" And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue" + And I should see "Text of the first question" + And I should see "Text of the second question" And I follow "Show one page at a time" And I should see "Text of the first question" + And I should not see "Text of the second question" And I follow "Next page" And I should see "Text of the second question" + And I should not see "Text of the first question" And I follow "Previous page" And I should see "Text of the first question" + And I should not see "Text of the second question" diff --git a/mod/quiz/upgrade.txt b/mod/quiz/upgrade.txt index d3828d1afc7..c0064297c27 100644 --- a/mod/quiz/upgrade.txt +++ b/mod/quiz/upgrade.txt @@ -12,6 +12,9 @@ This files describes API changes in the quiz code. * The third argument to mod_quiz_renderer::start_attempt_button has been changed from a warning string to a mod_quiz_preflight_check_form. +* mod_quiz_renderer::review_next_navigation has a new optional argument. If you + have overridden that method, consider updating your code to match. + === 2.9 ===