function stage(codeStage,style){this.codeStage=codeStage;this.codeGroupe=''; this.groupeCourant=''; this.nomGroupe='';this.titre='';this.role='0001';this.style="";if (style!="x"){this.style=style;}this.site=''; this.idTuteur='';this.nomTuteur='';this.prenomTuteur='';this.valide='';this.prerequis='';this.prerequisCompile='';this.telecharge='';this.description='';this.fenetre='';this.faq=0; this.RACINE_stage;this.anon=false;this.reglesVerif=false; this.accessible=true; this.tabRegleInsc; this.course_status='not attempted';this.score_raw='';this.scoreMbr='';this.dateTropTot='non';this.dateTropTard='non';this.dateFin='';this.dateDebut='';this.dateInsc;this.creneau1='';this.creneau2='';this.horsCreneau=false;this.accesMD='non';this.tabAutorise; this.refusAutorisation; this.necessiteAutorisation; this.estAuteur=false;this.estContibuteur=false;this.questSatisf=false;this.apercu=false;this.init=STG_init;this.getCodeGroupe=STG_getCodeGroupe;this.verifierRegles=STG_verifierRegles;this.verifierPrerequis=STG_verifierPrerequis;this.verifierCreneau=STG_verifierCreneau;this.desactiver=STG_desactiver;}function STG_init(codeGroupe,valide0,scoreMbr0) {this.codeGroupe=codeGroupe;this.RACINE_stage=top.serveur.RACINE_MosPub+'/'+this.codeStage+"/";this.tabRegleInsc=new Array();this.tabAutorise=new Array();this.accessible=true;if (this.valide==''){this.valide=valide0;this.scoreMbr=scoreMbr0;}}function STG_getCodeGroupe(){ return this.groupeCourant;}function STG_verifierRegles(){this.accessible=false;var i=0;var trouve=false;while ((!trouve)&&(i<this.tabRegleInsc.length)){var tabparam=this.tabRegleInsc[i].split("#");if (tabparam[2]!="oui"){this.refusAutorisation=false;this.necessiteAutorisation=false;var laRegle=new String(tabparam[1]);if (laRegle=="*"){laRegle="true";} else {laRegle=laRegle.replace(/vMos_/g,"serveur.vMos_");laRegle=laRegle.replace(/vMos_id/g,"id");laRegle=laRegle.replace(/vMos_nom/g,"nom");laRegle=laRegle.replace(/authByAdmin\(/g,"authByAdmin('"+this.codeStage+"',"+i+",");}try {var evlR=false;if (eval(laRegle)){evlR=true;}if (evlR||(laRegle.indexOf('authByAdmin')>=0)){trouve=true;this.codeGroupe=tabparam[0];var oTabl=top.planLMS.PF_donneObjet("tableau"+this.codeStage);oTabl.style.display="block";this.dateTropTard=tabparam[2];this.dateTropTot=tabparam[3];if ((this.dateTropTard=="oui")||(this.dateTropTot=="oui")){this.desactiver();this.dateFin=tabparam[6];this.dateDebut=tabparam[5];} else {if (evlR){this.accessible=true;this.verifierCreneau(tabparam[7],tabparam[8]);this.prerequis=tabparam[4]; if (tabparam[9]=="oui"){this.questSatisf=true;}} else {this.desactiver();}}}} catch(e){}}i++;}this.reglesVerif=true;}function STG_verifierPrerequis(){ var res=true; if (this.prerequis!=''){ res=false; if (this.prerequisCompile==''){ var expression=this.prerequis; var regle=new RegExp('(\\w+)',""); var prendPas="not,attempted,incomplete,browsed,completed,passed,failed";var debut="";var fin=expression;var n=0;var offs=expression.search(regle);while ((offs>=0)&&(n<100)){var tlemot=fin.match(regle);var lemot=tlemot[0];debut+=fin.substring(0,offs);fin=fin.substring(lemot.length+offs);if (prendPas.indexOf(lemot+',')<0){var derCar=fin.substring(0,1);if ((derCar=='=')||(derCar=='<')){lemot="parent.planLMS.MENU_statutPrerequis('"+lemot+"')";} else {lemot="parent.planLMS.MENU_testPrerequis('"+lemot+"')";}}n++;offs=fin.search(regle);debut+=lemot;}expression=debut+fin; expression=expression.replace(/&/g,'&&'); expression=expression.replace(/\|/g,'||'); expression=expression.replace(/~/g,'!'); expression=expression.replace(/=/g,'=='); expression=expression.replace(/<>/g,'!='); this.prerequisCompile=expression; } try { res=eval(this.prerequisCompile); } catch(e){} if (!res){ this.desactiver();} } return res;}function STG_verifierCreneau(cre1,cre2){this.creneau1=cre1;this.creneau2=cre2;if (((this.creneau1!='')||(this.creneau2!=''))){var dateAct=new Date();var tempsLoc=dateAct.getTime();this.horsCreneau=false;if (this.creneau1!=''){this.horsCreneau=testCreneau(tempsLoc,this.creneau1);}if (((this.horsCreneau)||(this.creneau1==''))&&(this.creneau2!='')){this.horsCreneau=testCreneau(tempsLoc,this.creneau2);}if (this.horsCreneau){this.accessible=false;this.desactiver();}}}function testCreneau(tempsLoc,creneau){var horsCreneau=false;var tabP=creneau.split("-");var tempsD=tabP[0].split(":");var tempsF=tabP[1].split(":");var heureD=Number(tempsD[0]);var heureF=Number(tempsF[0]);var dateD=new Date();dateD.setHours(heureD,Number(tempsD[1]),0);var dateF=new Date();dateF.setHours(heureF,Number(tempsF[1]),0);if (heureF>=heureD){if ((tempsLoc<dateD.getTime())||(tempsLoc>dateF.getTime())){horsCreneau=true;}} else {if (tempsLoc<dateD.getTime()){dateD.setDate(dateD.getDate()-1);} else if (tempsLoc>dateF.getTime()){dateF.setDate(dateF.getDate()+1);}if ((tempsLoc<dateD.getTime())||(tempsLoc>dateF.getTime())){horsCreneau=true;}}return horsCreneau;}function STG_desactiver(){this.accessible=false;var oLien=top.planLMS.PF_donneObjet("lien"+this.codeStage);if (oLien!=null){oLien.className="STY_accFormDesactive";}}function authByAdmin(codeStage,numReg,lsA){var res=false;var oStg=top.serveur.donneStage(codeStage);for (var n=0;n<oStg.tabAutorise.length;n++){var chAut=oStg.tabAutorise[n];var tabParm=chAut.split("/");if ((tabParm[0]==numReg)&&(tabParm[1]==lsA)){if (tabParm[2]=="1"){res=true;}else if (tabParm[2]=="0"){oStg.refusAutorisation=true;}}}oStg.necessiteAutorisation=true;return res;}
