Closed (fixed)
Project:
Quiz
Version:
6.x-4.x-dev
Component:
Code - Quiz module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Oct 2010 at 22:44 UTC
Updated:
14 Nov 2010 at 12:35 UTC
The Quiz module is set to email the results to the taker upon scoring a quiz. However, it is sending the email to the currently logged in user rather than the person who took the quiz. The currently logged in user is always the individual scoring the quiz and not the taker. The problem is in this function:
function quiz_quiz_scored($quiz, $score, $rid) {
global $user;
if (variable_get('quiz_email_results', 0) && $user->uid != 0 && $score['is_evaluated']) {
drupal_mail('quiz', 'notice', $user->mail, NULL, array($quiz, $score, $rid, 'taker'));
if ($user->uid && quiz_is_passed($user->uid, $quiz->nid, $quiz->vid)) {
drupal_mail('certificate', 'notice', $user->mail, NULL, array($quiz, $score, $rid, 'taker'));
}
drupal_set_message(t('The results has been sent to the users e-mail address.'));
}
// Calls userpoints functions to credit user point based on number of correct
// answers.
if ($quiz->has_userpoints && $user->uid != 0 && $score['is_evaluated']) {
//Looking up the tid of the selected Userpoint vocabulary
$selected_tid = db_result(
db_query("SELECT tid FROM {term_node}
WHERE nid = %d AND vid = %d AND tid IN (
SELECT tid
FROM {term_data}
WHERE vid = %d
)", $quiz->nid, $quiz->vid, userpoints_get_vid()));
$variables = array(
'@title' => $quiz->title,
'@quiz' => variable_get('quiz_name', QUIZ_NAME),
'@time' => date('l jS \of F Y h:i:s A'),
);
$params = array(
'points' => $score['numeric_score'],
'description' => t('Attened @title @quiz on @time', $variables),
'tid' => $selected_tid,
);
userpoints_userpointsapi($params);
}
}
Comments
Comment #1
dionysio commentedI should point out the two of the lines are my additions for creating a certificate. The module does not work properly without them either so it is not that.
Comment #2
falcon commentedThis has been fixed, but I haven't done much testing. Will you be able to update to the latest revision using cvs and test if my changes are working?
Comment #3
falcon commentedSince there were no replies here I close this issue.