added logic to get quiz questions and answers

This commit is contained in:
2017-02-01 22:36:47 -08:00
parent 8013e88e1b
commit 63a4cac313
3 changed files with 56 additions and 7 deletions

View File

@@ -14,9 +14,35 @@
vm.dataServices = DataServices;
vm.questionAnswered = questionAnswered;
vm.activeQuestion = 0;
vm.setActiveQuestion = setActiveQuestion;
var numQuestionsAnswered = 0;
function setActiveQuestion () {
var breakOut = false;
var quizLength = DataServices.quizQuestions.length - 1;
while (!breakOut) {
vm.activeQuestion = vm.activeQuestion < quizLength?++vm.activeQuestion:0;
if (DataServices.quizQuestions[activeQuestion].selected === null)
breakOut = true;
}
}
function questionAnswered () {
var quizLength = DataServices.quizQuestions.length;
if (DataServices.quizQuestions[vm.activeQuestion].selected !== null){
numQuestionsAnswered++;
if (numQuestionsAnswered >= quizLength) {
// Finilise the quiz
}
}
vm.setActiveQuestion();
}
}