mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-68970 quiz: prevent page caching during attempts
This ensures that the page reloads if the student uses the Back or Forwards buttons within an attempt. This avoids questions being in a stale state, or the timer showing the wrong time. Thanks to Jake Dallimore and Russell Boyatt for suggestions which lead to this fix.
This commit is contained in:
parent
fd840ab59c
commit
bdbe3cd268
@ -454,7 +454,6 @@ class quizaccess_seb extends quiz_access_rule_base {
|
||||
*/
|
||||
public function setup_attempt_page($page) {
|
||||
$page->set_title($this->quizobj->get_course()->shortname . ': ' . $page->title);
|
||||
$page->set_cacheable(false);
|
||||
$page->set_popup_notification_allowed(false); // Prevent message notifications.
|
||||
$page->set_heading($page->title);
|
||||
$page->set_pagelayout('secure');
|
||||
|
@ -72,7 +72,6 @@ class quizaccess_securewindow extends quiz_access_rule_base {
|
||||
public function setup_attempt_page($page) {
|
||||
$page->set_popup_notification_allowed(false); // Prevent message notifications.
|
||||
$page->set_title($this->quizobj->get_course()->shortname . ': ' . $page->title);
|
||||
$page->set_cacheable(false);
|
||||
$page->set_pagelayout('secure');
|
||||
|
||||
if ($this->quizobj->is_preview_user()) {
|
||||
|
@ -44,6 +44,8 @@ $cmid = optional_param('cmid', null, PARAM_INT);
|
||||
$attemptobj = quiz_create_attempt_handling_errors($attemptid, $cmid);
|
||||
$page = $attemptobj->force_page_number_into_range($page);
|
||||
$PAGE->set_url($attemptobj->attempt_url(null, $page));
|
||||
// During quiz attempts, the browser back/forwards buttons should force a reload.
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
// Check login.
|
||||
require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
|
||||
|
@ -44,6 +44,8 @@ if (!$course = $DB->get_record('course', array('id' => $cm->course))) {
|
||||
$quizobj = quiz::create($cm->instance, $USER->id);
|
||||
// This script should only ever be posted to, so set page URL to the view page.
|
||||
$PAGE->set_url($quizobj->view_url());
|
||||
// During quiz attempts, the browser back/forwards buttons should force a reload.
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
// Check login and sesskey.
|
||||
require_login($quizobj->get_course(), false, $quizobj->get_cm());
|
||||
|
@ -30,6 +30,8 @@ $attemptid = required_param('attempt', PARAM_INT); // The attempt to summarise.
|
||||
$cmid = optional_param('cmid', null, PARAM_INT);
|
||||
|
||||
$PAGE->set_url('/mod/quiz/summary.php', array('attempt' => $attemptid));
|
||||
// During quiz attempts, the browser back/forwards buttons should force a reload.
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$attemptobj = quiz_create_attempt_handling_errors($attemptid, $cmid);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user