div class="frm_grp">
<a href="" v-on:click.prevent="submit, newmethod" class="submit_answer" >Submit</a>
</div>
<div class="answer_block " v-if="newmethoddata"> test </div>
//inside your export defaults
data: function () {
return {
newmethoddata: false
} //end data return
}, //end data
methods: {
newmethod: function(){
this.newmethoddata=true;
}
}
How to show the correct answer myCorrect? Currently I am getting undefined value in the responses.
<div class="answer_block ">
<h4>Answer Details</h4>
<p>Option {{question.responses | myCorrect}} is the correct answer</p>
</div>
Vue.filter('myCorrect',function(responses){
var mapping = ["A", "B", "C" , "D", "E"];
var $i = 0;
for(var response in responses){
console.log(response.text);
if(response.corect) {
break;
}
$i++;
}
return mapping[$i+1];
});
question data format
var quiz = {
title: 'My quiz',
questions: [
{
text: "Question 1",
responses: [
{text: 'Wrong, too bad.'},
{text: 'Right!', correct: true},
]
}, {
text: "Question 2",
responses: [
{text: 'Right answer', correct: true},
{text: 'Wrong answer'},
]
}
]
};
How to show the correct answer
<div class="answer_block ">
<h4>Answer Details</h4>
<p>Option {{correctanswer(question.responses)}} is the correct answer</p>
</div>
currently it is showing undefined
var quiz = {
title: 'My quiz',
questions: [
{
text: "Question 1",
responses: [
{text: 'Wrong, too bad.'},
{text: 'Right!', correct: true},
]
}, {
text: "Question 2",
responses: [
{text: 'Right answer', correct: true},
{text: 'Wrong answer'},
]
}
]
};
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community