mirror of
https://github.com/Raghu-Ch/TurtleFactsQuiz.git
synced 2026-02-10 03:33:01 -05:00
added logic to get quiz questions and answers
This commit is contained in:
@@ -13,3 +13,15 @@
|
|||||||
.answer:hover{
|
.answer:hover{
|
||||||
cursor: pointer;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
23
index.html
23
index.html
@@ -71,7 +71,7 @@
|
|||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<p><strong>locations:</strong>{{list.activeTurtle.locations}}</p>
|
<p><strong>locations:</strong>{{list.activeTurtle.locations}}</p>
|
||||||
<p><strong>Size:</strong>{{list.activeTurtle.size}}</p>
|
<p><strong>Size:</strong>{{list.activeTurtle.size}}</p>
|
||||||
<p><strong>Average: Lifespan</strong>{{list.activeTurtle.lifespan}}</p>
|
<p><strong>Average Lifespan:</strong>{{list.activeTurtle.lifespan}}</p>
|
||||||
<p><strong>Dite:</strong>{{list.activeTurtle.dite}}</p>
|
<p><strong>Dite:</strong>{{list.activeTurtle.dite}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12 top-buffer">
|
<div class="col-xs-12 top-buffer">
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-8">
|
<div class="col-xs-8">
|
||||||
<h2><progress:</h2>
|
<h3>progress:</h3>
|
||||||
<div class="btn-toolbar">
|
<div class="btn-toolbar">
|
||||||
<button class="btn"
|
<button class="btn"
|
||||||
ng-repeat = "question in quiz.dataServices.quizQuestions"
|
ng-repeat = "question in quiz.dataServices.quizQuestions"
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
<p>Unanswered</p>
|
<p>Unanswered</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> <!-- legend ends -->
|
||||||
</div> <!-- progress section -->
|
</div> <!-- progress section -->
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -130,19 +130,30 @@
|
|||||||
<h4>{{quiz.activeQuestion+1 + ". " + quiz.dataServices.quizQuestions[quiz.activeQuestion].text}}</h4>
|
<h4>{{quiz.activeQuestion+1 + ". " + quiz.dataServices.quizQuestions[quiz.activeQuestion].text}}</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row"
|
||||||
|
ng-if = "quiz.dataServices.quizQuestions[quiz.activeQuestion].type === 'text'" >
|
||||||
<div class="col-sm-6" ng-repeat = "answer in quiz.dataServices.quizQuestions[quiz.activeQuestion].possibilities">
|
<div class="col-sm-6" ng-repeat = "answer in quiz.dataServices.quizQuestions[quiz.activeQuestion].possibilities">
|
||||||
<h4 class ="answer">
|
<h4 class ="answer">
|
||||||
{{answer.answer}}
|
{{answer.answer}}
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row"
|
||||||
|
ng-if = "quiz.dataServices.quizQuestions[quiz.activeQuestion].type === 'image'">
|
||||||
|
<div class="col-sm-6" ng-repeat = "answer in quiz.dataServices.quizQuestions[quiz.activeQuestion].possibilities">
|
||||||
|
<div class="image-answer">
|
||||||
|
<img ng-src="{{answer.answer}}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- ng-click will call the questionAnswered method on the controller -->
|
||||||
<button class = "btn btn-warning" ng-click = "quiz.questionAnswered()">Continue</button>
|
<button class = "btn btn-warning" ng-click = "quiz.questionAnswered()">Continue</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div> <!-- quizCtrl ends -->
|
||||||
</div>
|
</div> <!-- container ends -->
|
||||||
<!-- third party scripts -->
|
<!-- third party scripts -->
|
||||||
<!-- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.2/angular.min.js"></script> -->
|
<!-- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-rc.2/angular.min.js"></script> -->
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
|
||||||
|
|||||||
@@ -14,9 +14,35 @@
|
|||||||
vm.dataServices = DataServices;
|
vm.dataServices = DataServices;
|
||||||
vm.questionAnswered = questionAnswered;
|
vm.questionAnswered = questionAnswered;
|
||||||
vm.activeQuestion = 0;
|
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 () {
|
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