ali 2 anni fa
parent
commit
6252145748

+ 1 - 1
src/components/Widgets/Test/AdminAnswerBookShow/AdminAnswerBookShow.vue

@@ -23,7 +23,7 @@
             {{ toShamsi(answerBook.attending_start_time) }}
           </div>
           <div class="col-md-4 col-12">
-            {{ answerBook.test_info.test_set_info.test_questions.length }}
+            {{ answerBook.test_info.test_questions_info.list.length }}
             سوال
           </div>
           <div class="col-md-4 col-12">

+ 1 - 1
src/components/Widgets/Test/ShowTestGradeForGrader/ShowTestGradeForGrader.vue

@@ -23,7 +23,7 @@
             {{ toShamsi(answerBook.attending_start_time) }}
           </div>
           <div class="col-md-4 col-12">
-            {{ answerBook.test_info.test_set_info.test_questions.length }}
+            {{ answerBook.test_info.test_questions_info.list.length }}
             سوال
           </div>
         </div>

+ 1 - 21
src/components/Widgets/Test/TestParticipation/TestParticipation.vue

@@ -18,7 +18,7 @@
             {{ toShamsi(answerBook.attending_start_time) }}
           </div>
           <div class="col-md-4 col-12">
-            {{ answerBook.test_info.test_set_info.test_questions.length }}
+            {{ answerBook.test_info.test_questions_info.list.length }}
             سوال
           </div>
           <div class="col-md-4 col-12">
@@ -120,7 +120,6 @@ export default {
     }
   },
   mounted () {
-    // this.getAnswerBook()
     this.getTestQuestions()
     this.mounted = true
   },
@@ -189,25 +188,6 @@ export default {
     backToClassList () {
       this.$router.push({ name: 'UserPanel.Profile.AllClassrooms' })
     },
-    getAnswerBook () {
-      this.answerBook.loading = true
-      APIGateway.answerBook.get(this.$route.params.answer_book_id)
-        .then((answerBook) => {
-          this.answerBook = new AnswerBook(answerBook)
-          if (this.answerBook.test_info.test_questions_length === 0) {
-            this.$q.notify({
-              type: 'negative',
-              message: 'لیست سوالات آزمون خالی است.'
-            })
-            this.backToClassList()
-          }
-          this.answerBook.loading = false
-        })
-        .catch(() => {
-          this.answerBook.loading = false
-          this.backToClassList()
-        })
-    },
     initPageFromAnswerBook (answerBook) {
       this.answerBook = new AnswerBook(answerBook)
       this.answerBook.loading = false

+ 0 - 1
src/components/Widgets/Test/TestParticipation/components/AllQuestions.vue

@@ -1,7 +1,6 @@
 <template>
   <div class="AllQuestions">
     <q-list separator>
-      <!--      <q-item v-for="(question, questionIndex) in answerBook.test_info.test_set_info.test_questions"-->
       <q-item v-for="(answerSheet, answerSheetIndex) in answerBook.answer_sheet_info.list"
               :key="answerSheetIndex"
               clickable>

+ 3 - 5
src/components/Widgets/Test/TestParticipation/components/SingleQuestion.vue

@@ -74,27 +74,25 @@ export default {
   },
   computed: {
     hasNextQuestion () {
-      return this.answerBook.test_info.test_set_info.test_questions.length > this.questionNumber
+      return this.answerBook.test_info.test_questions_info.list.length > this.questionNumber
     },
     hasPrevQuestion () {
       return this.questionNumber > 1
     },
     isLastQuestion () {
-      return this.answerBook.test_info.test_set_info.test_questions.length === this.questionNumber
+      return this.answerBook.test_info.test_questions_info.list.length === this.questionNumber
     },
     testSetQuestion () {
-      // return this.answerBook.test_info.test_set_info.test_questions[this.questionNumber - 1]
       return this.answerBook.answer_sheet_info.list[this.questionNumber - 1].test_question_info
     },
     question () {
-      // return this.answerBook.test_info.test_set_info.test_questions[this.questionNumber - 1]
       return this.testSetQuestion.question_info
     }
   },
   mounted () {
     this.setInputs()
     this.mounted = true
-    if (this.answerBook.test_info.test_set_info.test_questions.length < this.questionNumber || this.questionNumber < 1) {
+    if (this.answerBook.test_info.test_questions_info.list.length < this.questionNumber || this.questionNumber < 1) {
       this.$router.push({ name: 'UserPanel.Test.AnswerBook.Participate.AllQuestions', params: this.$route.params })
     }
   },

+ 1 - 1
src/components/Widgets/Test/TestShow/TestShow.vue

@@ -12,7 +12,7 @@
             {{ toShamsi(answerBook.attending_start_time) }}
           </div>
           <div class="col-md-4 col-12">
-            {{ answerBook.test_info.test_set_info.test_questions.length }}
+            {{ answerBook.test_info.test_questions_info.list.length }}
             سوال
           </div>
           <div class="col-md-4 col-12">

+ 10 - 1
src/models/Test.js

@@ -1,5 +1,6 @@
-import { Collection, Model } from 'js-abstract-model'
 import { TestSet } from 'src/models/TestSet.js'
+import { Collection, Model } from 'js-abstract-model'
+import { QuestionList } from 'src/models/Question.js'
 
 class Test extends Model {
   constructor (data) {
@@ -17,6 +18,14 @@ class Test extends Model {
       {
         key: 'test_set_info',
         relatedModel: TestSet
+      },
+      {
+        key: 'test_questions',
+        default: []
+      },
+      {
+        key: 'test_questions_info',
+        relatedModel: QuestionList
       }
     ], {
       level: {

+ 1 - 0
src/pages/User/Profile/classroomInfo.vue

@@ -720,6 +720,7 @@ export default {
       this.participateTypeDialog = true
     },
     startTest () {
+      this.$store.commit('Test/updateAnswerBook', null)
       this.$router.push({ name: this.participateType, params: { test_id: this.selectedTest.testId, answer_book_id: this.selectedTest.answerBookId, question_number: 1 } })
     },
     getTeamJoinStatusLabel (team) {