Hi,

At the end of each quiz when the user results are displayed back to them I want to provide a link that allows them to use the Print module to convert it to a pdf.

I noticed that under /sitename/user/ you can access the results by Result ID but I want to be able to access this at the end of the quiz is there a way to get the Result ID of the quiz just taken?

Thanks,

rhughes

Comments

mbutcher’s picture

Well... in Quiz 3 this is pretty easy.

In Quiz 3, there is a hook and an action/trigger implementation, either of which could be used to do what you are asking. I just now checked in a tiny patch that adds result_id to both the do_action() call and the hook_quiz_finished() invocation. Take a look at quiz_end_actions() around line 1120 in quiz.module (From CVS or from today's dev build).

In Quiz 2.... it looks like the result_id *may* stay in the $_SESSION after the quiz is complete. So you might be able get it with something like this: $_SESSION['quiz_'. $quiz->nid]['result_id']

Otherwise, you would have to select result ID from quiz_node_results where uid = (Your user) and then order it by end date. Something like this (untested):

SELECT result_id FROM {quiz_node_results} WHERE vid = %d AND uid = %d ORDER BY time_end DESC

mbutcher’s picture

Status: Active » Closed (fixed)