/*
Code du didacticiel
documentation/sectionspartie5.html
*/
// Exemple de Graphe de test
// j3p.html?graphe=[1,"didacticiel1",[{pe:">=0",nn:"2",conclusion:"Etape 2"}]];[2,"modele",[{pe:">=0",nn:"fin",conclusion:"fin"}]];
j3p.Sectiondidacticiel1 = {
"outils":["calculatrice"],
"parametres":[
["nbrepetitions",2,"entier","aucun"],
["indication","","string","aucun"],
["limite","","entier","Temps disponible par répétition, en secondes"],
["nbchances",2,"entier",""],
["entier","[4;15]","string","Intervalle auquel appartient le nombre"],
["typequestion","double","string",'"double" || "triple" || "lesdeux" ']
],
"pe":[
{"pe":0}
]
};
Parcours.prototype.Sectiondidacticiel1 = function(){
this.Sectiondidacticiel1.unefonctionpersoglobale = function(){
alert("fonction perso et globale")
}
function fonction_locale(){
alert("fonction perso locale")
}
function _Donnees() {
// NE PAS OUBLIER DE CHANGER LE NOM DE LA VARIABLE
this.nomSection = "didacticiel1";
document.title += this.nomSection ;
this.typesection="primaire";
this.touche_entree = true;
this.nbrepetitions = 2;
this.surchargenbrepetitions = true;
this.nbetapes= 1;
this.nbitems = this.nbetapes*this.nbrepetitions;
this.indication = "";
this.nbchances = 2;
this.numeroessai = 1;
this.structure="presentation1";
this.entier = "[4;15]";
this.typequestion = "lesdeux"; // || "triple" || "lesdeux" || "double"
this.textes = {
phrase1 : "Ecris"
}
//Par défaut, pas de temps limite. Décommentez pour avoir un temps limite par défaut. En secondes.
//this.limite =5;
this.pe=0;
}
switch (this.etat){
case "enonce":
//code exécuté au lancement de la section
if (this.debutdelasection){
this.debutdelasection = false;
this.DonneesSection = new _Donnees();
J3PSurcharge();
this.StructurePage(this.DonneesSection.structure);
this.Dimensions(0.6);
this.stockage=[0,0,0,0,0,0,0,0,0,0,0];
this.typederreurs=[0,0,0,0,0,0,0,0,0,0,0];
this.score=0
this.Titre("TITRE",false);
this.BoutonValider(this.zones.ID);
this.BoutonContinuer(this.zones.ID);
this.BoutonSectionContinuer(this.zones.ID);
this.CacheBoutonSectionContinuer();
if (this.DonneesSection.indication !="") this.Indication(this.zones.IG,this.DonneesSection.indication);
//this.compteARebours = {conteneur:this.zones.MG,actif:false,left:0,top:0,width:300,height:30,couleur:"#F00"}
//this.compteARebours.actif = true;
//code de création de la boîte de boutons
this.fenetresjq = [
{name:"Boutons",title:"Outils",width:150,height:120,left:650,top:130,id:"fenetreBoutons"},
{name:"Calculatrice",title:"",width:300,left:430,top:250}
];
//J3PCreefenetres();
//J3PCreeBoutonFenetre("Calculatrice","fenetreBoutons",{top:10,left:10},"Calculatrice")
//J3PAfficheunefenetre("Boutons");
}
else {
this.Efface("MG");
if ((this.DonneesSection.structure=="presentation1")||(this.DonneesSection.structure=="presentation1bis"))
this.Efface("MD");
this.AfficheBoutonValider();
this.DonneesSection.numeroessai = 1;
}
// OBLIGATOIRE
this.Barredetat(this.zones.HD);
this.GestionTemps();
this.CacheBoutonContinuer();
/////////////////////////////////////
/* LE CODE PRINCIPAL DE LA SECTION */
/////////////////////////////////////
var nb = J3PRandom(this.DonneesSection.entier);
this.stockage[1]=nb
var ch="";
switch (this.DonneesSection.typequestion){
case "double" : {
ch="double";
this.stockage[0]=2*nb;
this.stockage[2]="double"
break;
}
case "triple" : {
ch="triple";
this.stockage[0]=3*nb;
this.stockage[2]="triple"
break;
}
case "lesdeux" : {
var choix = J3PgetRandomInt(1, 2)
if (choix==1) {
ch="triple";
this.stockage[0]=3*nb;
this.stockage[2]="triple"
} else {
ch="double";
this.stockage[0]=2*nb;
this.stockage[2]="double"
}
break;
}
}
J3PDiv(this.zones.MG,{id:"enonce",contenu:"Quel est le "+ch+ " du nombre "+nb+" ?",coord:[10,50],style:this.styles.moyen.enonce});
J3PDiv(this.zones.MG,{id:"reponse",contenu:"",coord:[100,100],style:this.styles.moyen.enonce});
J3PAjouteZoneTexte("reponse",{id:"zdtreponse",maxchars:"5",restrict:"0-9,",texte:"",width:80});
J3PFocus("zdtreponse")
J3PDiv(this.zones.MG,{id:"explications",contenu:"",coord:[10,200],style:this.styles.moyen.correction});
/////////////////////////////////////////
/* FIN DU CODE PRINCIPAL DE LA SECTION */
/////////////////////////////////////////
J3PDiv(this.zones.MD,{id:"correction",contenu:"",coord:[20,100],style:this.styles.moyen.explications});
this.finEnonce();
break;//case "enonce":
case "correction":
// On teste si une réponse a été saisie
var repEleve=J3PValeurde("zdtreponse");
if ((repEleve =="")&&(this.typereponse!=0)){
J3PElement("correction").style.color = this.styles.cfaux;
J3PElement("correction").innerHTML = this.phrases.reponsemanquante;
J3PFocus("zdtreponse");
this.AfficheBoutonValider();
}
// Une réponse a été saisie
else {
// Bonne réponse
if ( repEleve == J3PNumToStr(this.stockage[0]) || repEleve == String(this.stockage[0])) {
this.detruitEcouteurs();
this.score++;
J3PElement("correction").style.color = this.styles.cbien;
J3PElement("correction").innerHTML=this.phrases.cbien;
this.typederreurs[0]++;
this.CacheBoutonValider();
this.etat ="navigation";this.oncontinue();
} else {
// Pas de bonne réponse
J3PElement("correction").style.color = this.styles.cfaux;
// A cause de la limite de temps :
if (this.typereponse==0){//limite de temps
this.detruitEcouteurs();
J3PElement("correction").innerHTML=this.phrases.tempsdepasse;
this.typederreurs[10]++;
this.CacheBoutonValider();
J3PElement("correction").innerHTML+="
La solution était "+this.stockage[0]
// RECOPIER LA CORRECTION ICI !
this.etat ="navigation";this.oncontinue();
}
// Réponse fausse :
else {
J3PElement("correction").innerHTML=this.phrases.cfaux;
this.DonneesSection.numeroessai++;
// S'il y a plus de deux chances,on appelle à nouveau le bouton Valider
if (this.DonneesSection.numeroessai<=this.DonneesSection.nbchances) {
J3PElement("correction").innerHTML+=this.phrases.autrechance
this.typederreurs[1]++;
// indication éventuelle ici
}
// Erreur au nème essai
else {
this.detruitEcouteurs();
this.CacheBoutonValider();
J3PElement("correction").innerHTML+=this.phrases.correction;
J3PElement("correction").innerHTML+="
La solution était "+this.stockage[0];
J3PElement("explications").innerHTML+="En effet le "+this.stockage[2]+" de "+this.stockage[1];
if (this.stockage[2]=="double")
J3PElement("explications").innerHTML+=" est égal à
2 × "+this.stockage[1]+" = "+(2*this.stockage[1])
else
J3PElement("explications").innerHTML+=" est égal à
3 × "+this.stockage[1]+" = "+(3*this.stockage[1])
this.typederreurs[2]++;
this.etat ="navigation";this.oncontinue();
}
}
}
}
this.finCorrection();
break;//case "correction":
case "navigation":
if (this.Sectionterminee()){
//On détermine la phrase d'état renvoyée par la section
this.parcours.pe = this.score / this.DonneesSection.nbitems;
this.AfficheBoutonSectionContinuer();
this.desactiveReturn();
this.Focus("sectioncontinuer");
}
else {
this.sections.itemCourant ++;
this.etat ="enonce";
this.AfficheBoutonContinuer();
this.desactiveReturn();
this.Focus("boutoncontinuer");
}
this.finNavigation();
break;//case "navigation":
}
}