function _quiz_get_summary_text in Quiz 5.2
Same name and namespace in other branches
- 8.4 quiz.module \_quiz_get_summary_text()
- 5 quiz.module \_quiz_get_summary_text()
- 6.6 quiz.module \_quiz_get_summary_text()
- 6.2 quiz.module \_quiz_get_summary_text()
- 6.3 quiz.module \_quiz_get_summary_text()
- 6.4 quiz.module \_quiz_get_summary_text()
- 6.5 quiz.module \_quiz_get_summary_text()
- 7.6 quiz.module \_quiz_get_summary_text()
- 7 quiz.module \_quiz_get_summary_text()
- 7.4 quiz.module \_quiz_get_summary_text()
- 7.5 quiz.module \_quiz_get_summary_text()
Get the summary message for a completed quiz.
Summary is determined by whether we are using the pass / fail options, how the user did, and whether this is being called from admin/quiz/[quizid]/view.
TODO: Need better feedback for when a user is viewing their quiz results from the results list (and possibily when revisiting a quiz they can't take again).
Parameters
$quiz: The quiz node object.
$score: The score information as returned by quiz_calculate_score().
Return value
Filtered summary text or null if we are not displaying any summary.
3 calls to _quiz_get_summary_text()
- quiz_admin_results in ./
quiz.module - quiz_take_quiz in ./
quiz.module - Handles quiz taking.
- quiz_user_results in ./
quiz.module
File
- ./
quiz.module, line 1097
Code
function _quiz_get_summary_text($quiz, $score) {
if ($score['result_option']) {
// Unscored quiz, return the proper result option.
return $score['result_option'];
}
$admin = arg(3) == 'view';
if ($quiz->pass_rate > 0) {
$score_result = _quiz_pick_result_option($quiz->nid, $quiz->vid, $score['percentage_score']);
}
// If we are using pass/fail, and they passed.
if ($quiz->pass_rate > 0 && $score['percentage_score'] >= $quiz->pass_rate) {
// If we are coming from the admin view page.
if ($admin) {
$summary = t('The user passed this quiz.');
}
else {
if (trim($quiz->summary_pass) != '') {
$summary = !empty($score_result) ? $score_result : check_markup($quiz->summary_pass, $quiz->format, FALSE);
}
}
}
else {
// If we are coming from the admin view page,
// only show a summary if we are using pass/fail.
if ($admin) {
if ($quiz->pass_rate > 0) {
$summary = t('The user failed this quiz.');
}
}
else {
if (trim($quiz->summary_pass) != '') {
$summary = !empty($score_result) ? $score_result : check_markup($quiz->summary_default, $quiz->format, FALSE);
}
}
}
return $summary;
}