From b4f26f1564660b08aab5cdaffa71fd3a4feea344 Mon Sep 17 00:00:00 2001 From: Rajneel Totaram Date: Thu, 20 Apr 2023 18:54:37 +1200 Subject: [PATCH] MDL-71728 mod_quiz: check if user can access this page --- mod/quiz/processattempt.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mod/quiz/processattempt.php b/mod/quiz/processattempt.php index 50dba84d6ee..bd15d5642ae 100644 --- a/mod/quiz/processattempt.php +++ b/mod/quiz/processattempt.php @@ -85,6 +85,12 @@ if ($attemptobj->is_finished()) { 'attemptalreadyclosed', null, $attemptobj->review_url()); } +// If this page cannot be accessed, notify user and send them to the correct page. +if (!$finishattempt && !$attemptobj->check_page_access($thispage)) { + throw new moodle_exception('submissionoutofsequencefriendlymessage', 'question', + $attemptobj->attempt_url(null, $attemptobj->get_currentpage())); +} + // Process the attempt, getting the new status for the attempt. $status = $attemptobj->process_attempt($timenow, $finishattempt, $timeup, $thispage);