|
|
@@ -68,9 +68,11 @@ import { shallowRef } from 'vue'
|
|
|
import { EntityCreate } from 'quasar-crud'
|
|
|
import { APIGateway } from 'src/api/APIGateway.js'
|
|
|
import { AnswerBook } from 'src/models/AnswerBook.js'
|
|
|
+import BtnControl from 'src/components/Control/btn.vue'
|
|
|
import { FormBuilderAssist } from 'quasar-form-builder'
|
|
|
import QuestionChoices from 'src/components/FormBuilderCustumComponents/QuestionChoices/QuestionChoices.vue'
|
|
|
|
|
|
+const BtnControlComp = shallowRef(BtnControl)
|
|
|
const QuestionChoicesComp = shallowRef(QuestionChoices)
|
|
|
|
|
|
export default {
|
|
|
@@ -120,7 +122,40 @@ export default {
|
|
|
{ type: 'input', name: 'answer_text', label: 'متن پاسخ', placeholder: ' ', value: answerSheetItem.answer_text, inputType: 'textarea', col: 'col-12' },
|
|
|
{ type: 'file', name: 'answer_attachment', label: 'فایل پیوست', placeholder: ' ', value: answerSheetItem.answer_attachment, col: 'col-12' },
|
|
|
{ type: 'hidden', name: 'answer_book', value: this.answerBook.id },
|
|
|
- { type: 'hidden', name: 'test_question', value: answerSheetItem.test_question }
|
|
|
+ { type: 'hidden', name: 'test_question', value: answerSheetItem.test_question },
|
|
|
+ {
|
|
|
+ type: BtnControlComp,
|
|
|
+ name: 'btn',
|
|
|
+ responseKey: 'btn',
|
|
|
+ label: 'تایید و ادامه',
|
|
|
+ placeholder: ' ',
|
|
|
+ atClick: () => {
|
|
|
+ this.sendAnswer(answerSheetIndex)
|
|
|
+ // const answerText = FormBuilderAssist.getInputsByName(this.questionInputs[answerSheetIndex], 'answer_text').value
|
|
|
+ // if (!answerText && !hasChoise) {
|
|
|
+ // this.$q.notify({
|
|
|
+ // type: 'negative',
|
|
|
+ // message: 'لطفا متن پاسخ را کامل کنید.'
|
|
|
+ // })
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // const entityCreate = this.$refs['entityCreate_' + answerSheetIndex.toString()][0]
|
|
|
+ // entityCreate.entityLoading = true
|
|
|
+ // entityCreate.createEntity(false)
|
|
|
+ // .then(() => {
|
|
|
+ // if (this.questionPanel < this.answerBook.answer_sheet_info.list.length) {
|
|
|
+ // this.changeQuestion(this.questionPanel + 1)
|
|
|
+ // } else if (this.questionPanel === this.answerBook.answer_sheet_info.list.length) {
|
|
|
+ // this.confirmAnswers()
|
|
|
+ // }
|
|
|
+ // entityCreate.entityLoading = false
|
|
|
+ // })
|
|
|
+ // .catch(() => {
|
|
|
+ // entityCreate.entityLoading = false
|
|
|
+ // })
|
|
|
+ },
|
|
|
+ col: 'col-12 flex justify-end'
|
|
|
+ }
|
|
|
]
|
|
|
|
|
|
if (hasChoise) {
|
|
|
@@ -137,10 +172,14 @@ export default {
|
|
|
canEdit: false,
|
|
|
canDelete: false,
|
|
|
choicesInfo: answerSheetItem.test_question_info.question_info.choices_info,
|
|
|
- value: !answerSheetItem.answer_choice_index || isNaN(answerSheetItem.answer_choice_index) ? 0 : parseInt(answerSheetItem.answer_choice_index),
|
|
|
+ value: !answerSheetItem.answer_choice_index || isNaN(answerSheetItem.answer_choice_index) ? null : parseInt(answerSheetItem.answer_choice_index),
|
|
|
col: 'col-12 flex justify-end'
|
|
|
})
|
|
|
}
|
|
|
+ if (answerSheetIndex < this.answerBook.answer_sheet_info.list.length - 1) {
|
|
|
+ inputs[inputs.length - 1].type = 'hidden'
|
|
|
+ inputs[inputs.length - 1].value = null
|
|
|
+ }
|
|
|
|
|
|
this.questionInputs.push(inputs)
|
|
|
})
|
|
|
@@ -159,7 +198,7 @@ export default {
|
|
|
reject()
|
|
|
return
|
|
|
}
|
|
|
- if (!skipValidation && hasChoise && isNaN(answerSheetItem.answer_choice_index)) {
|
|
|
+ if (!skipValidation && hasChoise && (!answerSheetItem.answer_choice_index || isNaN(answerSheetItem.answer_choice_index))) {
|
|
|
this.$q.notify({
|
|
|
type: 'negative',
|
|
|
message: 'لطفا یک گزینه را انتخاب.'
|
|
|
@@ -167,6 +206,7 @@ export default {
|
|
|
reject()
|
|
|
return
|
|
|
}
|
|
|
+ debugger
|
|
|
const entityCreate = this.$refs['entityCreate_' + answerSheetIndex.toString()][0]
|
|
|
entityCreate.entityLoading = true
|
|
|
entityCreate.createEntity(false)
|