From 2d05b47209461dee49734dbc41713fd84fccfe7a Mon Sep 17 00:00:00 2001
From: tjhunt <tjhunt>
Date: Tue, 24 Apr 2007 17:32:21 +0000
Subject: [PATCH] MDL-6368 and MDL-6369 - allow question type plugins to easily
 provide some bits of Javascript and CSS - I forgot about the review page.

---
 mod/quiz/review.php | 55 +++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/mod/quiz/review.php b/mod/quiz/review.php
index 9e83fff678..a66a55abb1 100644
--- a/mod/quiz/review.php
+++ b/mod/quiz/review.php
@@ -78,6 +78,30 @@
 
     add_to_log($course->id, "quiz", "review", "review.php?id=$cm->id&amp;attempt=$attempt->id", "$quiz->id", "$cm->id");
 
+/// Load all the questions and states needed by this script
+
+    // load the questions needed by page
+    $pagelist = $showall ? quiz_questions_in_quiz($attempt->layout) : quiz_questions_on_page($attempt->layout, $page);
+    $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 ($pagelist)";
+    if (!$questions = get_records_sql($sql)) {
+        error('No questions found');
+    }
+
+    // Load the question type specific information
+    if (!get_question_options($questions)) {
+        error('Could not load question options');
+    }
+
+    // Restore the question sessions to their most recent states
+    // creating new sessions where required
+    if (!$states = get_question_states($questions, $quiz, $attempt)) {
+        error('Could not restore question sessions');
+    }
+
 /// Print the page header
 
     $strquizzes = get_string("modulenameplural", "quiz");
@@ -89,9 +113,11 @@
     $strtimecompleted = get_string("completedon", "quiz");
     $stroverdue = get_string("overdue", "quiz");
 
+    $pagequestions = explode(',', $pagelist);
+    $headtags = get_html_head_contributions($pagequestions, $questions, $states);
     if (!empty($popup)) {
         define('MESSAGE_WINDOW', true);  // This prevents the message window coming up
-        print_header($course->shortname.': '.format_string($quiz->name), '', '', '', '', false, '', '', false, '');
+        print_header($course->shortname.': '.format_string($quiz->name), '', '', '', $headtags, false, '', '', false, '');
         /// Include Javascript protection for this page
         include('protect_js.php');
     } else {
@@ -105,7 +131,7 @@
         
         $navigation = build_navigation($crumbs);
                
-        print_header_simple(format_string($quiz->name), "", $navigation, "", "", true, $strupdatemodule);
+        print_header_simple(format_string($quiz->name), "", $navigation, "", $headtags, true, $strupdatemodule);
     }
     echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib
 
@@ -122,30 +148,6 @@
         print_heading(format_string($quiz->name));
     }
 
-/// Load all the questions and states needed by this script
-
-    // load the questions needed by page
-    $pagelist = $showall ? quiz_questions_in_quiz($attempt->layout) : quiz_questions_on_page($attempt->layout, $page);
-    $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 ($pagelist)";
-    if (!$questions = get_records_sql($sql)) {
-        error('No questions found');
-    }
-
-    // Load the question type specific information
-    if (!get_question_options($questions)) {
-        error('Could not load question options');
-    }
-
-    // Restore the question sessions to their most recent states
-    // creating new sessions where required
-    if (!$states = get_question_states($questions, $quiz, $attempt)) {
-        error('Could not restore question sessions');
-    }
-
 /// Print infobox
 
     $timelimit = (int)$quiz->timelimit * 60;
@@ -239,7 +241,6 @@
 
 /// Print all the questions
 
-    $pagequestions = explode(',', $pagelist);
     $number = quiz_first_questionnumber($attempt->layout, $pagelist);
     foreach ($pagequestions as $i) {
         if (!isset($questions[$i])) {
-- 
2.39.5