MDL-34733 quiz 'secure' mode: finish review link broken in previews

This fix a small API change in mod_quiz_renderer::finish_review_link.
At least the required change is an improvement, since it gives the
renderer more flexibility.
This commit is contained in:
Tim Hunt 2012-08-13 13:48:22 +01:00
parent c92d6f417c
commit d869de66a6
3 changed files with 20 additions and 6 deletions

View File

@ -1687,7 +1687,7 @@ class quiz_review_nav_panel extends quiz_nav_panel_base {
get_string('showall', 'quiz'));
}
}
$html .= $output->finish_review_link($this->attemptobj->view_url());
$html .= $output->finish_review_link($this->attemptobj);
$html .= $this->render_restart_preview_link($output);
return $html;
}

View File

@ -226,16 +226,18 @@ class mod_quiz_renderer extends plugin_renderer_base {
/**
* Returns either a liink or button
*
* @param $url contains a url for the review link
* @param quiz_attempt $attemptobj instance of quiz_attempt
*/
public function finish_review_link($url) {
if ($this->page->pagelayout == 'popup') {
// In a 'secure' popup window.
public function finish_review_link(quiz_attempt $attemptobj) {
$url = $attemptobj->view_url();
if ($attemptobj->get_access_manager(time())->attempt_must_be_in_popup()) {
$this->page->requires->js_init_call('M.mod_quiz.secure_window.init_close_button',
array($url), quiz_get_js_module());
return html_writer::empty_tag('input', array('type' => 'button',
'value' => get_string('finishreview', 'quiz'),
'id' => 'secureclosebutton'));
} else {
return html_writer::link($url, get_string('finishreview', 'quiz'));
}
@ -250,7 +252,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
*/
public function review_next_navigation(quiz_attempt $attemptobj, $page, $lastpage) {
if ($lastpage) {
$nav = $this->finish_review_link($attemptobj->view_url());
$nav = $this->finish_review_link($attemptobj);
} else {
$nav = link_arrow_right(get_string('next'), $attemptobj->review_url(null, $page + 1));
}

12
mod/quiz/upgrade.txt Normal file
View File

@ -0,0 +1,12 @@
This files describes API changes in the quiz code.
=== 2.4 ===
* mod_quiz_renderer::finish_review_link now requires $attemptobj to be passed in
instead of a moodle_url.
=== Earlier changes ===
* Were not documented in this way. Sorry.