function _quiz_get_summary_text in Quiz 7
Same name and namespace in other branches
- 8.4 quiz.module \_quiz_get_summary_text()
- 5.2 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.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 where the method is called from.
@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.admin.inc - Quiz result report page for the quiz admin section
- quiz_take_quiz in ./
quiz.module - Handles quiz taking.
- quiz_user_results in ./
quiz.pages.inc - Show result page for a given result id
File
- ./
quiz.module, line 3212 - Quiz Module
Code
function _quiz_get_summary_text($quiz, $score) {
$summary = array();
$admin = arg(0) == 'admin';
if (!$admin) {
if (!empty($score['result_option'])) {
// Unscored quiz, return the proper result option.
$summary['result'] = check_markup($score['result_option']);
}
else {
$result_option = _quiz_pick_result_option($quiz->nid, $quiz->vid, $score['percentage_score']);
$summary['result'] = is_object($result_option) ? check_markup($result_option->option_summary, $result_option->option_summary_format) : '';
}
}
// 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['passfail'] = t('The user passed this quiz.');
}
elseif (trim($quiz->summary_pass) != '') {
$summary['passfail'] = check_markup($quiz->summary_pass, $quiz->summary_pass_format);
}
}
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['passfail'] = t('The user failed this quiz.');
}
else {
$summary['passfail'] = t('the user completed this quiz.');
}
}
elseif (trim($quiz->summary_default) != '') {
$summary['passfail'] = check_markup($quiz->summary_default, $quiz->summary_default_format);
}
}
return $summary;
}