function quiz_mail in Quiz 7
Same name and namespace in other branches
- 6.6 quiz.module \quiz_mail()
- 6.3 quiz.module \quiz_mail()
- 6.4 quiz.module \quiz_mail()
- 6.5 quiz.module \quiz_mail()
- 7.6 quiz.module \quiz_mail()
- 7.4 quiz.module \quiz_mail()
Implements hook_mail().
Related topics
File
- ./
quiz.module, line 2396 - Quiz Module
Code
function quiz_mail($key, &$message, $params) {
global $user;
list($quiz, $score, $rid, $target) = $params;
$substitutions = array(
'!title' => $quiz->title,
'!sitename' => variable_get('site_name', 'Quiz'),
'!taker' => $user->name,
'!author' => $quiz->name,
'!title' => check_plain($quiz->title),
'!date' => date("F j, Y, g:i a"),
'!desc' => check_plain($quiz->body),
'!correct' => isset($score['numeric_score']) ? $score['numeric_score'] : 0,
'!total' => $score['possible_score'],
'!percentage' => $score['percentage_score'],
'!url' => url('user/quiz/' . $rid . '/userresults', array(
'absolute' => TRUE,
)),
'!minutes' => db_query("SELECT CEIL((time_end - time_start)/60) FROM {quiz_node_results} WHERE result_id = :result_id AND time_end", array(
':result_id' => $rid,
))
->fetchField(),
);
switch ($key) {
case 'notice':
if ($target == 'author') {
$subject = t(variable_get('quiz_email_results_subject', quiz_email_results_format('subject', 'author')), $substitutions, array(
'langcode' => $user->language,
));
$body = t(variable_get('quiz_email_results_body', quiz_email_results_format('body', 'author')), $substitutions, array(
'langcode' => $user->language,
));
}
else {
$subject = t(variable_get('quiz_email_results_subject_taker', quiz_email_results_format('subject', 'taker')), $substitutions, array(
'langcode' => $user->language,
));
$body = t(variable_get('quiz_email_results_body_taker', quiz_email_results_format('body', 'taker')), $substitutions, array(
'langcode' => $user->language,
));
}
$message['subject'] = $subject;
$message['body'] = $body;
break;
}
}