Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We've encountered an issue with Quiz where anonymous users are unable to properly jump around a quiz.
Summary
Steps to reproduce:
- Create a quiz that allows anonymous users access and allows jumping with 3 or more questions.
- As anonymous, take the quiz and attempt to jump from question 1 to N (where N >= 3)
- Expected result: Question N is displayed
- Actual Result: Question 2 is displayed
Cause
I found that the issue is in quiz.module in quiz_take_quiz() on line 2004:
// If anonymous user, refresh url with unique hash to prevent caching.
if (!$user->uid && $q_passed_validation === TRUE) {
drupal_goto('node/' . $quiz->nid . '/take', array('query' => array('quizkey' => md5(mt_rand() . REQUEST_TIME))));
}
This code prevents caching of the quiz for anonymous users, however it also issues a redirect before the jump can be acted upon on line 2034:
if (isset($check_jump) && $check_jump) {
if ($quiz->allow_jumping && _quiz_is_int($_POST['jump_to_question'])) {
quiz_jump_to($_POST['jump_to_question'], $quiz, $_SESSION['quiz_' . $quiz->nid]['result_id']);
}
}
Workaround
Commenting out this line remedies the issue, however I don't know if this is an appropriate solution, as a hash is added to te URL, however it does NOT change with each subsequent request.
Comments
Comment #1
djdevinThis issue is being closed because it was filed against a version that is no longer supported.
If the issue still persists in the latest version of Quiz, please open a new issue.