Calculating quiz score for validation I'm not using the Quiz module; I am using Webform and Drupal 7.

I have created a quiz that, if passed, assigns the user a new role. Currently, I use validation rules to simply prevent wrong answers from validating; all questions must be answered correctly before the user can proceed.

I need to change this to allow users with a score of 80% or higher to proceed to the next quiz. I know that I can do that with the quiz module. However I also need to be able to show correct answers for missed questions only to users who scored between 80% and 100%. Those scoring below 80% may not see any answer key.

What is the best way to go about this?
I am solving this problem by disabling Quiz and using only Webform, and writing a custom module that does the following:


use hook_form_alter to catch webform submissions
compare them to fields in an answer key

answer keys are of content type 'answer key'
they have a node reference field that references a webform

calculate percent that match
display a message depending on score

if 80% &lt; x &lt; 100% display answers
if 80% &lt; x return that the quiz was passed
if 80% > x tell them they failed and redirect them back to the quiz page to re-take the test.