diff --git a/details.php b/details.php index f78d738..6642549 100644 --- a/details.php +++ b/details.php @@ -55,13 +55,16 @@ if ($mform->is_cancelled()) { $attempt_table = new html_table(); $attempt_table->head = array(get_string('question', 'report_usergrades'), get_string('response', 'report_usergrades'), get_string('grade', 'report_usergrades')); - foreach ($quiz_questions as $quiz_question) { - $question = $questions[$quiz_question->question]; + $question_usages = $DB->get_records('question_usages', array('id' => $quiz_attempt->uniqueid)); + + foreach ($question_usages as $question_usage) { + $question_attempt = $DB->get_record('question_attempts', array('questionusageid' => $question_usage->id)); + $question = $questions[$question_attempt->questionid]; + $response = $question_attempt->responsesummary; - $response = $DB->get_record('question_states', array('attempt' => $attempt->id, 'question' => $question->id)); - $grade = $DB->get_record('question_attempt_steps', array('questionattemptid' => $response->id)); + $question_grade = $DB->get_record('question_attempt_steps', array('questionattemptid' => $question_attempt->id)); - $attempt_table->data[] = array($question->name, $response->answer, $grade->fraction); + $attempt_table->data[] = array($question->name, $response, $question_grade->fraction); } echo html_writer::table($attempt_table);