function theme_quiz_my_results_for_quiz in Quiz 7
Same name and namespace in other branches
- 8.4 quiz.pages.inc \theme_quiz_my_results_for_quiz()
- 6.4 quiz.pages.inc \theme_quiz_my_results_for_quiz()
- 7.4 quiz.pages.inc \theme_quiz_my_results_for_quiz()
Theme the user results page.
Parameters
$results: An array of quiz information.
Return value
Themed html.
1 theme call to theme_quiz_my_results_for_quiz()
- quiz_my_results in ./
quiz.pages.inc - Show results for the current quiz
File
- ./
quiz.pages.inc, line 375 - User pages.
Code
function theme_quiz_my_results_for_quiz($variables) {
$results = $variables['rows'];
$rows = array();
$with_passing = FALSE;
while (list($key, $result) = each($results)) {
$interval = _quiz_format_duration($result['time_end'] - $result['time_start']);
$score = $result['score'] . ' %';
$row = array(
'time_start' => format_date($result['time_start'], 'short'),
'duration' => $interval,
'score' => $score,
);
if (!empty($result['pass_rate'])) {
$with_passing = TRUE;
$passed = $result['score'] >= $result['pass_rate'];
$grade = $passed ? t('Passed') : t('Failed');
$passed_class = $passed ? 'quiz-passed' : 'quiz-failed';
$pre = '<span class = "' . $passed_class . '">';
$row['passed'] = $pre . $grade . '</span>';
}
$row['more'] = l(t('More') . '...', 'node/' . $result['nid'] . '/myresults/' . $result['result_id']);
$rows[] = $row;
}
if (empty($rows)) {
return t('No @quiz results found.', array(
'@quiz' => QUIZ_NAME,
));
}
$header = array(
t('Started'),
t('Duration'),
t('Score'),
);
if ($with_passing) {
$header[] = t('Passed');
}
$header[] = '';
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
));
return $output;
}