function _quiz_get_summary_text in Quiz 7.6
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 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.
1 call to _quiz_get_summary_text()
- quiz_user_results in ./
quiz.pages.inc - Show result page for a given result id
File
- ./
quiz.module, line 2823 - quiz.module Main file for the Quiz module.
Code
function _quiz_get_summary_text($quiz, $score) {
$summary = array();
$admin = arg(0) == 'admin';
$quiz_format = isset($quiz->body[LANGUAGE_NONE][0]['format']) ? $quiz->body[LANGUAGE_NONE][0]['format'] : NULL;
if (!$admin) {
if (!empty($score['result_option'])) {
// Unscored quiz, return the proper result option.
$summary['result'] = check_markup($score['result_option'], $quiz_format);
}
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.', array(
'@quiz' => QUIZ_NAME,
));
}
elseif (variable_get('quiz_use_passfail', 1) == 0) {
// If there is only a single summary text, use this.
if (trim($quiz->summary_default) != '') {
$summary['passfail'] = check_markup($quiz->summary_default, $quiz_format);
}
}
elseif (trim($quiz->summary_pass) != '') {
// If there is a pass summary text, use this.
$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.', array(
'@quiz' => QUIZ_NAME,
));
}
else {
$summary['passfail'] = t('the user completed this @quiz.', array(
'@quiz' => QUIZ_NAME,
));
}
}
elseif (trim($quiz->summary_default) != '') {
$summary['passfail'] = check_markup($quiz->summary_default, $quiz->summary_default_format);
}
}
return $summary;
}