function quiz_create_rid in Quiz 6.4
Same name and namespace in other branches
- 8.4 quiz.module \quiz_create_rid()
- 7 quiz.module \quiz_create_rid()
- 7.4 quiz.module \quiz_create_rid()
Creates a unique id to be used when storing results for a quiz taker.
Parameters
$quiz: The quiz node.
Return value
$rid The result id.
Related topics
1 call to quiz_create_rid()
- quiz_take_quiz in ./
quiz.module - Handles quiz taking.
File
- ./
quiz.module, line 2552 - Quiz Module
Code
function quiz_create_rid($quiz) {
global $user;
$result = db_query("INSERT INTO {quiz_node_results} (nid, vid, uid, time_start) VALUES (%d, %d, %d, %d)", $quiz->nid, $quiz->vid, $user->uid, time());
if ($result) {
// Return the last RID.
$rid = db_last_insert_id('quiz_node_results', 'result_id');
}
else {
drupal_set_message(t('There was a problem starting the @quiz. Please try again later.', array(
'@quiz' => QUIZ_NAME,
), 'error'));
return FALSE;
}
return $rid;
}