]> git.mjollnir.org Git - moodle.git/commitdiff
Question preview now handles duplicate responses properly
authorgustav_delius <gustav_delius>
Sun, 30 Apr 2006 12:07:08 +0000 (12:07 +0000)
committergustav_delius <gustav_delius>
Sun, 30 Apr 2006 12:07:08 +0000 (12:07 +0000)
question/preview.php

index 7658dfaf057faf587969d0b15c8cbfdbffbffb4e..2dd1ec534e621213dc2239739502e8df6382a7eb 100644 (file)
     $attempt->timestart = $timenow;
     $attempt->timefinish = 0;
     $attempt->timemodified = $timenow;
-    $attempt->uniqueid = question_new_attempt_uniqueid();
+    $attempt->uniqueid = 0;
     $attempt->id = 0;
 
     // Restore the history of question sessions from the moodle session or create
         $states[$historylength + 1][$id] = clone($states[$historylength][$id]);
         $historylength++;
         $curstate =& $states[$historylength][$id];
+        $curstate->changed = false;
 
         // Process the responses
         unset($form['id']);
         unset($form['back']);
         unset($form['startagain']);
 
-        $event = $finishattempt ? QUESTION_EVENTCLOSE : ($markall ? QUESTION_EVENTGRADE : QUESTION_EVENTSAVE);
+        $event = $finishattempt ? QUESTION_EVENTCLOSE : QUESTION_EVENTSUBMIT;
         if ($actions = question_extract_responses($questions, $form, $event)) {
             $actions[$id]->timestamp = 0; // We do not care about timelimits here
-            question_process_responses($questions[$id], $states[$historylength][$id], $actions[$id], $quiz, $attempt);
-            if (QUESTION_EVENTGRADE != $curstate->event && QUESTION_EVENTCLOSE != $curstate->event) {
+            question_process_responses($questions[$id], $curstate, $actions[$id], $quiz, $attempt);
+            if (!$curstate->changed) {
                 // Update the current state rather than creating a new one
                 $historylength--;
                 unset($states[$historylength]);