function theme_quiz_feedback in Quiz 5
Same name and namespace in other branches
- 5.2 quiz.module \theme_quiz_feedback()
- 6.6 quiz.pages.inc \theme_quiz_feedback()
- 6.2 quiz.pages.inc \theme_quiz_feedback()
- 6.3 quiz.pages.inc \theme_quiz_feedback()
- 6.5 quiz.pages.inc \theme_quiz_feedback()
Theme the question feedback
Parameters
$questions: Array of quiz objects as returned by _quiz_get_answers
showpoints: Binary flag for whether to show the actual answers
$showfeedback: binary flag for whether to show question feedback
Return value
Themed html
3 theme calls to theme_quiz_feedback()
- theme_quiz_admin_summary in ./
quiz.module - Theme the summary page for admins
- theme_quiz_take_summary in ./
quiz.module - Theme the summary page after the quiz has been completed
- theme_quiz_user_summary in ./
quiz.module - Theme the summary page for user results
File
- ./
quiz.module, line 1854 - Quiz Module
Code
function theme_quiz_feedback($questions, $showpoints = TRUE, $showfeedback = FALSE) {
$rows = array();
$header = array(
t('Question Result(s)'),
'',
);
// go through each of the questions
while (list($key, $question) = each($questions)) {
// reset the cols array
$cols = array();
// Get the answer table for this question
$question['qanswer'] = unserialize($question['qanswer']);
$result = module_invoke($question['type'], 'calculate_results', $question['qanswer']['answers'], $question['qanswer']['tried'], $showpoints, $showfeedback);
// Build the question answers header (add blank space for IE)
$innerheader = array(
t('Answers'),
);
if ($showpoints) {
$innerheader[] = t('Correct Answer');
}
$innerheader[] = t('User Answer');
if ($showfeedback) {
$innerheader[] = ' ';
}
// Add the cell with the question and the answers
$q_output = '<div class="quiz_summary_question"><span class="quiz_question_bullet">Q:</span> ' . check_markup($question['question']) . '</div>';
$q_output .= theme('table', $innerheader, $result['resultstable']) . '<br />';
$cols[] = array(
'data' => $q_output,
'class' => 'quiz_summary_qcell',
);
// Get the score result for each question.
if ($result['score'] == 1) {
$cols[] = array(
'data' => theme('quiz_score_correct'),
'class' => 'quiz_summary_qcell',
);
}
else {
$cols[] = array(
'data' => theme('quiz_score_incorrect'),
'class' => 'quiz_summary_qcell',
);
}
// pack all of this into this row
$rows[] = array(
'data' => $cols,
'class' => 'quiz_summary_qrow',
);
}
return theme('table', $header, $rows);
}