Hi All
I have been following a great tutorial on building a quiz app with angular, link supplied below:
I am trying to expand a bit on this to add scoring at the end of the quiz but I don’t seem to be able to get this functionality working. Here’s an amendment I have tried to make to the code to get a score:
$scope.isCorrect = function (question) {
// inserted declaration and initialisation here
$scope.score = 0;
var result = 'correct';
// inserted if statement in here to check whether score needs to be added after answer check
if(result == true){
$scope.score++;
}
question.Options.forEach(function (option, index, array) {
if (helper.toBool(option.Selected) != option.IsAnswer) {
result = 'wrong';
return false;
}
});
return result;
};
It’s only a basic start so I’m probably way off. I only seem to be getting a score of 1 even though I try to increment the score for each correct answer.
I’d be grateful for any help with this to try and get it working.
Thanks for any help.