But the same thing can be achieved with the help of the menu bar. We had to deactivate Alt key to restrict the user from accessing menu items.
After doing this there is one more possibility from where the user can directly take the stuff from the quiz. Just use Ctrl + A to select the whole page and directly Ctrl + C, Ctrl + V to copy and paste respectively. This option must also be disabled.
One more issue to take care is browser compatibility. It should work in Microsoft Internet Explorer and in Netscape Navigator.
Here's the code:
var isnn,isie if(navigator.appName=='Microsoft Internet Explorer') //check the browser { isie=true } if(navigator.appName=='Netscape') { isnn=true } function right(e) //to trap right click button { if (isnn && (e.which == 3 || e.which == 2 )) return false; else if (isie && (event.button == 2 || event.button == 3)) { alert("Sorry, you do not have permission to right click on this page."); return false; } return true; } function key(k) { if(isie) { if(event.keyCode==17 || event.keyCode==18 || event.keyCode==93) { alert("Sorry, you do not have permission to press this key.") return false; } } if(isnn){ alert("Sorry, you do not have permission to press this key.") return false; } } if (document.layers) window.captureEvents(Event.KEYPRESS); if (document.layers) window.captureEvents(Event.MOUSEDOWN); if (document.layers) window.captureEvents(Event.MOUSEUP); documentxxxkey; documentxxxright; documentxxxright; window.document.layers=right;
Put this code in a file called security.js and reference it between the <HEAD> and </HEAD> tags of your MOODLE theme header.html page using: <Scriptxxx"JavaScript" src="security.js"></script>
Hope this helps---Rob