I am using Quiz module. How can we redirect user to thankyou/someother page after clicking Finish button?
1 Answer
If using Quiz 7.x-5.x
Assuming you're using the 7.x-5.x-rc3 version of the Quiz module, you can take advantage of integration with the Rules module that this new release comes with.
To do so, have a look at the delivered rule, which looks like so:
{ "rules_send_results_at_the_end_of_a_quiz" : {
"LABEL" : "Send quiz results at the end of a quiz",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"OWNER" : "rules",
"TAGS" : [ "quiz" ],
"REQUIRES" : [ "rules", "entity" ],
"ON" : { "quiz_result_update" : [] },
"IF" : [
{ "data_is" : { "data" : [ "quiz-result-unchanged:is-evaluated" ], "value" : "0" } },
{ "data_is" : { "data" : [ "quiz-result:is-evaluated" ], "value" : "1" } }
],
"DO" : [
{ "mail" : {
"to" : [ "quiz-result:uid:mail" ],
"subject" : "[site:name]: Your results for [quiz-result:nid:title]",
"message" : "[quiz-result:uid:name],\r\n\r\nYou finished the quiz [quiz-result:nid:title] on [quiz-result:time-start]\r\n\r\nYour score: [quiz-result:score]%\r\n\r\nYou can access the result here: [site:url]node\/[quiz-result:nid:nid]\/quiz-results\/[quiz-result:result-id]",
"language" : [ "" ]
}
},
{ "mail" : {
"to" : [ "quiz-result:nid:author:mail" ],
"subject" : "[site:name]: [quiz-result:uid:name]\u0027s results for [quiz-result:nid:title]",
"message" : "[quiz-result:nid:author:name],\r\n\r\n[quiz-result:uid:name] finished the quiz [quiz-result:nid:title] on [quiz-result:time-start]\r\n\r\nTheir score: [quiz-result:score]%\r\n\r\nYou can access the result here: [site:url]node\/[quiz-result:nid:nid]\/quiz\/results\/[quiz-result:result-id]\/view",
"language" : [ "" ]
}
}
]
}
}
After you enable Rules (and Rules UI, a submodule of it), just clone the above rule (using the Rules UI) and replace both Rules Actions with a basic "redirect" (a typical Rules Action) that fits your needs.
If using Quiz 7.x-4.x
For the 7.x-4.x version of the Quiz module, you may want to try the patch from fago (aka the Rules maestro ...), attached to issue # 1300420, which has a description like so (note the last phrase in it ...):
... adds basic rules integration to quiz. It includes an event when users have finished taking a quiz, a condition to check whether a user has passed a certain quiz and an action to clear quiz results for a user.
Patch works for me.
-
Thanks for the snippet @pierre, but I am using 7.x-4.0-beta2 version and I cant able to update that module due to some circumstances. Can I still use this?– NTTCommented Aug 15, 2016 at 14:14
-
@Nagarjuna : 2nd try ... see my updated answer ... curious if you can get that to work ... Commented Aug 15, 2016 at 14:32
-
i was busy with some other task. I will surely get back to u. Thanks for the answer.. Cheers– NTTCommented Aug 20, 2016 at 8:07
-
That works. I need to modify the rule condition, for now it is only passed, I need to make another one if is fail. I can manage though. Cheers :)– NTTCommented Aug 26, 2016 at 9:34