]> git.mjollnir.org Git - moodle.git/commitdiff
Minor improvement to a subtle edge case of question preview that probably only affect...
authortjhunt <tjhunt>
Thu, 17 Apr 2008 17:56:41 +0000 (17:56 +0000)
committertjhunt <tjhunt>
Thu, 17 Apr 2008 17:56:41 +0000 (17:56 +0000)
Also, revert dongshen's bad error -> print_error changes in this file.

question/preview.php

index 06c04779bf11c6e702eb3e916570ce6cbd756bde..f0c74b1a926899a7223ca50b23cf2cfcafb5c402 100644 (file)
@@ -60,7 +60,7 @@
     }
     // Load the question information
     if (!$questions = get_records('question', 'id', $id)) {
-        print_error('Could not load question');
+        error('Could not load question');
     }
     if (empty($quizid)) {
         $quiz = new cmoptions;
@@ -69,7 +69,7 @@
         require_login($courseid, false);
         $quiz->course = $courseid;
     } else if (!$quiz = get_record('quiz', 'id', $quizid)) {
-        print_error("Quiz id $quizid does not exist");
+        error("Quiz id $quizid does not exist");
     } else {
         require_login($quiz->course, false, get_coursemodule_from_instance('quiz', $quizid, $quiz->course));
     }
     $quiz->questions = $id;
 
     if (!$category = get_record("question_categories", "id", $questions[$id]->category)) {
-        print_error("This question doesn't belong to a valid category!");
+        error("This question doesn't belong to a valid category!");
     }
 
     if (!question_has_capability_on($questions[$id], 'use', $questions[$id]->category)){
-        print_error("You can't preview these questions!");
+        error("You can't preview these questions!");
     }
     if (isset($COURSE)){
         $quiz->course = $COURSE->id;
         unset($form['back']);
         unset($form['startagain']);
 
-        $event = $finishattempt ? QUESTION_EVENTCLOSE : QUESTION_EVENTSUBMIT;
+        if ($finishattempt) {
+            $event = QUESTION_EVENTCLOSE;
+        } else if ($markall) {
+            $event = QUESTION_EVENTSUBMIT;
+        } else {
+            $event = QUESTION_EVENTSAVE;
+        }
         if ($actions = question_extract_responses($questions, $form, $event)) {
             $actions[$id]->timestamp = 0; // We do not care about timelimits here
             question_process_responses($questions[$id], $curstate, $actions[$id], $quiz, $attempt);