Skip to content
Snippets Groups Projects
Commit ab841ffa authored by Milan Jaros's avatar Milan Jaros
Browse files

fix

parent 3f1af8bc
No related branches found
No related tags found
1 merge request!1Ncc v2.2.4
...@@ -227,25 +227,30 @@ export default { ...@@ -227,25 +227,30 @@ export default {
this.$refs.submitButton.click() this.$refs.submitButton.click()
}, },
checkQuestion(indexQ) { checkQuestion(indexQ, saveIndex) {
const question = this.form.questions[indexQ] const question = this.form.questions[indexQ]
const qTextSplit1 = question.text.replace('[n]', '').replace(']', '').split('[') // [1/1] const qTextSplit1 = question.text.replace('[n]', '').replace(']', '').split('[') // [1/1][1/2][1/3]
if (qTextSplit1.length > 1) { if (qTextSplit1.length > 1) {
let i let i
for (i = 0; i < qTextSplit1.length; i++) { for (i = 0; i < qTextSplit1.length; i++) {
const qTextSplit2 = qTextSplit1[i].split('/') // 1/1] const qTextSplit2 = qTextSplit1[i].split('/') // (1,1) (1,2) (1,3)
if (qTextSplit2.length > 1) { if (qTextSplit2.length > 1) {
const qi = parseInt(qTextSplit2[0]) const qi = parseInt(qTextSplit2[0]) // 1 1 1
const ai = parseInt(qTextSplit2[1]) const ai = parseInt(qTextSplit2[1]) // 1 2 3
if (this.answers[qi]) { if (this.answers[qi]) { // "q1": None
const answers = this.answers[qi].filter(answer => answer === ai) const answers = this.answers[qi].filter(answer => answer === ai) // "q1" : [a1,a2,a3,a4]
if (!answers.length) { if (!answers.length) {
continue // no answers, go to next question continue // no answers, go to next question
} else { } else {
return true return true
} }
} else {
if (saveIndex) {
showError(t('forms', 'Answer is required'))
throw 'Answer is required';
}
} }
} }
} }
...@@ -257,34 +262,27 @@ export default { ...@@ -257,34 +262,27 @@ export default {
getQuestions(saveIndex) { getQuestions(saveIndex) {
const questionsArray = [] const questionsArray = []
try { let index = this.questionIndex
let index = this.questionIndex
if (this.checkQuestion(index)) { if (this.checkQuestion(index)) {
questionsArray.push(this.form.questions[index]) questionsArray.push(this.form.questions[index])
} }
while (index < this.form.questions.length - 1) {
index = index + 1
const textQ = this.form.questions[index].text
if (textQ.includes('[n]') && questionsArray.length > 0) {
// index = index - 1
break
}
if (this.checkQuestion(index)) { while (index < this.form.questions.length - 1) {
questionsArray.push(this.form.questions[index]) index = index + 1
} const textQ = this.form.questions[index].text
if (textQ.includes('[n]') && questionsArray.length > 0) {
// index = index - 1
break
} }
if (saveIndex) { if (this.checkQuestion(index, saveIndex)) {
this.questionIndex = index questionsArray.push(this.form.questions[index])
} }
}
} catch (error) { if (saveIndex) {
this.logError = ' ' + error this.questionIndex = index
console.error(error)
showError(t('forms', 'There was an error in the form'))
} }
// const qTextSplit = questionsArray[0].text //.split('[') // [1/1] // const qTextSplit = questionsArray[0].text //.split('[') // [1/1]
...@@ -300,9 +298,8 @@ export default { ...@@ -300,9 +298,8 @@ export default {
try { try {
if (this.questionIndex < this.form.questions.length - 1) { if (this.questionIndex < this.form.questions.length - 1) {
this.questionIndex = this.questionIndex + 1
const questions = this.getQuestions(true) const questions = this.getQuestions(true)
logError += ' ' + questions.length
if (questions.length > 0) { if (questions.length > 0) {
return return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment