function theme_quiz_get_user_results in Quiz 6.4
Same name and namespace in other branches
- 8.4 quiz.pages.inc \theme_quiz_get_user_results()
- 5.2 quiz.module \theme_quiz_get_user_results()
- 5 quiz.module \theme_quiz_get_user_results()
- 6.6 quiz.pages.inc \theme_quiz_get_user_results()
- 6.2 quiz.pages.inc \theme_quiz_get_user_results()
- 6.3 quiz.pages.inc \theme_quiz_get_user_results()
- 6.5 quiz.pages.inc \theme_quiz_get_user_results()
- 7 quiz.pages.inc \theme_quiz_get_user_results()
- 7.4 quiz.pages.inc \theme_quiz_get_user_results()
Theme the user results page.
Parameters
$results: An array of quiz information.
Return value
Themed html.
1 theme call to theme_quiz_get_user_results()
- quiz_get_user_results in ./
quiz.pages.inc - Displays all the quizzes the user has taken part in.
File
- ./
quiz.pages.inc, line 284 - User pages.
Code
function theme_quiz_get_user_results($results) {
$rows = array();
while (list($key, $result) = each($results)) {
$interval = _quiz_format_duration($result['time_end'] - $result['time_start']);
$passed = $result['score'] >= $result['pass_rate'];
$grade = $passed ? t('Passed') : t('Failed');
$passed_class = $passed ? 'quiz-passed' : 'quiz-failed';
if (!is_numeric($result['score'])) {
$score = t('In progress');
}
elseif (!$result['is_evaluated']) {
$score = t('Not evaluated');
}
else {
if (!empty($result['pass_rate']) && is_numeric($result['score'])) {
$pre_score = '<span class = "' . $passed_class . '">';
$post_score = ' %<br><em>' . $grade . '</em></span>';
}
else {
$post_score = ' %';
}
$score = $pre_score . $result['score'] . $post_score;
}
$rows[] = array(
'title' => l($result['title'], 'user/quiz/' . $result['result_id'] . '/userresults'),
'time_start' => format_date($result['time_start'], 'small'),
'time_end' => $result['time_end'] > 0 ? format_date($result['time_end'], 'small') . '<br />' . t('Duration : @value', array(
'@value' => $interval,
)) : t('In Progress'),
'score' => $score,
'evaluated' => $result['is_evaluated'] ? t('Yes') : t('No'),
);
}
if (empty($rows)) {
return t('No @quiz results found.', array(
'@quiz' => QUIZ_NAME,
));
}
$header = array(
t('@quiz Title', array(
'@quiz' => QUIZ_NAME,
)),
t('Started'),
t('Finished'),
t('Score'),
t('Evaluated'),
);
$output = theme('table', $header, $rows);
$output .= '<p><em>' . t('@quizzes that are not evaluated may have different score and grade when it is done.', array(
'@quizzes' => QUIZ_NAME,
)) . '</em></p>';
return $output;
}