Revert "MDL-34257 quiz 'secure' mode: PAGE initialisation order issues."
[moodle.git] / mod / quiz / attempt.php
index 1cbda08..135ae14 100644 (file)
@@ -76,9 +76,8 @@ if ($attemptobj->is_finished()) {
 
 // Check the access rules.
 $accessmanager = $attemptobj->get_access_manager(time());
-$accessmanager->setup_attempt_page($PAGE);
-$output = $PAGE->get_renderer('mod_quiz');
 $messages = $accessmanager->prevent_access();
+$output = $PAGE->get_renderer('mod_quiz');
 if (!$attemptobj->is_preview_user() && $messages) {
     print_error('attempterror', 'quiz', $attemptobj->view_url(),
             $output->access_messages($messages));
@@ -121,6 +120,7 @@ $title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number());
 $headtags = $attemptobj->get_html_head_contributions($page);
 $PAGE->set_title(format_string($attemptobj->get_quiz_name()));
 $PAGE->set_heading($attemptobj->get_course()->fullname);
+$accessmanager->setup_attempt_page($PAGE);
 
 if ($attemptobj->is_last_page($page)) {
     $nextpage = -1;