From 63a4cac31356eb0acce932be8809aa8974bee445 Mon Sep 17 00:00:00 2001 From: Raghu-Ch Date: Wed, 1 Feb 2017 22:36:47 -0800 Subject: [PATCH] added logic to get quiz questions and answers --- css/style.css | 12 ++++++++++++ index.html | 23 +++++++++++++++++------ js/controllers/quiz.js | 28 +++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/css/style.css b/css/style.css index 30cbe4c..041866d 100644 --- a/css/style.css +++ b/css/style.css @@ -13,3 +13,15 @@ .answer:hover{ cursor: pointer; } +.image-answer{ + cursor: pointer; + height: 350px; + width: 100%; + overflow: hidden; + border-radius: 10px; + margin-bottom: 20px; +} +.image-answer img{ + width: 100%; + height: auto; +} diff --git a/index.html b/index.html index 7c79476..48a6f38 100644 --- a/index.html +++ b/index.html @@ -71,7 +71,7 @@

locations:{{list.activeTurtle.locations}}

Size:{{list.activeTurtle.size}}

-

Average: Lifespan{{list.activeTurtle.lifespan}}

+

Average Lifespan:{{list.activeTurtle.lifespan}}

Dite:{{list.activeTurtle.dite}}

@@ -93,7 +93,7 @@
-

+

progress:

-
+
@@ -130,19 +130,30 @@

{{quiz.activeQuestion+1 + ". " + quiz.dataServices.quizQuestions[quiz.activeQuestion].text}}

-
+

{{answer.answer}}

+
+
+
+ +
+
+
+ +
- - + + diff --git a/js/controllers/quiz.js b/js/controllers/quiz.js index 03a6c9a..856fdec 100644 --- a/js/controllers/quiz.js +++ b/js/controllers/quiz.js @@ -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(); } }