diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index a6c546ecff804..8ef3e782d0f7a 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -103,71 +103,6 @@ $firstregion = reset($PAGE->blocks->get_regions()); $PAGE->blocks->add_fake_block($navbc, $firstregion); -// Print the page header -$title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number()); -$headtags = $attemptobj->get_html_head_contributions($page); -$PAGE->set_heading($attemptobj->get_course()->fullname); -if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { - $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' . - format_string($attemptobj->get_quiz_name())); - -} else if ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) { - $PAGE->set_title($attemptobj->get_course()->shortname . ': ' . - format_string($attemptobj->get_quiz_name())); - $PAGE->set_cacheable(false); - echo $OUTPUT->header(); - -} else { - $PAGE->set_title(format_string($attemptobj->get_quiz_name())); - echo $OUTPUT->header(); -} - -if ($attemptobj->is_preview_user() && $messages) { - // Inform teachers of any restrictions that would apply to students at this point. - echo $OUTPUT->box_start('quizaccessnotices'); - echo $OUTPUT->heading(get_string('accessnoticesheader', 'quiz'), 3); - $accessmanager->print_messages($messages); - echo $OUTPUT->box_end(); -} - -// Start the form -echo '
\n"; - -// Finish the page -$accessmanager->show_attempt_timer_if_needed($attemptobj->get_attempt(), time()); -echo $OUTPUT->footer(); +$output->attempt_page($attemptobj, $page, $accessmanager, $messages, $slots, $id); diff --git a/mod/quiz/renderer.php b/mod/quiz/renderer.php index 75a862dd48fb5..b988b82910c05 100644 --- a/mod/quiz/renderer.php +++ b/mod/quiz/renderer.php @@ -32,7 +32,7 @@ */ class mod_quiz_renderer extends plugin_renderer_base { public function review_page(quiz_attempt $attemptobj, $slots, $page, $showall, - $lastpage, mod_quiz_display_options $displayoptions, $summarydata) { + $lastpage, mod_quiz_display_options $displayoptions, $summarydata) { $output = ''; $output .= $this->header(); @@ -237,6 +237,99 @@ protected function render_mod_quiz_links_to_other_attempts( } return implode(', ', $attemptlinks); } + + /* + * Attempt Page + */ + public function attempt_page($attemptobj, $page, $accessmanager, $messages, $slots, $id){ + $output = ''; + $output .= $this->attempt_header($attemptobj, $page, $accessmanager); + $output .= $this->quiz_notices($attemptobj, $accessmanager, $messages); + $output .= $this->attempt_form($attemptobj, $page, $slots, $id); + $output .= $this->attempt_footer($attemptobj, $accessmanager); + return $output; + } + + protected function attempt_header($attemptobj, $page, $accessmanager){ + global $PAGE, $OUTPUT; + + $title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number()); + $headtags = $attemptobj->get_html_head_contributions($page); + $PAGE->set_heading($attemptobj->get_course()->fullname); + if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) { + $accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' . + format_string($attemptobj->get_quiz_name())); + + } else if ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) { + $PAGE->set_title($attemptobj->get_course()->shortname . ': ' . + format_string($attemptobj->get_quiz_name())); + $PAGE->set_cacheable(false); + echo $OUTPUT->header(); + + } else { + $PAGE->set_title(format_string($attemptobj->get_quiz_name())); + echo $OUTPUT->header(); + } + } + + + private function quiz_notices($attemptobj, $accessmanager, $messages){ + if ($attemptobj->is_preview_user() && $messages) { + // Inform teachers of any restrictions that would apply to students at this point. + echo $OUTPUT->box_start('quizaccessnotices'); + echo $OUTPUT->heading(get_string('accessnoticesheader', 'quiz'), 3); + $accessmanager->print_messages($messages); + echo $OUTPUT->box_end(); + } + } + + private function attempt_form($attemptobj, $page, $slots, $id){ + // Start the form + //TODO: Convert all html to html:writer + echo '\n"; + } + + protected function attempt_footer($attemptobj, $accessmanager){ + global $OUTPUT; + + $accessmanager->show_attempt_timer_if_needed($attemptobj->get_attempt(), time()); + echo $OUTPUT->footer(); + } }