From 84857f8ccdf0b588fbb98485bb2871d1dc23c7b4 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 17 Apr 2008 17:56:41 +0000 Subject: [PATCH] Minor improvement to a subtle edge case of question preview that probably only affects Opaque questions. Also, revert dongshen's bad error -> print_error changes in this file. --- question/preview.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/question/preview.php b/question/preview.php index 06c04779bf..f0c74b1a92 100644 --- a/question/preview.php +++ b/question/preview.php @@ -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)); } @@ -86,11 +86,11 @@ $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; @@ -160,7 +160,13 @@ 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); -- 2.39.5