function findNextLevel() {
        var nbStateZero = 0;
        var nbStateOne = 0;
        var nbStateTwo = 0;
        var idQuestion = trace[trace.length - 1].id;
        var levelQuestion = trace[trace.length - 1].level;
        for (var i = trace.length - 1; i >= 0; --i) {
            if (idQuestion === trace[i].id) {
                if (trace[i].state === 0) nbStateZero++;
                if (trace[i].state === 1) nbStateOne++;
                if (trace[i].state === 2) nbStateTwo++;
            }
            //console.log("nombre succes " + nbStateOne);
            //console.log("nombre echec " + nbStateZero);
            //console.log("nombre abandon " + nbStateTwo);
        }
        if ((nbStateZero > 4 || nbStateTwo === 1) && levelQuestion > 1) {
            // level down
            --levelQuestion;
        }
        if ((nbStateZero < 2 && nbStateOne === 1) && levelQuestion < 3) {
            // level up
            ++levelQuestion;
        }
        nextLevel = levelQuestion;
        //console.log("niveau suivant : " + nextLevel);
        // if(nbStateZero%2===0) //to do donner indice
        return (nbStateZero % 2 === 0);
    }
/**
     * Allows to determine the level of the next question depending on the
     * previous questions outcomes.
     */
Allows to determine the level of the next question depending on the
previous questions outcomes.
Allows to determine the level of the next question depending on the previous questions outcomes .
function findNextLevel() {
        var nbStateZero = 0;
        var nbStateOne = 0;
        var nbStateTwo = 0;
        var idQuestion = trace[trace.length - 1].id;
        var levelQuestion = trace[trace.length - 1].level;
        for (var i = trace.length - 1; i >= 0; --i) {
            if (idQuestion === trace[i].id) {
                if (trace[i].state === 0) nbStateZero++;
                if (trace[i].state === 1) nbStateOne++;
                if (trace[i].state === 2) nbStateTwo++;
            }
        }
        if ((nbStateZero > 4 || nbStateTwo === 1) && levelQuestion > 1) {
            --levelQuestion;
        }
        if ((nbStateZero < 2 && nbStateOne === 1) && levelQuestion < 3) {
            ++levelQuestion;
        }
        nextLevel = levelQuestion;
        return (nbStateZero % 2 === 0);
    }
function findNextLevel ( ) { var nbStateZero = 0 ; var nbStateOne = 0 ; var nbStateTwo = 0 ; var idQuestion = trace [ trace . length - 1 ] . id ; var levelQuestion = trace [ trace . length - 1 ] . level ; for ( var i = trace . length - 1 ; i >= 0 ; -- i ) { if ( idQuestion === trace [ i ] . id ) { if ( trace [ i ] . state === 0 ) nbStateZero ++ ; if ( trace [ i ] . state === 1 ) nbStateOne ++ ; if ( trace [ i ] . state === 2 ) nbStateTwo ++ ; } } if ( ( nbStateZero > 4 || nbStateTwo === 1 ) && levelQuestion > 1 ) { -- levelQuestion ; } if ( ( nbStateZero < 2 && nbStateOne === 1 ) && levelQuestion < 3 ) { ++ levelQuestion ; } nextLevel = levelQuestion ; return ( nbStateZero % 2 === 0 ) ; }
Allows to determine the level of the next question depending on the
 previous questions outcomes.
Allows to determine the level of the next question depending on the previous questions outcomes .
//console.log("nombre succes " + nbStateOne); //console.log("nombre echec " + nbStateZero); //console.log("nombre abandon " + nbStateTwo); // level down // level up //console.log("niveau suivant : " + nextLevel); // if(nbStateZero%2===0) //to do donner indice