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))));
}
| Comment | File | Size | Author |
|---|---|---|---|
| quiz-anonymous_validation-1.patch | 444 bytes | philipnorton42 |
Comments
Comment #1
falcon commentedComment #2
sivaji_ganesh_jojodae commentedI 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))
Comment #2.0
sivaji_ganesh_jojodae commentedAdded more clarity to code change (ie. which file was being changed).
Comment #3
djdevin