function quiz_take_quiz in Quiz 7.6
Same name and namespace in other branches
- 8.4 quiz.module \quiz_take_quiz()
- 5.2 quiz.module \quiz_take_quiz()
- 5 quiz.module \quiz_take_quiz()
- 6.6 quiz.module \quiz_take_quiz()
- 6.2 quiz.module \quiz_take_quiz()
- 6.3 quiz.module \quiz_take_quiz()
- 6.4 quiz.module \quiz_take_quiz()
- 6.5 quiz.module \quiz_take_quiz()
- 7 quiz.module \quiz_take_quiz()
- 7.4 quiz.module \quiz_take_quiz()
- 7.5 quiz.module \quiz_take_quiz()
Handles quiz taking.
This gets executed when the main quiz node is first loaded.
Parameters
$quiz: The quiz node.
Return value
Content array.
Related topics
2 calls to quiz_take_quiz()
- quiz_take_page in ./
quiz.module - Page to either resume a quiz or display a start quiz form.
- quiz_take_pane_content_type_render in plugins/
content_types/ quiztake_pane.inc - Run-time rendering of the body of the block (content type) See ctools_plugin_examples for more advanced info
File
- ./
quiz.module, line 1754 - quiz.module Main file for the Quiz module.
Code
function quiz_take_quiz($quiz) {
global $user;
// Make sure we use the same revision of the quiz throughout the quiz taking
// session.
$result_id = !empty($_SESSION['quiz'][$quiz->nid]['result_id']) ? $_SESSION['quiz'][$quiz->nid]['result_id'] : NULL;
if ($result_id && ($quiz_result = quiz_result_load($result_id))) {
return $quiz_result;
}
else {
// User doesn't have attempt in session. If we allow resuming we can load it
// from the database.
if ($quiz->allow_resume && !user_is_anonymous()) {
if ($result_id = _quiz_active_result_id($user->uid, $quiz->nid, $quiz->vid)) {
$_SESSION['quiz'][$quiz->nid]['result_id'] = $result_id;
$_SESSION['quiz'][$quiz->nid]['current'] = 1;
$quiz_result = quiz_result_load($result_id);
// Resume a quiz from the database.
$quiz_result->resume = 1;
return $quiz_result;
}
}
}
return FALSE;
}