From 618a45294721fb5fcb17cfdee4e1aeb189f663e1 Mon Sep 17 00:00:00 2001
From: samhemelryk <samhemelryk>
Date: Thu, 2 Jul 2009 06:46:47 +0000
Subject: [PATCH] mod-quiz MDL-16706 Eliminated inline scripts to use PAGE
 methods

---
 mod/quiz/accessrules.php | 7 +++----
 mod/quiz/quiz.js         | 6 +++++-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php
index 3a548d6c57..9f31e62d80 100644
--- a/mod/quiz/accessrules.php
+++ b/mod/quiz/accessrules.php
@@ -691,7 +691,7 @@ class securewindow_access_rule extends quiz_access_rule_base {
      * a JavaScript altert before the button submits.
      */
     public function print_start_attempt_button($buttontext, $strconfirmstartattempt) {
-        global $CFG, $SESSION;
+        global $CFG, $SESSION, $PAGE;
 
         $attempturl = $this->_quizobj->start_attempt_url() . '?cmid=' . $this->_quizobj->get_cmid() .
                 '&sesskey=' . sesskey();
@@ -709,9 +709,8 @@ class securewindow_access_rule extends quiz_access_rule_base {
         echo "window.open('$attempturl', '$window', '$this->windowoptions');", '" />';
 
     /// JavaScript to reveal the button.
-        echo '<script type="text/javascript">' . "\n";
-        echo "document.getElementById('quizstartbutton').style.cssText = '';\n";
-        echo "</script>\n";
+        echo $PAGE->requires->js('mod/quiz/quiz.js')->asap();
+        echo $PAGE->requires->js_function_call('reveal_start_button')->asap();
 
     /// A noscript tag to explains that this quiz only works with JavaScript enabled.
         echo '<noscript>';
diff --git a/mod/quiz/quiz.js b/mod/quiz/quiz.js
index 5d7b3f8883..97cf4eeb68 100644
--- a/mod/quiz/quiz.js
+++ b/mod/quiz/quiz.js
@@ -220,4 +220,8 @@ quiz_secure_window = {
             }
         }
     }
-};
\ No newline at end of file
+};
+
+function reveal_start_button() {
+    document.getElementById('quizstartbutton').style.cssText = '';
+}
\ No newline at end of file
-- 
2.39.5