ali 2 anni fa
parent
commit
e33629a008

+ 7 - 3
src/components/FormBuilderCustumComponents/QuestionsCreateAndAppend/CreateQuestionForm.vue

@@ -45,6 +45,10 @@ export default {
       type: Number,
       default: null
     },
+    testSetId: {
+      type: Number,
+      default: null
+    },
     questionType: {
       default: 'QUESTION_BANK',
       type: String
@@ -71,10 +75,10 @@ export default {
     }
   },
   created() {
-    if (this.questionType === 'QUESTION_BANK') {
+    if (this.testId) {
       this.api = APIGateway.test.APIAdresses.appendQuestion(this.testId)
-    } else if (this.questionType === 'EVENT') {
-      this.api = APIGateway.testSet.APIAdresses.appendQuestion(this.testId)
+    } else if (this.testSetId) {
+      this.api = APIGateway.testSet.APIAdresses.appendQuestion(this.testSetId)
     }
   },
   mounted() {

+ 8 - 3
src/components/FormBuilderCustumComponents/QuestionsCreateAndAppend/QuestionsCreateAndAppend.vue

@@ -110,6 +110,7 @@
               transition-show="slide-up"
               transition-hide="slide-down">
       <create-question-form :test-id="testId"
+                            :test-set-id="testSetId"
                             :question-type="questionType"
                             @onQuestionCreated="onQuestionCreated" />
     </q-dialog>
@@ -157,6 +158,10 @@ export default {
       default: null,
       type: [Number, String, Boolean]
     },
+    testSetId: {
+      type: Number,
+      default: null
+    },
     unitId: {
       default: null,
       type: [Number, String, Boolean]
@@ -407,7 +412,7 @@ export default {
     },
     refreshTestQuestions () {
       this.test.loading = true
-      if (this.questionType === 'QUESTION_BANK') {
+      if (this.testId) {
         APIGateway.test.get(this.testId)
           .then((test) => {
             this.test.loading = false
@@ -417,8 +422,8 @@ export default {
           .catch(() => {
             this.test.loading = false
           })
-      } else if (this.questionType === 'EVENT') {
-        APIGateway.testSet.get(this.testId)
+      } else if (this.testSetId) {
+        APIGateway.testSet.get(this.testSetId)
           .then((testSet) => {
             this.test.loading = false
             this.localValue = testSet.inputData.test_set_questions

+ 1 - 1
src/components/Widgets/TestSet/AdminEventTestSetShow/AdminEventTestSetShow.vue

@@ -58,7 +58,7 @@ export default {
         { type: 'hidden', name: 'type', responseKey: 'type', value: 'QUESTIONNAIRE' },
         // { type: BtnControlComp, name: 'btnCreateQuestion', responseKey: 'btnCreateQuestion', label: 'تعریف سوال جدید', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' },
         // { type: QuestionsSelectorComp, name: 'test_set_questions', responseKey: 'test_set_questions', unitId: false, questionType: 'EVENT', col: 'col-md-12 col-12' },
-        { type: QuestionsCreateAndAppendComp, name: 'test_set_questions', responseKey: 'test_set_questions', testId: testSetId, questionType: 'EVENT', ignoreValue: true, col: 'col-md-12 col-12' },
+        { type: QuestionsCreateAndAppendComp, name: 'test_set_questions', responseKey: 'test_set_questions', testSetId, questionType: 'EVENT', ignoreValue: true, col: 'col-md-12 col-12' },
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تایید نهایی', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
       ]
     }