Bladeren bron

see also #248

ali 2 jaren geleden
bovenliggende
commit
07284e8c27

+ 5 - 1
src/components/FormBuilderCustumComponents/QuestionsSelector/QuestionsSelector.vue

@@ -150,7 +150,8 @@ export default {
       },
       inputs: [
         { type: 'hidden', name: 'type', value: 'QUESTION_BANK' },
-        { type: 'hidden', name: 'session_template_questions__session_template', value: null }
+        { type: 'hidden', name: 'session_template_questions__session_template', value: null },
+        { type: 'hidden', name: 'session_template_questions__session_template__unit', value: null }
       ],
       table: {
         columns: [
@@ -321,6 +322,9 @@ export default {
       this.updateloadedQuestionsByArray(response.data.results)
     },
     updateloadedQuestionsByArray (array, allSelected = false) {
+      if (!array || !Array.isArray(array)) {
+        return
+      }
       array.forEach(item => {
         const questionId = item.id || item.question
         const mark = item.mark || 0

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

@@ -53,7 +53,7 @@ export default {
         { 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: 'hidden', name: 'unit', responseKey: 'unit', value: this.$route.params.unit_id },
-        { type: QuestionsSelectorComp, name: 'test_questions', responseKey: 'test_questions', unitId: this.$route.params.unit_id, col: 'col-md-12 col-12' },
+        { type: QuestionsSelectorComp, name: 'test_set_questions', responseKey: 'test_set_questions', unitId: this.$route.params.unit_id, col: 'col-md-12 col-12' },
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تایید نهایی', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
       ]
     }

+ 4 - 2
src/components/Widgets/TestSet/AdminTestSetShow/AdminTestSetShow.vue

@@ -42,10 +42,12 @@ export default {
   components: { EntityEdit },
   mixins: [mixinWidget],
   data () {
+    const unitId = this.$route.params.unit_id
+    const testSetId = this.$route.params.id
     return {
       mounted: false,
       entityLoading: false,
-      api: APIGateway.test.APIAdresses.byId(this.$route.params.id),
+      api: APIGateway.test.APIAdresses.byId(testSetId),
       entityIdKey: 'id',
       entityParamKey: 'id',
       inputs: [
@@ -53,7 +55,7 @@ export default {
         { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات آزمون', col: 'col-md-12 col-12' },
         { type: 'hidden', name: 'id', responseKey: 'id' },
         { type: 'hidden', name: 'unit', responseKey: 'unit' },
-        { type: QuestionsSelectorComp, name: 'test_questions', responseKey: 'test_questions', unitId: this.$route.params.unit_id, col: 'col-md-12 col-12' },
+        { type: QuestionsSelectorComp, name: 'test_set_questions', responseKey: 'test_set_questions', unitId, col: 'col-md-12 col-12' },
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'تایید نهایی', placeholder: ' ', atClick: () => {}, col: 'col-12 flex justify-end' }
       ]
     }

+ 4 - 2
src/models/Test.js

@@ -1,4 +1,5 @@
 import { Collection, Model } from 'js-abstract-model'
+import { TestSet } from 'src/models/TestSet.js'
 
 class Test extends Model {
   constructor (data) {
@@ -9,9 +10,10 @@ class Test extends Model {
       { key: 'level' },
       { key: 'unit' },
       { key: 'status' },
+      { key: 'test_set' },
       {
-        key: 'test_questions',
-        default: []
+        key: 'test_set_info',
+        relatedModel: TestSet
       }
     ], {
       level: {

+ 1 - 1
src/models/TestSet.js

@@ -9,7 +9,7 @@ class TestSet extends Model {
       { key: 'level' },
       { key: 'unit' },
       {
-        key: 'test_questions',
+        key: 'test_set_questions',
         default: []
       }
     ], {