Skip to content Skip to sidebar Skip to footer

AngularJS : Decision Tree Implementation

I am trying to write a quiz app.Below is the source code.Currently it is working like as below : On Click start Quiz,first questions shows up. User selects correct option and it m

Solution 1:

Change Your checkAnswer function like this

        scope.checkAnswer = function(question) {
            console.log(question);
            var options = question.options;
            for (var i = 0; i < options.length; i++) {
                if (options[i].selectedRadio) {
                    var ans = options[i].selectedRadio;
                }
            }
            console.log(question.options[question.answer]);
            if (question.options[question.answer].name == ans) {
                console.log(scope.id);
                scope.score++;
                scope.question[scope.id].answerMode = false;
                scope.answerMode = false;
                scope.id++;
                scope.getQuestion();
            }else{
                scope.question=scope.question.slice(0,question.trueQId);
                console.log(scope.question);
                scope.id=question.falseQid-1;
                scope.getQuestion();
            }
          };

It will give you understanding ,How to do it .. Thanks


Post a Comment for "AngularJS : Decision Tree Implementation"