intercept/disable F5 refresh key
April 1, 2013 12:00 AM
I have a Flash custom quiz (all questions in SWF with multiple pages) that I'd like the user not to press F5 (=refresh) button because it will start the course over. I'd like to have a similar dialog box like "You must answer all of the questions to continue." when you set a quiz to "Ensure the student answers all questions on the test." This way, a student can't restart the quiz until he or she finishes it.
How can I achieve that?
Thanks,
Discussion (3)
This is still an unresolved issue. If F5 pressed, it starts a course over from the beginning no matter which page a user is on. This allows a user to read the feedback, and write down the right answers, get the score in a quiz. If he or she fails, just press refresh and start over. Then, with answer keys at hand, he or she can pass the quiz. To LMS, it's still the same attempt so it won't block the user from taking it even the LMS is set to allow only 1 attempt.
The solution I have: Check the total attempt before the first page. At that page, it adds 1 to the VAR. If it's greater than 1, it goes to page informing the user that he has reached total attempt allowed; otherwise, it continues to the content page. This works, but I wonder if I can disable F5 completely inside a quiz, then it won't block users if F5 was accidentally clicked on.
Is refresh to start over a course control by Lectora or LMS? Is there an option to have refresh to refresh only the page a user is on instead of the course from Lectora?
Thanks for the help.
The following solution works for me on lectora v.11:
- Add the below script as a HTML extension.
- From the Elemenets Properties tab change the Type from Custom Div to Top of file scripting
This should disable the F5 refresh. It won't display the message you wont though, but it should stop the refresh, it works on a sample course I tried at least. I built a blank page and it stops that refreshing, I dont know if your flash content would interfer with it though.
I hope its of some help!
Block F5 Key In IE undefined<br />
<br />
if ((version.indexOf('MSIE') != -1)) {<br />
if (keycode == 116) {<br />
event.keyCode = 0;<br />
event.returnValue = false;<br />
return false;<br />
}<br />
}<br />
else {<br />
if (keycode == 116) {<br />
return false;<br />
}<br />
}<br />
}<br />
<br />
</script><br />
<br />
</head><br />
<body onload="JavaScript:document.body.focus();" onkeydown="return showKeyCode(event)"><br />
</body><br />
</html>
Wow, now that's a terrible way to add code.
Ext.HTML > Meta tags > add this:
[/CODE]
Tested in IE9 and Chrome. Probably needs further tuning to cover more browsers.
However, you should not be trying to prevent users from hitting F5, because they can still hit Ctrl+R, or close and re-open, or click with mouse on the circular arrow, or choose Refresh from the menu, or pull the cord, or do another 1 000 000 things that will result in refreshing the page and you can't stop them.
What you should do is to DEAL with refreshing by e.g. saving the quiz progress as you go and restarting from the same place and score. Also, if this is an important quiz that users shouldn't be cheating at, why are you showing feedback? Feedback is for teaching, not for knowledge testing. So decide what you want - teach your learners by asking them questions and providing feedback, or test their knowledge by asking them questions.By the way, the latter should be done using server-side solutions (i.e. quiz in LMS, not in Lectora) because user-side solutions are not secure.[CODE][/CODE]
Tested in IE9 and Chrome. Probably needs further tuning to cover more browsers.
However, you should not be trying to prevent users from hitting F5, because they can still hit Ctrl+R, or close and re-open, or click with mouse on the circular arrow, or choose Refresh from the menu, or pull the cord, or do another 1 000 000 things that will result in refreshing the page and you can't stop them.
What you should do is to DEAL with refreshing by e.g. saving the quiz progress as you go and restarting from the same place and score. Also, if this is an important quiz that users shouldn't be cheating at, why are you showing feedback? Feedback is for teaching, not for knowledge testing. So decide what you want - teach your learners by asking them questions and providing feedback, or test their knowledge by asking them questions.By the way, the latter should be done using server-side solutions (i.e. quiz in LMS, not in Lectora) because user-side solutions are not secure.
Discussions have been disabled for this post