function _quiz_active_result_id in Quiz 6.4
Same name and namespace in other branches
- 8.4 quiz.module \_quiz_active_result_id()
- 6.6 quiz.module \_quiz_active_result_id()
- 6.3 quiz.module \_quiz_active_result_id()
- 6.5 quiz.module \_quiz_active_result_id()
- 7.6 quiz.module \_quiz_active_result_id()
- 7 quiz.module \_quiz_active_result_id()
- 7.4 quiz.module \_quiz_active_result_id()
- 7.5 quiz.module \_quiz_active_result_id()
Returns the result ID for any current result set for the given quiz.
Parameters
$uid: User ID
$nid: Quiz node ID
$vid: Quiz node version ID
$now: Timestamp used to check whether the quiz is still open. Default: current time.
Return value
If a quiz is still open and the user has not finished the quiz, return the result set ID so that the user can continue. If no quiz is in progress, this will return 0.
1 call to _quiz_active_result_id()
- quiz_take_quiz in ./
quiz.module - Handles quiz taking.
File
- ./
quiz.module, line 3007 - Quiz Module
Code
function _quiz_active_result_id($uid, $nid, $vid, $now = NULL) {
if (!isset($now)) {
$now = time();
}
// Get any quiz that is open, for this user, and has not already
// been completed.
$sql = "SELECT result_id\n FROM {quiz_node_results} qnr\n INNER JOIN {quiz_node_properties} qnp ON qnr.vid = qnp.vid\n WHERE (qnp.quiz_always = 1 OR (%d BETWEEN qnp.quiz_open AND qnp.quiz_close))\n AND qnr.vid = %d\n AND qnr.uid = %d\n AND qnr.time_end = 0";
$rid = db_result(db_query($sql, $now, $vid, $uid));
return (int) $rid;
}