Support the ongoing development of Laravel.io →
posted 5 years ago
Last updated 2 years ago.
0
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;
}
 }
Last updated 5 years ago.
0

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'}, 

        ]

      } 

    ]

  };
Last updated 5 years ago.
0

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'}, 

        ]

      } 

    ]

  };
Last updated 5 years ago.
0

what is correctanswer() ?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.