mirror of
https://github.com/Raghu-Ch/TurtleFactsQuiz.git
synced 2026-02-10 11:33:01 -05:00
added logic to get quiz questions and answers
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user