function theme_quiz_get_user_results in Quiz 8.4
Same name and namespace in other branches
- 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.4 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 873 - Page callback file for the quiz module.
Code
function theme_quiz_get_user_results($variables) {
$results = $variables['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'], 'node/' . $result['nid']),
'time_start' => format_date($result['time_start'], 'short'),
'time_end' => $result['time_end'] > 0 ? format_date($result['time_end'], 'short') . '<br />' . t('Duration : @value', array(
'@value' => $interval,
)) : t('In Progress'),
'score' => $score,
'evaluated' => $result['is_evaluated'] ? t('Yes') : t('No'),
'op' => l(t('View answers'), 'user/quiz/' . $result['result_id'] . '/userresults'),
);
}
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'),
t('Operation'),
);
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
));
$output .= '<p><em>' . t('@quizzes that are not evaluated may have a different score and grade once evaluated.', array(
'@quizzes' => QUIZ_NAME,
)) . '</em></p>';
return $output;
}