From: moodler Date: Wed, 9 Apr 2003 08:11:20 +0000 (+0000) Subject: More fixes resulting from random question feature X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=72e5815533497a1fef90388bb31c6b52b97c28a5;p=moodle.git More fixes resulting from random question feature --- diff --git a/mod/quiz/report.php b/mod/quiz/report.php index 10a0ec8e26..e80bf7b357 100644 --- a/mod/quiz/report.php +++ b/mod/quiz/report.php @@ -82,6 +82,7 @@ print_heading($quiz->name); + if (!empty($attempt)) { // Show a particular attempt if (! $attempt = get_record("quiz_attempts", "id", $attempt)) { @@ -98,6 +99,8 @@ error("Could not reconstruct quiz results for attempt $attempt->id!"); } + quiz_remove_unwanted_questions(&$questions, $quiz); + if (!$result = quiz_grade_attempt_results($quiz, $questions)) { error("Could not re-grade this quiz attempt!"); } @@ -158,6 +161,7 @@ if (! $questions = quiz_get_attempt_responses($attempt, $quiz)) { error("Could not reconstruct quiz results for attempt $attempt->id!"); } + quiz_remove_unwanted_questions(&$questions, $quiz); if (!$result = quiz_grade_attempt_results($quiz, $questions)) { error("Could not re-grade this quiz attempt!"); @@ -221,4 +225,22 @@ // Finish the page print_footer($course); + +function quiz_remove_unwanted_questions(&$questions, $quiz) { + + $quizquestions = array(); + $quizids = explode(",", $quiz->questions); + foreach ($quizids as $quizid) { + $quizquestions[$quizid] = true; + } + foreach ($questions as $key => $question) { + if (!isset($quizquestions[$question->id])) { + unset($questions[$key]); + } + } +} + + + + ?>