/*class X-AM*/
var VERSION = "x-am 3"; //Version actuelle du logiciel examen

var PREPARATION=1;
var WRONGANSWERS=2;
var REVIEW=3;
var SIMULATION=4;
var SCORES=5;
var RESUME=6;
var STOP=7;
var IGNORE=8;
var SINGLEQUESTION=9;
var SCORENUM=10;
var SCOREGRAPH=11;
var SCORELAST=12;
var NEVERANSWERED=13;

function XAM( pType, pLanguage, pIniFile )
{
	this.version=VERSION;
	this.type=pType;			//exam, pmtok
	this.language=pLanguage;
	this.iniFile=pIniFile;
	this.source="";
	this.error=false;

	this.mode=0;	//preparation (1), wrong answers (2), review (3), simulation (4)
	this.param=null; //Knowledge Area (1-10), Process Group (p1-p5)
	this.timePerQuestion=0;
	this.resume=false;
	this.stopAndReview=false;

	//History
	this.active=false;
	this.name="";
	this.numQuestions=0;
	this.date=0;
	this.timeRemaining=-1;
	this.correctAnswers=0;
	this.givenAnswers=0;
	this.randomSeed1=0;
	this.randomSeed2=0;

	this.qStr="";
	this.xmlIni=null;
	this.xmlLang=null;
	this.analysis="";
	this.xmlAnalysis=null;
	
	this.calculateLmsScore=false;
	
	this.alert=XAM_alert;
	this.setDate=XAM_setDate;
	this.historyToString=XAM_historyToString;
	this.timeSpent=XAM_timeSpent;
}

function XAM_setDate()
{
	var cur = new Date();
	this.date=parseInt((cur.getTime()/1000), 10);
}

function XAM_historyToString()
{
	var s="";
	s+=(this.active ? 1 : 0)+";";
	s+=this.mode+";";
	s+=this.param+";";
	s+=this.numQuestions+";";
	s+=this.date+";";
	s+=this.timeRemaining+";";
	s+=this.correctAnswers+";";
	s+=this.givenAnswers+";";
	s+=this.randomSeed1+";";
	s+=this.randomSeed2;
	return s;
}

function XAM_timeSpent()
{
	//alert(this.numQuestions+" "+this.timePerQuestion+" "+this.timeRemaining);
	return (((this.numQuestions*this.timePerQuestion)+1)-this.timeRemaining);
}

function XAM_getXmlValue(objXml, attribLang, attribId)
{
	var cn1 = 0;
	var cn2 = 0;
	while(objXml.childNodes[cn1].getAttribute("lang")!=attribLang){
		cn1++;
	}
	while(objXml.childNodes[cn1].childNodes[cn2].getAttribute("id")!=attribId){
		cn2++;
	}
	return objXml.childNodes[cn1].childNodes[cn2].firstChild.data;
}

function XAM_alert()
{
	var s="objXAM: "+this+"\n";
	s+="----------------------------\n";
	s+="version: "+this.version+"\n";
	s+="type: "+this.type+"\n";
	s+="language: "+this.language+"\n";
	s+="iniFile: "+this.iniFile+"\n";
	s+="source: "+this.source+"\n";
	s+="----------------------------\n";
	s+="mode: "+this.mode+"\n";
	s+="param: "+this.param+"\n";
	s+="timePerQuestion: "+this.timePerQuestion+"\n";
	s+="----------------------------\n";
	s+="active: "+this.active+"\n";
	s+="resume: "+this.resume+"\n";
	s+="stopAndReview: "+this.stopAndReview+"\n";
	s+="calculateLmsScore: "+this.calculateLmsScore+"\n";
	s+="----------------------------\n";
	s+="name: "+this.name+"\n";
	s+="numQuestions: "+this.numQuestions+"\n";
	s+="date: "+this.date+"\n";
	s+="timeRemaining: "+this.timeRemaining+"\n";
	s+="correctAnswers: "+this.correctAnswers+"\n";
	s+="givenAnswers: "+this.givenAnswers+"\n";
	s+="randomSeed1: "+this.randomSeed1+"\n";
	s+="randomSeed2: "+this.randomSeed2+"\n";
	s+="qStr: "+this.qStr.length+"\n";
	s+="----------------------------\n";
	s+="xmlIni: "+this.xmlIni+"\n";
	s+="xmlLang: "+this.xmlLang+"\n";
	s+="xmlAnalysis: "+this.xmlAnalysis+"\n";
	alert(s);
}
