for the requirement of test paper generation, try to implement it with vue. The
code is roughly structured as follows:
<div v-for="(big, index) in all" ><!-- -->
:<input> :{{bigtotal}}
<button @click="addsmall"></button>
<div v-for="(question, index) in big.question" ><!-- -->
:<input >
</div>
</div>
<button @click="addbig"></button>
var vu = new Vue({
el: "-sharptodo-list-example",
data: {
all:[],
onebig:{qtype:"",title:"xxx",bmark:0,questions:[]},//
onesmall:{smark:0,stem:"",answer1:"",answer2:"",answer3:"",answer4:""}//
},
methods: {
addbig: function() {//
let onebig_str = JSON.parse(JSON.stringify(this.onebig));
this.all.push(onebig_str);
//....
},
addsmall: function(index) {//
let onebig_str = JSON.parse(JSON.stringify(vu.onesmall));
this.all[index].questions.push(onebig_str);
//....
});
},
}
})
question: when the score of the small question is preset, the score of all the small questions within the big question will change. Modify the score of a small question, and the total score of the big question will be calculated automatically.
since all the big and small questions are generated by clicking the button push, there are two for loops here, how can I calculate the score?
ideas for implementation