MDL-28424 Reviewing a quiz in 'secure mode' gives a fatal error.

The problem was when output was being started in relation to when the fake block was added.

Took the opportunity to clean up the quiz renderer API a bit.
This commit is contained in:
Tim Hunt
2011-09-21 16:41:36 +01:00
parent 136fa79e34
commit e6674da8ff
5 changed files with 12 additions and 20 deletions
+1 -3
View File
@@ -723,12 +723,11 @@ class password_access_rule extends quiz_access_rule_base {
$PAGE->set_title($this->_quizobj->get_course()->shortname . ': ' .
format_string($this->_quizobj->get_quiz_name()));
$PAGE->set_cacheable(false);
echo $OUTPUT->header();
} else {
$PAGE->set_title(format_string($this->_quizobj->get_quiz_name()));
echo $OUTPUT->header();
}
echo $OUTPUT->header();
if (trim(strip_tags($this->_quiz->intro))) {
$output .= $OUTPUT->box(format_module_intro('quiz', $this->_quiz,
$this->_quizobj->get_cmid()), 'generalbox', 'intro');
@@ -838,7 +837,6 @@ class securewindow_access_rule extends quiz_access_rule_base {
$PAGE->add_body_class('quiz-secure-window');
$PAGE->requires->js_init_call('M.mod_quiz.secure_window.init', null, false,
quiz_get_js_module());
echo $OUTPUT->header();
}
}
+1 -5
View File
@@ -114,11 +114,9 @@ if ($accessmanager->securewindow_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_last_page($page)) {
@@ -127,7 +125,5 @@ if ($attemptobj->is_last_page($page)) {
$nextpage = $page + 1;
}
echo $output->attempt_page($attemptobj, $page, $accessmanager, $messages, $slots, $id, $nextpage);
$accessmanager->show_attempt_timer_if_needed($attemptobj->get_attempt(), time());
echo $OUTPUT->footer();
echo $output->attempt_page($attemptobj, $page, $accessmanager, $messages, $slots, $id, $nextpage);
+1 -1
View File
@@ -113,7 +113,7 @@ M.mod_quiz.timer = {
var minutes = Math.floor(secondsleft/60);
secondsleft -= minutes*60;
var seconds = secondsleft;
Y.one('#quiz-time-left').setContent('' + hours + ':' +
Y.one('#quiz-time-left').setContent(hours + ':' +
M.mod_quiz.timer.two_digit(minutes) + ':' +
M.mod_quiz.timer.two_digit(seconds));
+7 -1
View File
@@ -259,7 +259,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
* @return string HTML content.
*/
public function countdown_timer() {
return html_writer::tag('div', get_string('timeleft', 'quiz') .
return html_writer::tag('div', get_string('timeleft', 'quiz') . ' ' .
html_writer::tag('span', '', array('id' => 'quiz-time-left')),
array('id' => 'quiz-timer'));
}
@@ -376,8 +376,10 @@ class mod_quiz_renderer extends plugin_renderer_base {
public function attempt_page($attemptobj, $page, $accessmanager, $messages, $slots, $id,
$nextpage) {
$output = '';
$output .= $this->header();
$output .= $this->quiz_notices($messages);
$output .= $this->attempt_form($attemptobj, $page, $slots, $id, $nextpage);
$output .= $this->footer();
return $output;
}
@@ -479,8 +481,12 @@ class mod_quiz_renderer extends plugin_renderer_base {
*/
public function summary_page($attemptobj, $displayoptions) {
$output = '';
$output .= $this->header();
$output .= $this->heading(format_string($attemptobj->get_quiz_name()));
$output .= $this->heading(get_string('summaryofattempt', 'quiz'), 3);
$output .= $this->summary_table($attemptobj, $displayoptions);
$output .= $this->summary_page_controls($attemptobj);
$output .= $this->footer();
return $output;
}
+2 -10
View File
@@ -77,7 +77,6 @@ if (empty($attemptobj->get_quiz()->showblocks)) {
$PAGE->blocks->show_only_fake_blocks();
}
$title = get_string('summaryofattempt', 'quiz');
if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) {
$accessmanager->setup_secure_page($attemptobj->get_course()->shortname . ': ' .
format_string($attemptobj->get_quiz_name()), '');
@@ -86,20 +85,13 @@ if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) {
format_string($attemptobj->get_quiz_name()));
$PAGE->set_heading($attemptobj->get_course()->fullname);
$PAGE->set_cacheable(false);
echo $OUTPUT->header();
} else {
$PAGE->navbar->add($title);
$PAGE->navbar->add(get_string('summaryofattempt', 'quiz'));
$PAGE->set_title(format_string($attemptobj->get_quiz_name()));
$PAGE->set_heading($attemptobj->get_course()->fullname);
echo $OUTPUT->header();
}
// Print heading.
echo $OUTPUT->heading(format_string($attemptobj->get_quiz_name()));
echo $OUTPUT->heading($title, 3);
echo $output->summary_page($attemptobj, $displayoptions);
// Finish the page
$accessmanager->show_attempt_timer_if_needed($attemptobj->get_attempt(), time());
echo $OUTPUT->footer();
echo $output->summary_page($attemptobj, $displayoptions);