i'm overriding theme_quiz_result because i feel the output is too verbose for my purposes. but i cant figure how to get the user's answer choice from there. $variables can yield which answer is correct but not which answer was chosen. any help please?

Comments

djdevin’s picture

Since the result page is also the grading form (which may no longer be the case soon) it complicates things.

In that theme function you do have the $questions array but you will most likely have to do some manual work to get the chose answer out, because it gets passed to a form building function.

There is a method on each question response called "getReportFormResponse" which returns a standardized array for the display of feedback so you may be able to try that.

$instance = _quiz_question_response_get_instance($result_id, $question_node);
$response = $instance->getReportFormResponse();

It's a hacky solution but I think it will have to do for now until we make that theme function more flexible so that the response data is directly available. Note that $response will include all question feedback regardless of the feedback settings on the quiz.

docwilmot’s picture

getting "Class name must be a valid object or a string" for line 739 in quiz_question.module when i run this code. 739 is

  $to_return = new $constructor($result_id, $question, $answer);