From ea16a91d2ef32bd53ef7d938ba383a5eaf5cca46 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Fri, 19 Sep 2008 04:54:49 +0000 Subject: [PATCH] MDL-12391 Prevent browser autocomplete in the quiz. Acutally, there was already code trying to do that, but it was not working. Fix it in HEAD only, because it is not a big deal, and so much has changed, it is not an easy back-port. --- mod/quiz/attempt.php | 5 +++-- mod/quiz/quiz.js | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index 4daf38d6e7..c6cdc2c369 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -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); @@ -119,9 +120,9 @@ // Start the form echo '
', "\n"; + '" enctype="multipart/form-data">', "\n"; echo '
'; + print_js_call('init_quiz_form'); /// Print the navigation panel in a left column. print_container_start(); diff --git a/mod/quiz/quiz.js b/mod/quiz/quiz.js index 267f7299cb..74e08402f7 100644 --- a/mod/quiz/quiz.js +++ b/mod/quiz/quiz.js @@ -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) { -- 2.39.5