From: tjhunt Date: Wed, 25 Apr 2007 15:45:24 +0000 (+0000) Subject: * Fix layout problem on password form. (invisiblefieldset). * Question state fixes... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5df53d00827d891af8034d052b9eba11408021a1;p=moodle.git * Fix layout problem on password form. (invisiblefieldset). * Question state fixes: + Don't change from EVENTOPEN too soon. + Make sure all questions get closed at the end of the attempt in adaptive mode. * Get rid of the delay on the redirect when you submit all and finish. --- diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index 37c71300be..535bac53c2 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -110,7 +110,7 @@ echo "
\n"; echo "
id\" onclick=\"this.autocomplete='off'\">\n"; - echo '
'; + echo '
'; print_simple_box_start("center"); echo "
\n"; @@ -307,7 +307,7 @@ foreach($questionidarray as $i) { if (!isset($actions[$i])) { $actions[$i]->responses = array('' => ''); - $actions[$i]->event = QUESTION_EVENTSAVE; + $actions[$i]->event = QUESTION_EVENTOPEN; } $actions[$i]->timestamp = $timestamp; question_process_responses($questions[$i], $states[$i], $actions[$i], $quiz, $attempt); @@ -325,40 +325,35 @@ // Set the attempt to be finished $attempt->timefinish = $timestamp; - // Find all the questions for this attempt for which the newest - // state is not also the newest graded state - if ($closequestions = get_records_select('question_sessions', - "attemptid = $attempt->uniqueid AND newest != newgraded", '', 'questionid, questionid')) { - - // load all the questions - $closequestionlist = implode(',', array_keys($closequestions)); - $sql = "SELECT q.*, i.grade AS maxgrade, i.id AS instance". - " FROM {$CFG->prefix}question q,". - " {$CFG->prefix}quiz_question_instances i". - " WHERE i.quiz = '$quiz->id' AND q.id = i.question". - " AND q.id IN ($closequestionlist)"; - if (!$closequestions = get_records_sql($sql)) { - error('Questions missing'); - } + // load all the questions + $closequestionlist = quiz_questions_in_quiz($attempt->layout); + $sql = "SELECT q.*, i.grade AS maxgrade, i.id AS instance". + " FROM {$CFG->prefix}question q,". + " {$CFG->prefix}quiz_question_instances i". + " WHERE i.quiz = '$quiz->id' AND q.id = i.question". + " AND q.id IN ($closequestionlist)"; + if (!$closequestions = get_records_sql($sql)) { + error('Questions missing'); + } - // Load the question type specific information - if (!get_question_options($closequestions)) { - error('Could not load question options'); - } + // Load the question type specific information + if (!get_question_options($closequestions)) { + error('Could not load question options'); + } - // Restore the question sessions - if (!$closestates = get_question_states($closequestions, $quiz, $attempt)) { - error('Could not restore question sessions'); - } + // Restore the question sessions + if (!$closestates = get_question_states($closequestions, $quiz, $attempt)) { + error('Could not restore question sessions'); + } - foreach($closequestions as $key => $question) { - $action->event = QUESTION_EVENTCLOSE; - $action->responses = $closestates[$key]->responses; - $action->timestamp = $closestates[$key]->timestamp; - question_process_responses($question, $closestates[$key], $action, $quiz, $attempt); - save_question_session($question, $closestates[$key]); - } + foreach($closequestions as $key => $question) { + $action->event = QUESTION_EVENTCLOSE; + $action->responses = $closestates[$key]->responses; + $action->timestamp = $closestates[$key]->timestamp; + question_process_responses($question, $closestates[$key], $action, $quiz, $attempt); + save_question_session($question, $closestates[$key]); } + add_to_log($course->id, 'quiz', 'close attempt', "review.php?attempt=$attempt->id", "$quiz->id", $cm->id); @@ -386,7 +381,7 @@ } if ($finishattempt) { - redirect('review.php?attempt='.$attempt->id); + redirect('review.php?attempt='.$attempt->id, 0); } /// Print the quiz page //////////////////////////////////////////////////////// @@ -434,6 +429,7 @@ } } + // Start the form echo "\n"; if($quiz->timelimit > 0) { // Make sure javascript is enabled for time limited quizzes @@ -470,7 +466,7 @@ //]]> \n"; + echo '\n"; quiz_print_navigation_panel($page, $numpages); echo "
\n"; } @@ -522,7 +518,7 @@ // For teachers ignore the quiz closing time $secondsleft = 999999999999; } - + // If time limit is set include floating timer. // MDL-7495, no timer for users with disability if ($quiz->timelimit > 0 && !has_capability('mod/quiz:ignoretimelimits', $context, NULL, false)) { @@ -544,5 +540,4 @@ if (empty($popup)) { print_footer($course); } - ?>