* @param object $cmoptions
* @param object $attempt The attempt for which the question sessions are
* to be restored or created.
+* @param mixed either the id of a previous attempt, if this attmpt is
+* building on a previous one, or false for a clean attempt.
*/
-function get_question_states(&$questions, $cmoptions, $attempt, $lastattemptid=null) {
+function get_question_states(&$questions, $cmoptions, $attempt, $lastattemptid = false) {
global $CFG, $QTYPES;
// get the question ids
error('Could not load question options');
}
- // If the new attempt is to be based on a previous attempt find its id
+ // If the new attempt is to be based on a previous attempt find its id
+ $lastattemptid = false;
if ($newattempt and $attempt->attempt > 1 and $quiz->attemptonlast and !$attempt->preview) {
// Find the previous attempt
if (!$lastattemptid = get_field('quiz_attempts', 'uniqueid', 'quiz', $attempt->quiz, 'userid', $attempt->userid, 'attempt', $attempt->attempt-1)) {