// DYRIS version 12.2


// VARIABLES GLOBALES

var txt_page="";
var num_page=1;
var fen_guide=null;
var timer=null;
var flag=1;
var af_themes=1;
var af_questions=1;


// CLASSE CL_appr

function CL_appr(a,b,c) {
	this.note_min=a*1;
	this.note_max=b*1;
	if (b*1<a*1) {
		this.note_min=b*1;
		this.note_max=a*1;
	}
	this.enonce=c;
}


// CLASSE CL_text()

function CL_text() {
	this.titre=new Array();
	this.bouton=new Array();
	this.fenetre=new Array();
	this.mot=new Array();
	this.score=new Array();
	this.juste=new Array();
	this.faux=new Array();
	this.appr=new Array();
	this.non_fini="";
	this.ajouter_appr=ajouter_appr;
}
function ajouter_appr(a,b,c) {
	this.appr[this.appr.length]=new CL_appr(a,b,c);
}


// CLASSE CL_page

function CL_page(nom,adresse) {
	this.nom=nom;
	this.adresse="pages/"+adresse;
}


// CLASSE CL_option

function CL_option() {
	this.mode_accueil=1;
	this.mode_questions=1;	
	this.mode_evaluation=1;
	this.titre="";
	this.commentaire="";
	this.nb_questions=new Array();
	this.conseil_debut="";
	this.conseil_fin="";
	this.quitter="";		
	this.coef_rep_juste=1;
	this.coef_rep_nulle=0;
	this.coef_rep_fausse=-0.5;
	this.note_sur="";
	this.bouton=new Array();
	this.ajouter_bouton_sup=ajouter_bouton_sup;
}
function ajouter_bouton_sup(a,b) {
	this.bouton[this.bouton.length]=new CL_page(a,b);
}


//CLASSE CL_reponse

function CL_reponse(txt) {
	var debut=txt.substring(0,3);
	if (debut=="[x]"||debut=="[ ]") {
		this.enonce=txt.substring(4,txt.length);
		if (debut=="[x]") this.resultat="vrai"; else this.resultat="faux";
	}
	else if (debut=="(x)"||debut=="(o)"||debut=="( )") {
		this.enonce=txt.substring(4,txt.length);
		if (debut=="(x)"||debut=="(o)") this.resultat="vrai"; else this.resultat="faux";
	}
	else {
		this.resultat=new Array();
		var pos=txt.indexOf("[");
		if (pos!=-1) {
			this.enonce=txt.substring(0,pos);
			var ch=txt.substring(pos+1,txt.length-1);
			var pos=ch.indexOf("=>");
			if (pos==-1) {
				this.type="zone de texte";
				var pos=ch.indexOf("||");
				if (pos==-1) this.resultat[0]=ch;
				while (pos!=-1) {
					this.resultat[this.resultat.length]=ch.substring(0,pos);
					ch=ch.substring(pos+2,ch.length);
					pos=ch.indexOf("||");
					if (pos==-1) this.resultat[this.resultat.length]=ch;
				}
			}
			else {
				this.type="liste de selection";

// Pour la prochaine version!

			}
		}
		else {
			this.enonce=txt;
			this.resultat[0]="";
		}
	}
	this.repondu="";
}


// CLASSE CL_question

function CL_question(txt) {
	var pos=txt.indexOf("//");
	if (pos==-1) {
		this.enonce=txt;
		this.bareme=1;
	}
	else {
		this.enonce=txt.substring(0,pos);
		this.bareme=1*txt.substring(pos+2,txt.length);
	}
	this.etat="libre";
	this.schema="aucun";
	this.larg="";
	this.haut="";
	this.reponse=new Array();
	this.aide=new Array();
	this.ajouter_reponse=ajouter_reponse;
	this.ajouter_aide=ajouter_aide;
	this.ajouter_schema=ajouter_schema;
}
function ajouter_reponse(txt) {
	var debut=txt.substring(0,3);
	if (debut=="[x]"||debut=="[ ]") {
		this.type="cases a cocher";
		this.reponse[this.reponse.length]=new CL_reponse(txt);
	}
	else if (debut=="(x)"||debut=="(o)"||debut=="( )") {
		this.type="boutons radio";
		this.reponse[this.reponse.length]=new CL_reponse(txt);
	}
	else {
		this.type="autre";
		var pos=txt.indexOf("]");
		if (pos==-1) this.reponse[this.reponse.length]=new CL_reponse(txt+"<br>");
		while (pos!=-1) {
			var ch=txt.substring(0,pos+1);
			this.reponse[this.reponse.length]=new CL_reponse(ch);
			txt=txt.substring(pos+1,txt.length);
			pos=txt.indexOf("]");
			if (pos==-1) this.reponse[this.reponse.length]=new CL_reponse(txt+"<br>");
		}
	}
}
function ajouter_aide(a,b) {
	this.aide[this.aide.length]=new CL_page(a,b);
}
function ajouter_schema(txt,largeur,hauteur) {
	this.schema="schemas/"+txt;
	this.larg=largeur;
	this.haut=hauteur;
}


// CLASSE CL_theme

function CL_theme(txt) {
	this.etat="libre";
	this.titre=txt;
	this.choisi="non";
	this.question=new Array();
	this.ajouter_question=ajouter_question;
}
function ajouter_question(txt) {
	this.question[this.question.length]=new CL_question(txt);
}


// CLASSE CL_qcm

function CL_qcm() {
	this.theme=new Array();
	this.ajouter_theme=ajouter_theme;
}
function ajouter_theme(txt) {
	this.theme[this.theme.length]=new CL_theme(txt);
}


// CLASSE CL_activite

function CL_activite() {
	this.debut=null;
	this.fin=null;
	this.nb_quest_choisi=0;
	this.nb_quest_faites=0;
	this.num_theme=0;
	this.num_question=0;
	this.note=0;
	this.note_maxi=0;
}


// CREATION DES OBJETS

var texte=new CL_text();
var option=new CL_option();
var qcm=new CL_qcm();
var activite=new CL_activite()

