function quiz_jump_to in Quiz 6.4
Same name and namespace in other branches
- 8.4 quiz.module \quiz_jump_to()
- 7 quiz.module \quiz_jump_to()
- 7.4 quiz.module \quiz_jump_to()
Set the current session to jump to a specific question number
Parameters
int $question_num: The question number we want to jump to
Related topics
1 call to quiz_jump_to()
- quiz_take_quiz in ./
quiz.module - Handles quiz taking.
File
- ./
quiz.module, line 1972 - Quiz Module
Code
function quiz_jump_to($question_num, $quiz, $rid) {
$num_next = count($_SESSION['quiz_' . $quiz->nid]['quiz_questions']);
$num_previous = count($_SESSION['quiz_' . $quiz->nid]['previous_quiz_questions']);
if ($question_num > $num_next + $num_previous + 1) {
// Trying to jump too far. We allow skipping all questions because of jQuery countdown...
return;
}
if ($question_num <= $num_previous) {
for ($i = 0; $i < $num_previous - $question_num + 1; $i++) {
array_unshift($_SESSION['quiz_' . $quiz->nid]['quiz_questions'], array_pop($_SESSION['quiz_' . $quiz->nid]['previous_quiz_questions']));
}
}
elseif ($question_num > $num_previous + 1) {
for ($i = 0; $i < $question_num - $num_previous - 1; $i++) {
$_SESSION['quiz_' . $quiz->nid]['previous_quiz_questions'][] = array_shift($_SESSION['quiz_' . $quiz->nid]['quiz_questions']);
}
_quiz_cleanup_after_jumping($quiz, $rid);
}
}