From 660fa2871ac5ac154cd2ddec50d3dbbf5b4ee4e1 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 22 Apr 2020 21:04:09 +0100 Subject: [PATCH] MDL-57240 quiz: don't show useless links on overdue attempt summary page --- mod/quiz/attemptlib.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 743fcbf7e92..21ca63247a5 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -1092,6 +1092,12 @@ class quiz_attempt { * @return bool true if the navigation should be allowed. */ public function can_navigate_to($slot) { + if ($this->attempt->state == self::OVERDUE) { + // When the attempt is overdue, students can only see the + // attempt summary page and cannot navigate anywhere else. + return false; + } + switch ($this->get_navigation_method()) { case QUIZ_NAVMETHOD_FREE: return true; @@ -2783,6 +2789,10 @@ class quiz_attempt_nav_panel extends quiz_nav_panel_base { } public function render_end_bits(mod_quiz_renderer $output) { + if ($this->page == -1) { + // Don't link from the summary page to itself. + return ''; + } return html_writer::link($this->attemptobj->summary_url(), get_string('endtest', 'quiz'), array('class' => 'endtestlink')) . $output->countdown_timer($this->attemptobj, time()) .