var num_right=0;var num_wrong=0;var session='';var mode='normal';var category='';var scoreNormal=0;var scoreWeighted=0;var scoreLevel=0;var questionId=0;var questionUp=new String('');var questionDown=new String('');var choiceUp='';var choiceDown='';var indexCurrent=0;var indexUp=0;var indexDown=0;var questionNumber=1;var questionTotal=25;var level=0;var levelStep=1;var testData=new Array();var feedbackSubmitted=false;function renderStatistics() {if($("#txtLevel")) $("#txtLevel").html(Math.round(level*10000)/100);if($("#txtScoreLevel")) $("#txtScoreLevel").html(Math.round(scoreLevel*10000)/100);$("#txtScore").html(Math.round(scoreNormal*10000)/100);$("#txtWScore").html(Math.round(scoreWeighted*10000)/100);if($("#txtAnswerRight")) $("#txtAnswerRight").html(num_right);if($("#txtAnswerWrong")) $("#txtAnswerWrong").html(num_wrong);if($("#txtAnswerLeft")) $("#txtAnswerLeft").html(questionTotal-questionNumber+1);if($("#question_no")) $("#question_no").html(questionNumber);if($("#txtLevelStep")) $("#txtLevelStep").html(levelStep);if($("#txtQuestionAvailable")) $("#txtQuestionAvailable").html(testData.length);if($("#txtQuestionTotal")) $("#txtQuestionTotal").html(questionTotal);}function resetVar() {questionTotal=25;questionNumber=1;indexCurrent=0;level=0;scoreNormal=0;scoreWeighted=0;scoreLevel=0;num_right=0;num_wrong=0;}function questionFetch(idxCurrent, idxDirection) {if (mode!="normal") return (idxCurrent+1>=testData.length)?(testData.length-1):(idxCurrent+1);if (idxDirection==0) { if (idxCurrent<0) idx=0;if (idxCurrent==0) idx=idxCurrent+1;if (idxCurrent>0) idx=idxCurrent-1;} else {idx=idxCurrent+Math.floor(levelStep+Math.random());if (idx>=testData.length)idx=testData.length-1;}return idx;}function renderChoices(choice,mmc) {$("#choice").empty();type=(mmc==1)?'checkbox':'radio';for(i=0;i<choice.length;i++) $("#choice").append(" <li><input name='choices' type='"+type+"' value='"+choice[i].answer_code+"'>"+choice[i].answer_code+". "+choice[i].answer+"</li>");}function prefetch() {switch (indexCurrent) {case 0: indexDown=1;indexUp=questionFetch(indexDown,1);break;case 1: indexDown=0;indexUp=questionFetch(indexCurrent,1);break;default:indexUp=questionFetch(indexCurrent,1);indexDown=questionFetch(indexCurrent,0);}$.post('getQuestion/', {id:testData[indexUp].question_id}, function(data, textStatus) {questionUp=data.question.question;if(parseInt(data.question.picture_length)>0) questionUp=questionUp.replace(/<img.*>/gi,'<img src="renderPicture/?id='+questionId+"\" />");choicesUp=data.choices;if($("#txtIndexUp")) $("#txtIndexUp").html(indexUp);},'json');$.post('getQuestion/', {id:testData[indexDown].question_id}, function(data, textStatus) {questionDown=data.question.question;if(parseInt(data.question.picture_length)>0) questionDown=questionDown.replace(/<img.*>/gi,'<img src="renderPicture/?id='+questionId+"\" />");choicesDown=data.choices;if($("#txtIndexDown")) $("#txtIndexDown").html(indexDown);},'json');if($("#txtIndexCurrent")) $("#txtIndexCurrent").html(indexCurrent);}