fix object error
This commit is contained in:
parent
b2512c0961
commit
96abb6559e
2 changed files with 8 additions and 1 deletions
|
@ -8,6 +8,7 @@ export default new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
surveyCompletedOnce: false,
|
surveyCompletedOnce: false,
|
||||||
answers: [],
|
answers: [],
|
||||||
|
skipped: [],
|
||||||
questions: []
|
questions: []
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
@ -17,6 +18,9 @@ export default new Vuex.Store({
|
||||||
answerQuestion(state, pl) {
|
answerQuestion(state, pl) {
|
||||||
this.state.answers[pl.id] = pl.answer
|
this.state.answers[pl.id] = pl.answer
|
||||||
},
|
},
|
||||||
|
setSkipped(state, n) {
|
||||||
|
this.state.skipped[n] = true
|
||||||
|
},
|
||||||
setSurveyCompleted() {
|
setSurveyCompleted() {
|
||||||
this.state.surveyCompletedOnce = true
|
this.state.surveyCompletedOnce = true
|
||||||
},
|
},
|
||||||
|
@ -25,7 +29,9 @@ export default new Vuex.Store({
|
||||||
.then(res => {
|
.then(res => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
this.state.questions = res.data
|
this.state.questions = res.data
|
||||||
this.state.answers = Array.apply(0, Array(res.data.length)).map(function () {})
|
|
||||||
|
this.state.answers = Array(res.data.length).fill(0);
|
||||||
|
this.state.skipped = Array(res.data.length).fill(false);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.$store.commit("setSurveyCompleted")
|
this.$store.commit("setSurveyCompleted")
|
||||||
|
this.$store.commit("setSkipped", this.$route.params.id)
|
||||||
router.push('/results')
|
router.push('/results')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue