public function MatchingResponse::getReportFormResponse in Quiz 6.4
Same name and namespace in other branches
- 7 question_types/matching/matching.classes.inc \MatchingResponse::getReportFormResponse()
- 7.4 question_types/matching/matching.classes.inc \MatchingResponse::getReportFormResponse()
Implementation of getReportFormResponse
Overrides QuizQuestionResponse::getReportFormResponse
See also
QuizQuestionResponse#getReportFormResponse($showpoints, $showfeedback, $allow_scoring)
File
- question_types/
matching/ matching.classes.inc, line 446 - matching.classes
Class
- MatchingResponse
- Extension of QuizQuestionResponse
Code
public function getReportFormResponse($showpoints = TRUE, $showfeedback = TRUE, $allow_scoring = FALSE) {
$data = $metadata = array();
// Build the question answers header (add blank space for IE).
$metadata[] = t('Match');
if ($showpoints) {
$metadata[] = t('Correct Answer');
}
$metadata[] = t('User answer');
if ($showfeedback) {
$metadata[] = t('Feedback');
}
$MatchingQuestion = new MatchingQuestion($this->question);
$correct_answers = $MatchingQuestion
->getCorrectAnswer();
$user_answers = isset($this->answer['answer']) ? $this->answer['answer'] : $this->answer;
foreach ($correct_answers as $correct_answer) {
$answer_data = array();
$id = $user_answers[$correct_answer['match_id']];
$correct = isset($correct_answers[$id]) && $correct_answer['answer'] == $correct_answers[$id]['answer'];
$answer_data['question'] = check_markup($correct_answer['question'], $this->question->format, FALSE);
if ($showpoints) {
$answer_data['correct_answer'] = check_markup($correct_answer['answer'], $this->question->format, FALSE);
}
$answer_data['user_answer'] = isset($correct_answers[$id]) ? check_markup($correct_answers[$id]['answer'], $this->question->format, FALSE) : NULL;
if ($showfeedback) {
$answer_data['feedback'] = check_markup($correct_answer['feedback'], $this->question->format, FALSE);
$answer_data['is_correct'] = $correct;
}
$data[] = $answer_data;
}
return array(
'#type' => 'markup',
'#value' => theme('matching_response', $metadata, $data),
);
}