// 010912 quizcode.js // using copy of questions array, selects one at a time and displays it // restart(), getquestion() includes slideup/down jquery animation, // displayquestion(), resetquestion(), shakeup(), soundplayer() // correctanswer()function, value of answer and what to do with answer is in game.html file //----------------------- // 050810 - Disable enter key - www.webcheatsheet.com method // 311013 - Allow for caeser shift encrypted questions, disable realquestionnumber variable // 020114 - converted to mp3 function stopRKey(evt) { var evt = (evt) ? evt : ((event) ? event : null); var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); if (evt.keyCode == 13) {return false;} } document.onkeypress = stopRKey; answer=""; correctanswer=0; // if answer correct // qloaded=1; // stop answering same question twice distractornum=0; // 020612 initialise global for no. of distractors 4 or 5 score=0; spinwin=0; if(typeof gametitle!='string'){gametitle=''} // 150211 - use gametitle if available function decodequestion(qdecode){ //281013 - encrypted questions in millquestenc.js are decoded via decodequestion() fn decodedq=''; //initialise decoded question string // only decode letters var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz[\]^"; for (var i=0;i to shuffle the answers in some QGM games // input array testsplit[], [0]=Question, [1]-[4]=possible answers, [5]=key A-E to correct answer var abcde="ABCDE"; var i; // need to declare this to protect other counters for(i=1; i<=distractornum; i++){ var aa=testsplit[distractornum+1]; //the original answer position var x=aa.charCodeAt(0)-64; // convert ASCII code for answer into number in range 1-4 var newplace=Math.ceil(Math.random()*distractornum); var temp=testsplit[newplace]; testsplit[newplace]=testsplit[i]; testsplit[i]=temp; //swap index with newplace if(i==x){testsplit[distractornum+1]=abcde.substring(newplace-1,newplace);} // if moving the answer, correct the answer flag if(newplace==x){testsplit[distractornum+1]=abcde.substring(i-1,i);} // if displacing the answer, adjust the answer flag } } function soundplayer(x){ // use new html audio tag to play mp3's document.getElementById("sndplayer").src=x+".mp3"; document.getElementById("sndplayer").play(); }