Here's what I'm trying to accomplish:

The user takes a quiz (through the quiz module - http://drupal.org/project/quiz). Once he completes the quiz, he should be automatically taken to another page which gives him a reward:

- Download an ebook
-Automatically email him with the download location for the eBook
-Provide him with badges that he can embed in his blog/website

I'm also hoping this can be done for other content as well. For instance, I want a user to be rewarded once they view a number of content on the site.

This is for a travel site; please suggest how I go about achieving this.

Thanks.

Comments

anijmeh’s picture

For the quiz award your best bet is to impliment the hook quiz_finished with something similar to this.

function mymodule_quiz_finished($quiz, $score, $rid) {
global $user;

if ($user->uid && quiz_is_passed($user->uid, $quiz->nid, $quiz->vid) ) {
drupal_mail(..)..... email user nessessary details
drupal_set_message(t('You have passed this quiz! Please check your email to access your award'), 'status');
}
else {
// if quiz did not pass... do something else
}

}

I don't think you can redirect using this hook since it's parent function quiz_end_actions() needs to return the score of the quiz. You can however manage to send out an email with all the details.

An better but slightly more sophisticated approach would be define an action using hook_action_info() since each quiz can be assigned an action to perform after a quiz has been completed.

You can achive a similar a result with other node types by using hook_view(). You might also want to look into the points module with rules.