var quizesUrl="http://quizzes.almotanabbi.com";
function Quiz(){
var questionsCount=5;
var divId=null;
var trackId=1;
var timerCountdown=0;
var theTimer=null;
this.countdown=function(){
if(timerCountdown==0){
return;
}
timerCountdown--;
if(timerCountdown<1){
this.answer(0);
}else{
this.initializeTimer();
}
}
this.initializeTimer=function(){
document.getElementById("remainingTimeSpan").style.visibility="visible";
if(timerCountdown<9){
document.getElementById("remainingTimeSpan").style.color="red";
}
message=String(timerCountdown)+" ثانية";
document.getElementById("remainingTimeSpan").innerHTML=message;
theTimer=window.setTimeout("quiz.countdown()",1000);
}
this.renderQuestion=function(sequence,countDown,question,options){
timerCountdown=countDown;
q='
';
document.getElementById(divId).innerHTML=q;
if(sequence>1){
// Initialise timer at the second question
this.initializeTimer();
}
}
this.initialise=function(divId1){
divId=divId1;
if(document.getElementById(divId)==null){
alert("div is not defined");
}
document.getElementById(divId).className="questionElement";
this.loadCSS();
this.startTest1JSON();
}
this.startTest1JSON=function(){
this.QuizesDynamicTag("startTest1JSON.do");
}
this.answer=function(){
timerCountdown=0;
clearTimeout(theTimer);
selectedValue=0;
var o=document.questionForm['optionId'];
for(i=0;i';
r+=' ';
r+=' | ';
r+=' ';
r+=' ';
r+=' | ';
r+=' نشكرك على مشاركتك في الإختبار';
r+=' | ';
r+='
';
r+=' ';
r+=' ';
if(score==100){
r+=' مبروك !! ';
}
r+=' حققت نسبة إجابة Q%'.replace("Q",score);
r+='
';
r+=' | ';
r+='
';
r+=' ';
r+=' ';
r+=' عدد المشاركين الذين حققوا نسبة إجابة 100%: Q مشترك'.replace("Q",fullScoreUsersCount);
r+=' ';
r+=' ';
r+=' | ';
r+='
';
r+=' ';
r+=' | ';
r+=' ';
r+=' إضغط هنا للمشاركة في الإختبار مرة أخرى';
r+=' ';
r+=' | ';
r+='
';
r+='';
document.getElementById(divId).innerHTML=r;
}
this.loadCSS=function (){
var head = document.getElementsByTagName("head").item(0);
// Create new Element
scriptElement = document.createElement("link");
scriptElement.id="jsonCSS";
scriptElement.setAttribute("rel", "stylesheet");
scriptElement.setAttribute("type", "text/css");
scriptElement.setAttribute("href", quizesUrl+"/style_json.css?r="+Math.random());
head.appendChild(scriptElement);
}
this.QuizesDynamicTag=function(action)
{
var head = document.getElementsByTagName("head").item(0);
var scriptElement = null;
scriptElement = document.getElementById("quizes");
if(scriptElement != null)
{
// Remove existing one
scriptElement.parentNode.removeChild(scriptElement);
}
// Create new Element
scriptElement = document.createElement("script");
scriptElement.id="quizes";
scriptElement.setAttribute("type", "text/javascript");
if(action.indexOf('?')==-1){
action+="?trackId="+trackId+"&r="+Math.random();
}else{
action+="&trackId="+trackId+"&r="+Math.random();
}
scriptElement.setAttribute("src", quizesUrl+"/"+action);
head.appendChild(scriptElement);
}
}
quiz=new Quiz();
function initialiseQuiz(divId){
quiz.initialise(divId);
}