]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-12391 Prevent browser autocomplete in the quiz. Acutally, there was already code...
authortjhunt <tjhunt>
Fri, 19 Sep 2008 04:54:49 +0000 (04:54 +0000)
committertjhunt <tjhunt>
Fri, 19 Sep 2008 04:54:49 +0000 (04:54 +0000)
mod/quiz/attempt.php
mod/quiz/quiz.js

index 4daf38d6e7b5304e046366da6beb9b0f7aa03045..c6cdc2c369fd1921d71eca41012b3451fb81b2ed 100644 (file)
@@ -80,6 +80,7 @@
 /// Print the quiz page ////////////////////////////////////////////////////////
 
     // Print the page header
+    require_js(array('yui_yahoo','yui_event'));
     require_js($CFG->wwwroot . '/mod/quiz/quiz.js');
     $title = get_string('attempt', 'quiz', $attemptobj->get_attempt_number());
     $headtags = $attemptobj->get_html_head_contributions($page);
 
     // Start the form
     echo '<form id="responseform" method="post" action="', $attemptobj->processattempt_url(),
-            '" enctype="multipart/form-data"' .
-            ' onclick="this.autocomplete=\'off\'" onkeypress="return check_enter(event);">', "\n";
+            '" enctype="multipart/form-data">', "\n";
     echo '<div>';
+    print_js_call('init_quiz_form');
 
 /// Print the navigation panel in a left column.
     print_container_start();
index 267f7299cba351342d530a4efa10cab43aeacf48..74e08402f7c1ff3dd63817fc8a6de843644c8ec1 100644 (file)
@@ -6,6 +6,12 @@
  * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
  */
 
+function init_quiz_form() {
+    var responseform = document.getElementById('responseform');
+    responseform.setAttribute('autocomplete', 'off');
+    YAHOO.util.Event.addListener(responseform, 'keypress', check_enter);
+}
+
 /* Use this in an onkeypress handler, to stop enter submitting the forum unless you
 are actually on the submit button. Don't stop the user typing things in text areas. */
 function check_enter(e) {