Ver Fonte

fixed #336

ali há 2 anos atrás
pai
commit
75296bc54a

+ 2 - 1
src/api/models/TestSet.js

@@ -7,7 +7,8 @@ export default class TestSetAPI extends APIRepository {
     super('test_sets', appApi)
     super('test_sets', appApi)
     this.APIAdresses = {
     this.APIAdresses = {
       base: '/lma/test_sets',
       base: '/lma/test_sets',
-      byId: (id) => '/lma/test_sets/' + id
+      byId: (id) => '/lma/test_sets/' + id,
+      appendQuestion: (id) => '/lma/test_sets/' + id + '/append_question'
     }
     }
     this.CacheList = {
     this.CacheList = {
       base: this.name + this.APIAdresses.base
       base: this.name + this.APIAdresses.base

+ 10 - 1
src/components/FormBuilderCustumComponents/QuestionsCreateAndAppend/CreateQuestionForm.vue

@@ -55,7 +55,7 @@ export default {
     return {
     return {
       mounted: false,
       mounted: false,
       entityLoading: true,
       entityLoading: true,
-      api: APIGateway.test.APIAdresses.appendQuestion(this.testId),
+      api: null,
       entityIdKey: 'id',
       entityIdKey: 'id',
       entityParamKey: 'id',
       entityParamKey: 'id',
       showRouteName: 'Admin.Unit.Questions.Show',
       showRouteName: 'Admin.Unit.Questions.Show',
@@ -70,6 +70,13 @@ export default {
       ]
       ]
     }
     }
   },
   },
+  created() {
+    if (this.questionType === 'QUESTION_BANK') {
+      this.api = APIGateway.test.APIAdresses.appendQuestion(this.testId)
+    } else if (this.questionType === 'EVENT') {
+      this.api = APIGateway.testSet.APIAdresses.appendQuestion(this.testId)
+    }
+  },
   mounted() {
   mounted() {
     this.setInputs()
     this.setInputs()
     this.mounted = true
     this.mounted = true
@@ -79,7 +86,9 @@ export default {
       FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.edit)
       FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.edit)
       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, 'mark', 'ignoreValue', true)
         FormBuilderAssist.setAttributeByName(this.inputs, 'level', 'type', 'hidden')
         FormBuilderAssist.setAttributeByName(this.inputs, 'level', 'type', 'hidden')
+        FormBuilderAssist.setAttributeByName(this.inputs, 'level', 'ignoreValue', true)
       }
       }
     },
     },
     afterLoadInputData () {
     afterLoadInputData () {

+ 25 - 14
src/components/FormBuilderCustumComponents/QuestionsCreateAndAppend/QuestionsCreateAndAppend.vue

@@ -88,7 +88,7 @@
           </div>
           </div>
         </div>
         </div>
       </template>
       </template>
-      <template v-else-if="questionType === 'EVENT'">
+      <template v-else-if="questionType === 'EVENT' && localValue">
         <div class="row">
         <div class="row">
           <div class="col-md-4 col-12">
           <div class="col-md-4 col-12">
             تعداد سوالات انتخاب شده:
             تعداد سوالات انتخاب شده:
@@ -117,12 +117,12 @@
 </template>
 </template>
 
 
 <script>
 <script>
+import { Test } from 'src/models/Test.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import { FormBuilderAssist } from 'quasar-form-builder'
 import { FormBuilderAssist } from 'quasar-form-builder'
 import EditQuestionForm from './EditQuestionForm.vue'
 import EditQuestionForm from './EditQuestionForm.vue'
 import CreateQuestionForm from './CreateQuestionForm.vue'
 import CreateQuestionForm from './CreateQuestionForm.vue'
 import NormalizeNumber from 'src/assets/js/NormalizeNumber.js'
 import NormalizeNumber from 'src/assets/js/NormalizeNumber.js'
-import { Test } from 'src/models/Test.js'
 import { Question, QuestionList } from 'src/models/Question.js'
 import { Question, QuestionList } from 'src/models/Question.js'
 import { SessionTemplateList } from 'src/models/SessionTemplate.js'
 import { SessionTemplateList } from 'src/models/SessionTemplate.js'
 
 
@@ -176,7 +176,6 @@ export default {
       sessionQuestions: new QuestionList(),
       sessionQuestions: new QuestionList(),
       loadedQuestions: {},
       loadedQuestions: {},
 
 
-      api: APIGateway.question.APIAdresses.base,
       tableKeys: {
       tableKeys: {
         data: 'results',
         data: 'results',
         total: 'count',
         total: 'count',
@@ -247,7 +246,7 @@ export default {
     }
     }
   },
   },
   watch: {
   watch: {
-    value () {
+    value (newValue) {
       this.reFreshTestQuestionList()
       this.reFreshTestQuestionList()
     }
     }
   },
   },
@@ -372,7 +371,7 @@ export default {
 
 
     },
     },
     reFreshTestQuestionList () {
     reFreshTestQuestionList () {
-      if (!Array.isArray(this.localValue)) {
+      if (!this.localValue || !Array.isArray(this.localValue)) {
         return
         return
       }
       }
       this.testQuestionList = JSON.parse(JSON.stringify(this.localValue))
       this.testQuestionList = JSON.parse(JSON.stringify(this.localValue))
@@ -408,15 +407,27 @@ export default {
     },
     },
     refreshTestQuestions () {
     refreshTestQuestions () {
       this.test.loading = true
       this.test.loading = true
-      APIGateway.test.get(this.testId)
-        .then((test) => {
-          this.test.loading = false
-          this.localValue = test.inputData.test_questions_info
-          this.reFreshTestQuestionList()
-        })
-        .catch(() => {
-          this.test.loading = false
-        })
+      if (this.questionType === 'QUESTION_BANK') {
+        APIGateway.test.get(this.testId)
+          .then((test) => {
+            this.test.loading = false
+            this.localValue = test.inputData.test_questions_info
+            this.reFreshTestQuestionList()
+          })
+          .catch(() => {
+            this.test.loading = false
+          })
+      } else if (this.questionType === 'EVENT') {
+        APIGateway.testSet.get(this.testId)
+          .then((testSet) => {
+            this.test.loading = false
+            this.localValue = testSet.inputData.test_set_questions
+            this.reFreshTestQuestionList()
+          })
+          .catch(() => {
+            this.test.loading = false
+          })
+      }
     },
     },
     filterQuestionList () {
     filterQuestionList () {
       if (this.selectedSessionId) {
       if (this.selectedSessionId) {

+ 2 - 2
src/components/Widgets/Test/AdminTestShow/AdminTestShow.vue

@@ -42,8 +42,8 @@ import { FormBuilderAssist } from 'quasar-form-builder'
 import BtnControl from 'src/components/Control/btn.vue'
 import BtnControl from 'src/components/Control/btn.vue'
 import { UnitCategory } from 'src/models/UnitCategory.js'
 import { UnitCategory } from 'src/models/UnitCategory.js'
 import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
 import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
-import QuestionsCreateAndAppend from 'src/components/FormBuilderCustumComponents/QuestionsCreateAndAppend/QuestionsCreateAndAppend.vue'
 import UsersOfTestSelector from 'src/components/FormBuilderCustumComponents/UsersOfTestSelector/UsersOfTestSelector.vue'
 import UsersOfTestSelector from 'src/components/FormBuilderCustumComponents/UsersOfTestSelector/UsersOfTestSelector.vue'
+import QuestionsCreateAndAppend from 'src/components/FormBuilderCustumComponents/QuestionsCreateAndAppend/QuestionsCreateAndAppend.vue'
 
 
 const BtnControlComp = shallowRef(BtnControl)
 const BtnControlComp = shallowRef(BtnControl)
 const UsersOfTestSelectorComp = shallowRef(UsersOfTestSelector)
 const UsersOfTestSelectorComp = shallowRef(UsersOfTestSelector)
@@ -74,7 +74,7 @@ export default {
         { type: 'select', name: 'level', responseKey: 'level', label: 'سطح آزمون', placeholder: ' ', options: (new Test()).levelEnums, col: 'col-md-3 col-12' },
         { type: 'select', name: 'level', responseKey: 'level', label: 'سطح آزمون', placeholder: ' ', options: (new Test()).levelEnums, col: 'col-md-3 col-12' },
         { type: 'hidden', name: 'test_set', responseKey: 'test_set', value: this.$route.params.test_set_id },
         { type: 'hidden', name: 'test_set', responseKey: 'test_set', value: this.$route.params.test_set_id },
         { type: 'hidden', name: 'classroom', responseKey: 'classroom', value: this.$route.params.classroom_id },
         { type: 'hidden', name: 'classroom', responseKey: 'classroom', value: this.$route.params.classroom_id },
-        { type: QuestionsCreateAndAppendComp, name: 'test_questions', responseKey: 'test_questions_info', testId: this.$route.params.id, questionType: 'QUESTION_BANK', ignoreValue: true, col: 'col-md-12 col-12' },
+        { type: QuestionsCreateAndAppendComp, name: 'test_questions', responseKey: 'test_set_questions', testId: this.$route.params.id, questionType: 'QUESTION_BANK', ignoreValue: true, col: 'col-md-12 col-12' },
         { type: UsersOfTestSelectorComp, name: 'examinees', responseKey: 'examinees', classroomId: this.$route.params.classroom_id, col: 'col-12' },
         { type: UsersOfTestSelectorComp, name: 'examinees', responseKey: 'examinees', classroomId: this.$route.params.classroom_id, col: 'col-12' },
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تعیین جزییات', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تعیین جزییات', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
       ],
       ],

+ 5 - 5
src/components/Widgets/TestSet/AdminEventTestSetCreate/AdminEventTestSetCreate.vue

@@ -32,10 +32,10 @@ import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import { FormBuilderAssist } from 'quasar-form-builder'
 import { FormBuilderAssist } from 'quasar-form-builder'
 import BtnControl from 'src/components/Control/btn.vue'
 import BtnControl from 'src/components/Control/btn.vue'
-import QuestionsSelector from 'src/components/FormBuilderCustumComponents/QuestionsSelector/QuestionsSelector.vue'
+// import QuestionsSelector from 'src/components/FormBuilderCustumComponents/QuestionsSelector/QuestionsSelector.vue'
 
 
 const BtnControlComp = shallowRef(BtnControl)
 const BtnControlComp = shallowRef(BtnControl)
-const QuestionsSelectorComp = shallowRef(QuestionsSelector)
+// const QuestionsSelectorComp = shallowRef(QuestionsSelector)
 
 
 export default {
 export default {
   name: 'AdminEventTestSetCreate',
   name: 'AdminEventTestSetCreate',
@@ -53,8 +53,8 @@ export default {
         { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان پرسشنامه', placeholder: ' ', col: 'col-md-6 col-12' },
         { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان پرسشنامه', placeholder: ' ', col: 'col-md-6 col-12' },
         { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات پرسشنامه', col: 'col-md-12 col-12' },
         { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات پرسشنامه', col: 'col-md-12 col-12' },
         { type: 'hidden', name: 'type', responseKey: 'type', value: 'QUESTIONNAIRE' },
         { 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: 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: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تایید نهایی', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تایید نهایی', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
       ]
       ]
     }
     }
@@ -66,7 +66,7 @@ export default {
   methods: {
   methods: {
     setActionBtn () {
     setActionBtn () {
       FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.create)
       FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.create)
-      FormBuilderAssist.setAttributeByName(this.inputs, 'btnCreateQuestion', 'atClick', this.goToCreateQuestionPage)
+      // FormBuilderAssist.setAttributeByName(this.inputs, 'btnCreateQuestion', 'atClick', this.goToCreateQuestionPage)
     },
     },
     goToCreateQuestionPage () {
     goToCreateQuestionPage () {
       this.$router.push({ name: 'Admin.Event.TestSet.Questions.Create', params: { test_set_id: this.$route.params.test_set_id } })
       this.$router.push({ name: 'Admin.Event.TestSet.Questions.Create', params: { test_set_id: this.$route.params.test_set_id } })

+ 7 - 4
src/components/Widgets/TestSet/AdminEventTestSetShow/AdminEventTestSetShow.vue

@@ -32,10 +32,12 @@ import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import { FormBuilderAssist } from 'quasar-form-builder'
 import { FormBuilderAssist } from 'quasar-form-builder'
 import BtnControl from 'src/components/Control/btn.vue'
 import BtnControl from 'src/components/Control/btn.vue'
-import QuestionsSelector from 'src/components/FormBuilderCustumComponents/QuestionsSelector/QuestionsSelector.vue'
+// import QuestionsSelector from 'src/components/FormBuilderCustumComponents/QuestionsSelector/QuestionsSelector.vue'
+import QuestionsCreateAndAppend from 'src/components/FormBuilderCustumComponents/QuestionsCreateAndAppend/QuestionsCreateAndAppend.vue'
 
 
 const BtnControlComp = shallowRef(BtnControl)
 const BtnControlComp = shallowRef(BtnControl)
-const QuestionsSelectorComp = shallowRef(QuestionsSelector)
+// const QuestionsSelectorComp = shallowRef(QuestionsSelector)
+const QuestionsCreateAndAppendComp = shallowRef(QuestionsCreateAndAppend)
 
 
 export default {
 export default {
   name: 'AdminEventTestSetShow',
   name: 'AdminEventTestSetShow',
@@ -54,8 +56,9 @@ export default {
         { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات پرسشنامه', col: 'col-md-12 col-12' },
         { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات پرسشنامه', col: 'col-md-12 col-12' },
         { type: 'hidden', name: 'id', responseKey: 'id' },
         { type: 'hidden', name: 'id', responseKey: 'id' },
         { type: 'hidden', name: 'type', responseKey: 'type', value: 'QUESTIONNAIRE' },
         { 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: 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: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تایید نهایی', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تایید نهایی', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
       ]
       ]
     }
     }