How to Disable Show All Questions on One Page

Re: How to Disable Show All Questions on One Page

by Rashad Raza -
Number of replies: 0
Hi Tim Hunt

I could see that you have previously suggested Max Monclair to use the following:

at the top of review.php, just after $showall = optional_param(...) just add a new line $showall = false.
in attemptlib.php, right at the end, in render_end_bits change
if ($this->attemptobj->get_num_pages() > 1) {
to something like
if (false && $this->attemptobj->get_num_pages() > 1) {

I can now remember that I used the same in past and it worked very well. However after the recent upgrade it does not seem to be working. I may be doing something wrong. This is what I have done to get rid of 'Show all questions on one page' option:

REVIEW PHP
require_once(__DIR__ . '/../../config.php');
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php');

$attemptid = required_param('attempt', PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
$showall = optional_param('showall', null, PARAM_BOOL);
$showall = false.
$cmid = optional_param('cmid', null, PARAM_INT);

$url = new moodle_url('/mod/quiz/review.php', array('attempt'=>$attemptid));
if ($page !== 0) {
$url->param('page', $page);
} else if ($showall) {
$url->param('showall', $showall);
}


ATTEMPTLIB.PHP
public function render_end_bits(mod_quiz_renderer $output) {
$html = '';
if (false && $this->attemptobj->get_num_pages() > 1) {
if ($this->showall) {
$html .= html_writer::link($this->attemptobj->review_url(null, 0, false),
get_string('showeachpage', 'quiz'));
} else {
$html .= html_writer::link($this->attemptobj->review_url(null, 0, true),
get_string('showall', 'quiz'));
}
}
$html .= $output->finish_review_link($this->attemptobj);
$html .= $this->render_restart_preview_link($output);
return $html;
}
}

Could you please suggest me if i am doing something wrong?