From: tjhunt Date: Wed, 26 Sep 2007 18:15:31 +0000 (+0000) Subject: MDL-8682: Pressing enter when answering a short answer question can submit the wrong... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=fba3ea31bc398ac363763b837f72ede3d5f88069;p=moodle.git MDL-8682: Pressing enter when answering a short answer question can submit the wrong one. To fix this, I have disabled the enter key unless the keyboard focus is on a submit button (or inside a text box or HTML editor). MDL-9451: Quiz answers can be lost if user navigates before page reloads. I am not totally sure I have fixed this, but I hope so. I moved the printing of the hidden form field with the list of questions on the page to the end of the form, so no answers will be processed unless the whole form loaded. Note that you could still lose data, but only if the page takes a really long time to load and you answer the first question and click submit before the whole quiz is loaded. MDL-11463: The quiz uses two different timers, which is silly. I have removed the javascript that was ocasionally used to put a timer in the browser's title bar. Now we only use the one in the page for all cases. Because MDL-8682 also needed javascript, I renamed timer.js to quiz.js so it could be a library of all the quiz's JavaScript, and started including it properly with require_js. --- diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index 3adf670312..3f0fd0266c 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -394,6 +394,7 @@ /// Print the quiz page //////////////////////////////////////////////////////// // Print the page header + require_js($CFG->wwwroot . '/mod/quiz/quiz.js'); $pagequestions = explode(',', $pagelist); $headtags = get_html_head_contributions($pagequestions, $questions, $states); if (!empty($popup)) { @@ -439,12 +440,13 @@ // Start the form echo '
', "\n"; + '" enctype="multipart/form-data"' . + ' onclick="this.autocomplete=\'off\'" onkeypress="return check_enter(event);">', "\n"; if($quiz->timelimit > 0) { // Make sure javascript is enabled for time limited quizzes ?>