<html> <script> var objXmlHTTP,objXmlDOM; var aQuest; //to store question ids var aAnswer = new Array(); // to track the result var aSelected = new Array(); // to store user's response var count = 0; //to store the current question no var ansSel = 0; //to store user's selection var ExamDuration = 5 * 60 ; // 5 minutes var timerID; //to store the setInterval fun's id var radIndex = -1; //to store the selected radio's index
//constructor like function //here XML objects are created and //No of questions as well as question ids list //are fetched from the server. function init(){ objXmlHTTP = new ActiveXObject("Microsoft.XMLHTTP"); objXmlDOM = new ActiveXObject("Microsoft.XMLDOM"); objXmlHTTP.open("POST","OLExam.asp?Action=Start",false); objXmlHTTP.send(""); temp =objXmlHTTP.ResponseText; aQuest = temp.split(",");
//initialize the user's answers list for(i=0;i<aQuest.length; i++){ aAnswer[i] = 0; // 0 for wrong; 1 for right answer aSelected[i] = -1; // to store the radio's index }
//parse the response content fetched from the server //and display the question parseQ(); }
//change the Start button's caption and its click event document.frm.btnFinish.value = "Finish the Exam"; document.frm.btnFinish.onclick = showResult; //function
//start the timer timerID = setInterval("timer()",1000); }
function getPreQ() { //update the user's answers list checkAnswer();
//decrement the question no - i.e. to previous Question count--;
//stop the timer clearInterval(timerID);
//fetch the question for the aQuest[count] id url = "OLExam.asp?Action=NextQ&QNo=" +