Problem/Motivation

When an anonymous user is taking a quiz they never see any status messages telling them about quiz question validation problems. This is because the user is redirected via drupal_goto() before the drupal_set_message() call that sends the validation message to the session.

Proposed resolution

Essentially, a call to drupal_set_message() should also be placed before the call to drupal_goto(), which stops code execution.

Remaining tasks

I think the patch attached is pretty simple. If everything checks out with the module maintainers then please apply it :)

User interface changes

Just that anonymous users now receive indication as to why they can't progress through the quiz if the question they are on fails to validate.

API changes

Line 1993 of quiz.module is changed here.
Code before:

      // Avoid caching for anonymous users
      if (!$user->uid) {
        drupal_goto('node/' . $quiz->nid . '/take', array('query' => array('quizkey' => md5(mt_rand() . REQUEST_TIME))));
      }

Code after

      // Avoid caching for anonymous users
      if (!$user->uid) {
        drupal_set_message($q_passed_validation, 'error');        
        drupal_goto('node/' . $quiz->nid . '/take', array('query' => array('quizkey' => md5(mt_rand() . REQUEST_TIME))));
      }
CommentFileSizeAuthor
quiz-anonymous_validation-1.patch444 bytesphilipnorton42

Comments

falcon’s picture

Status: Active » Needs review
sivaji_ganesh_jojodae’s picture

Status: Needs review » Needs work
drupal_goto('node/' . $quiz->nid . '/take', array('query' => array('quizkey' => md5(mt_rand() . REQUEST_TIME))));

I think, ideally the whole drupal_goto() with quizkey in quiz_take_quiz() to be removed because now we have API in place to disable page cache (drupal_page_is_cacheable(FALSE))

sivaji_ganesh_jojodae’s picture

Issue summary: View changes

Added more clarity to code change (ie. which file was being changed).

djdevin’s picture

Status: Needs work » Closed (outdated)