|
@@ -14,7 +14,7 @@
|
|
|
:show-save-button="false"
|
|
:show-save-button="false"
|
|
|
:show-reload-button="false"
|
|
:show-reload-button="false"
|
|
|
:redirect-after-edit="false"
|
|
:redirect-after-edit="false"
|
|
|
- :after-load-input-data="afterLoadInputData">
|
|
|
|
|
|
|
+ :before-load-input-data="beforeLoadInputData">
|
|
|
<template #toolbar>
|
|
<template #toolbar>
|
|
|
<q-btn v-close-popup
|
|
<q-btn v-close-popup
|
|
|
icon="close"
|
|
icon="close"
|
|
@@ -31,8 +31,10 @@ import { Question } from 'src/models/Question.js'
|
|
|
import { APIGateway } from 'src/api/APIGateway.js'
|
|
import { APIGateway } from 'src/api/APIGateway.js'
|
|
|
import BtnControl from 'src/components/Control/btn.vue'
|
|
import BtnControl from 'src/components/Control/btn.vue'
|
|
|
import { FormBuilderAssist } from 'quasar-form-builder'
|
|
import { FormBuilderAssist } from 'quasar-form-builder'
|
|
|
|
|
+import QuestionChoices from 'src/components/FormBuilderCustumComponents/QuestionChoices/QuestionChoices.vue'
|
|
|
|
|
|
|
|
const BtnControlComp = shallowRef(BtnControl)
|
|
const BtnControlComp = shallowRef(BtnControl)
|
|
|
|
|
+const QuestionChoicesComp = shallowRef(QuestionChoices)
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'EditQuestionForm',
|
|
name: 'EditQuestionForm',
|
|
@@ -63,7 +65,9 @@ export default {
|
|
|
{ type: 'inputEditor', name: 'correct_answer', responseKey: 'correct_answer', label: 'پاسخ', placeholder: ' ', col: 'col-12' },
|
|
{ type: 'inputEditor', name: 'correct_answer', responseKey: 'correct_answer', label: 'پاسخ', placeholder: ' ', col: 'col-12' },
|
|
|
{ type: 'input', name: 'mark', responseKey: 'mark', label: 'بارم پیشنهادی سوال', placeholder: ' ', col: 'col-md-3 col-12' },
|
|
{ type: 'input', name: 'mark', responseKey: 'mark', label: 'بارم پیشنهادی سوال', placeholder: ' ', col: 'col-md-3 col-12' },
|
|
|
{ type: 'select', name: 'level', responseKey: 'level', label: 'سطح سوال', placeholder: ' ', options: (new Question()).levelEnums, col: 'col-md-3 col-12' },
|
|
{ type: 'select', name: 'level', responseKey: 'level', label: 'سطح سوال', placeholder: ' ', options: (new Question()).levelEnums, col: 'col-md-3 col-12' },
|
|
|
|
|
+ { type: QuestionChoicesComp, name: 'choices', responseKey: 'choices_info', correctChoiceIndex: 0, col: 'col-12 flex justify-end' },
|
|
|
{ type: BtnControlComp, name: 'btn', label: 'ذخیره سوال', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' },
|
|
{ type: BtnControlComp, name: 'btn', label: 'ذخیره سوال', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' },
|
|
|
|
|
+ { type: 'hidden', name: 'correct_choice_index', responseKey: 'correct_choice_index' },
|
|
|
{ type: 'hidden', name: 'type', responseKey: 'type', value: 'QUESTION_BANK' }
|
|
{ type: 'hidden', name: 'type', responseKey: 'type', value: 'QUESTION_BANK' }
|
|
|
]
|
|
]
|
|
|
}
|
|
}
|
|
@@ -71,16 +75,24 @@ export default {
|
|
|
mounted() {
|
|
mounted() {
|
|
|
this.setInputs()
|
|
this.setInputs()
|
|
|
this.mounted = true
|
|
this.mounted = true
|
|
|
|
|
+ this.$bus.on('onChangeCorrectChoiceIndexInQuestionChoicesInput', (correctChoiceIndex) => {
|
|
|
|
|
+ FormBuilderAssist.setAttributeByName(this.inputs, 'correct_choice_index', 'value', correctChoiceIndex)
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
setInputs () {
|
|
setInputs () {
|
|
|
FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.edit)
|
|
FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.edit)
|
|
|
|
|
+ if (this.questionType === 'QUESTION_BANK') {
|
|
|
|
|
+ FormBuilderAssist.setAttributeByName(this.inputs, 'choices', 'type', 'hidden')
|
|
|
|
|
+ FormBuilderAssist.setAttributeByName(this.inputs, 'choices', 'ignoreValue', true)
|
|
|
|
|
+ }
|
|
|
if (this.questionType === 'EVENT') {
|
|
if (this.questionType === 'EVENT') {
|
|
|
FormBuilderAssist.setAttributeByName(this.inputs, 'mark', 'type', 'hidden')
|
|
FormBuilderAssist.setAttributeByName(this.inputs, 'mark', 'type', 'hidden')
|
|
|
FormBuilderAssist.setAttributeByName(this.inputs, 'level', 'type', 'hidden')
|
|
FormBuilderAssist.setAttributeByName(this.inputs, 'level', 'type', 'hidden')
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- afterLoadInputData () {
|
|
|
|
|
|
|
+ beforeLoadInputData (responseData) {
|
|
|
|
|
+ FormBuilderAssist.setAttributeByName(this.inputs, 'choices', 'correctChoiceIndex', responseData.correct_choice_index)
|
|
|
this.entityLoading = false
|
|
this.entityLoading = false
|
|
|
},
|
|
},
|
|
|
edit() {
|
|
edit() {
|
|
@@ -102,6 +114,7 @@ export default {
|
|
|
.EditQuestionForm {
|
|
.EditQuestionForm {
|
|
|
.entity-edit {
|
|
.entity-edit {
|
|
|
height: 100vh;
|
|
height: 100vh;
|
|
|
|
|
+ overflow: auto;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|