Disable autocomplete

Disable autocomplete

by Jim Gary -
Number of replies: 13
Anyone know where I can disable autocomplete for quizzes? I see where I can add a tag:
autocomplete = "off" to a form but will that work and where would I add the tag?
Average of ratings: -
In reply to Jim Gary

Re: Disable autocomplete

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The Moodle quiz already sets autocomplete="off".
In reply to Tim Hunt

Re: Disable autocomplete

by Jim Gary -
OIC, the problem is different than I explained. I guess I need to know how to set autocomplete="off" in the games module that uses a quiz as a a source. I realize now that that module simply accesses the quiz table and has nothing to do with the php source for the quiz, DUH!. Should I pose this question in that forum or is there a generic solution that would apply to all modules? If you can point me to the php page in the quiz module that contains the autocomplete=off tag in the quiz module I think I can figure it out... maybe!!! smile Or just point me in the right direction in the documentation and I can RTFM myself. As you can see, I've only been moodling for a few months.

Thanks for the help Tim!!
In reply to Jim Gary

Re: Disable autocomplete

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Moodle 1.9.9
file mod/quiz/attempt.php
lines 471-472
echo '<form id="responseform" method="post" action="', $quiz->thispageurl . '" enctype="multipart/form-data"' .
' onclick="this.autocomplete=\'off\'" onkeypress="return check_enter(event);" accept-charset="utf-8">', "\n";
Joseph
In reply to Jim Gary

Re: Disable autocomplete

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ah, that makes more sense.

Joseph gave the right answer. (Just remember that the Moodle forums adds an X in front of 'onclick'.)

You may wonder why we add this attribute using JavaScript. That is because autocomplete= is not valid HTML, but it is OK in JavaScript.
In reply to Tim Hunt

Re: Disable autocomplete

by Jim Gary -
Going back a few steps, I was checking one of my quizzes and I noticed that short answer cloze questions DO allow autocomplete. Am I missing something here? I can send you a login if you have time to check it out. Speaking of, it is safe to send semi-sensitive info like logins via Moodle messaging?

Thanks again for your help!
In reply to Jim Gary

Re: Disable autocomplete

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Weird. I don't particularly want to take a look myself. Are you familiar with using the Firebug extension for Firefox to examine web pages?

Some people do use Moodle messaging to send passwords. It is about as secure as email, assuming you trust Martin D, Jordan, and the other HQ folks who have access to the DB.
In reply to Jim Gary

Re: Disable autocomplete

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Jim,

autocomplete is a (generally useful) feature of modern browsers. I think it is every user's responsibility to turn that feature ON or OFF at will.

I'm not sure but I think that, in an institution such as a school, university, etc. where a number of different users (students etc.) may use the same physical machine, autocomplete does not work across different users' sessions. It is only if one user comes back to the same machine and identify themselves that they will find the autocomplete feature in their own session.

But I may be wrong.

Joseph

In reply to Tim Hunt

Re: Disable autocomplete

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Tim,

autocomplete="off" may not be valid HTML, but it does work.smile

echo '<form autocomplete="off" id="responseform" method="post" action="', $quiz->thispageurl . '" enctype="multipart/form-data"' .' onkeypress="return check_enter(event);" accept-charset="utf-8">', "\n";

on the other hand, using JavaScript (as per Moodle 1.9) does not work.sad

echo '<form id="responseform" method="post" action="', $quiz->thispageurl . '" enctype="multipart/form-data"' .' onclick="autocomplete=\'off\'" onkeypress="return check_enter(event);" accept-charset="utf-8">', "\n";

Just tested in moodle 1.9.9 and FireFox.

Joseph

In reply to Joseph Rézeau

Re: Disable autocomplete

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
How are you testing - note that it is being added on CLICK.

Why we don't just do

<form id="responseform" ... >
<script type="text/javascript">
document.getElementById('responseform').autocomplete = 'off';
</script>

Actually, we do pretty much that in Moodle 2.0.
In reply to Tim Hunt

Re: Disable autocomplete

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

1.- How I test:

Go to quiz, answer question once, then move away. Come back to same question, click inside input box, type "c", "cat" autocomplete appears. See attached screenshot.

2.- Adding the little script after line 412 does the trick, Tim. Maybe should be added to Moodle 1.9 as a fix?

Joseph

Attachment image00.jpg
In reply to Joseph Rézeau

Re: Disable autocomplete

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Thanks for the testing Joseph. I made the change on the 1.9 branch.
In reply to Jim Gary

Re: Disable autocomplete

by Peter Halverson -
Hi everyone,

I am giving a moodle quiz to my high school physics class, and I'm finding that there is still a problem with autocomplete. One question is "What do you call the force exerted by a rope?" The answer is "tension." The problem is that if two students take the quiz on the same computer, the 2nd person taking the quiz will see "tension" as soon as he types "t". I have tried using the "some java security in a pop-up window" option and the problem persists. It even persists if I tell Firefox to clean recent history.

This is crazy... The students can see the answers of the previous students. How can I stop it? The computers I have in the classroom are running firefox on Ubuntu 8, but the students will take the quiz at home, and in the library, where there is a variety of computers.

Thanks,

Peter Halverson
In reply to Peter Halverson

Re: Disable autocomplete

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Which version of Moodle are you using? I believe this is fixed.