ali 2 лет назад
Родитель
Сommit
d7d5612f14
5 измененных файлов с 218 добавлено и 9 удалено
  1. 2 0
      src/api/APIGateway.js
  2. 89 0
      src/api/models/AnswerBook.js
  3. 112 0
      src/models/AnswerBook.js
  4. 4 0
      src/models/Test.js
  5. 11 9
      src/pages/User/Profile/classroomInfo.vue

+ 2 - 0
src/api/APIGateway.js

@@ -17,6 +17,7 @@ import ContentAPI from 'src/api/models/Content.js'
 import ProjectAPI from 'src/api/models/Project.js'
 import ProjectAPI from 'src/api/models/Project.js'
 import QuestionApi from 'src/api/models/Question.js'
 import QuestionApi from 'src/api/models/Question.js'
 import ClassroomAPI from 'src/api/models/Classroom.js'
 import ClassroomAPI from 'src/api/models/Classroom.js'
+import AnswerBookApi from 'src/api/models/AnswerBook.js'
 import InstalmentAPI from 'src/api/models/Instalment.js'
 import InstalmentAPI from 'src/api/models/Instalment.js'
 import TransactionAPI from 'src/api/models/Transaction.js'
 import TransactionAPI from 'src/api/models/Transaction.js'
 import PageSettingAPI from 'src/api/models/PageSetting.js'
 import PageSettingAPI from 'src/api/models/PageSetting.js'
@@ -58,6 +59,7 @@ export const APIGateway = {
   content: new ContentAPI(),
   content: new ContentAPI(),
   question: new QuestionApi(),
   question: new QuestionApi(),
   classroom: new ClassroomAPI(),
   classroom: new ClassroomAPI(),
+  answerBook: new AnswerBookApi(),
   instalment: new InstalmentAPI(),
   instalment: new InstalmentAPI(),
   transaction: new TransactionAPI(),
   transaction: new TransactionAPI(),
   pageSetting: new PageSettingAPI(),
   pageSetting: new PageSettingAPI(),

+ 89 - 0
src/api/models/AnswerBook.js

@@ -0,0 +1,89 @@
+import { appApi } from 'src/boot/axios.js'
+import APIRepository from '../classes/APIRepository.js'
+import { AnswerBook, AnswerBookList } from 'src/models/AnswerBook.js'
+
+export default class AnswerBookAPI extends APIRepository {
+  constructor() {
+    super('test_sets', appApi)
+    this.APIAdresses = {
+      base: '/lma/answer_books',
+      byId: (id) => '/lma/answer_books/' + id,
+      getTestQuestions: (id) => '/lma/answer_books/' + id + '/get_test_questions'
+    }
+    this.CacheList = {
+      base: this.name + this.APIAdresses.base,
+      byId: (id) => this.name + this.APIAdresses.byId(id),
+      getTestQuestions: (id) => this.name + this.APIAdresses.getTestQuestions(id)
+    }
+    this.restUrl = (id) => this.APIAdresses.base + '/' + id
+    /* Setting the callback functions for the CRUD operations. */
+    this.setCrudCallbacks({
+      get: (response) => { return new AnswerBook(response.data) },
+      post: (response) => { return new AnswerBook(response.data) },
+      put: (response) => { return new AnswerBook(response.data) },
+      delete: (response) => { return response.data }
+    })
+  }
+
+  index(data) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.base,
+      data: this.getNormalizedSendData({
+        test__classroom: null, // Number
+        owner: null, // Number
+        per_page: 10, // Number
+        page: 1 // Number
+      }, data),
+      resolveCallback: (response) => {
+        const paginate = response.data
+        const results = response.data.results
+        delete paginate.results
+        return {
+          list: new AnswerBookList(results),
+          paginate
+          // {
+          //   "count": 1,
+          //   "num_pages": 1,
+          //   "per_page": 10,
+          //   "current": 1,
+          //   "next": null,
+          //   "previous": null,
+          // }
+        }
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
+  get (id) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.byId(id),
+      resolveCallback: (response) => {
+        return new AnswerBook(response.data)
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
+  getTestQuestions (id) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.getTestQuestions(id),
+      resolveCallback: (response) => {
+        return new AnswerBook(response.data)
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+}

+ 112 - 0
src/models/AnswerBook.js

@@ -0,0 +1,112 @@
+import { User } from 'src/models/User.js'
+import { Test } from 'src/models/Test.js'
+import { Collection, Model } from 'js-abstract-model'
+
+class AnswerBook extends Model {
+  constructor (data) {
+    super(data, [
+      { key: 'id' },
+      { key: 'attachment' },
+      { key: 'attending_end_time' },
+      { key: 'attending_start_time' },
+      { key: 'creation_time' },
+      { key: 'creator' },
+      {
+        key: 'creator_info',
+        relatedModel: User
+      },
+      { key: 'owner' },
+      {
+        key: 'owner_info',
+        relatedModel: User
+      },
+      { key: 'test' },
+      {
+        key: 'test_info',
+        relatedModel: Test
+      },
+      { key: 'duration' },
+      { key: 'grader' },
+      { key: 'grader_description' },
+      { key: 'grader_info' },
+      { key: 'is_active' },
+      { key: 'is_deleted' },
+      { key: 'last_modification_time' },
+      { key: 'objection_request' },
+      { key: 'objection_result' },
+      { key: 'objection_time' },
+      { key: 'registration' },
+      { key: 'registration_info' },
+      { key: 'server_time' },
+      { key: 'attending_start_time' },
+      { key: 'status' },
+      {
+        key: 'is_enabled_attending',
+        default: false
+      },
+      {
+        key: 'is_enabled_continuing',
+        default: false
+      },
+      {
+        key: 'is_enabled_objecting',
+        default: false
+      },
+      {
+        key: 'is_enabled_viewing',
+        default: false
+      }
+    ], {
+      status: {
+        infoKey: 'status_info',
+        enumListKey: 'statusEnums',
+        enums: [
+          {
+            label: 'حذف شده',
+            value: 'DELETED'
+          },
+          {
+            label: 'ایجاد شده',
+            value: 'CREATED'
+          },
+          {
+            label: 'ارسال نشده',
+            value: 'FETCHED'
+          },
+          {
+            label: 'ارسال شده',
+            value: 'SUBMITTED'
+          },
+          {
+            label: 'در حال تصحیح',
+            value: 'GRADING'
+          },
+          {
+            label: 'غیر قابل تصحیح',
+            value: 'UNGRADABLE'
+          },
+          {
+            label: 'تصحیح شده',
+            value: 'GRADED'
+          },
+          {
+            label: 'اعتراض شده',
+            value: 'OBJECTED'
+          },
+          {
+            label: 'نهایی شده',
+            value: 'FINALIZED'
+          }
+        ]
+      }
+    })
+  }
+}
+
+class AnswerBookList extends Collection {
+  model () {
+    return AnswerBook
+  }
+}
+
+export { AnswerBook, AnswerBookList }

+ 4 - 0
src/models/Test.js

@@ -77,6 +77,10 @@ class Test extends Model {
           {
           {
             label: 'خاتمه',
             label: 'خاتمه',
             value: 'CLOSED'
             value: 'CLOSED'
+          },
+          {
+            label: 'خاتمه یافته',
+            value: 'FINISHED'
           }
           }
         ]
         ]
       }
       }

+ 11 - 9
src/pages/User/Profile/classroomInfo.vue

@@ -128,7 +128,8 @@
                     height="200px" />
                     height="200px" />
       </q-tab-panel>
       </q-tab-panel>
 
 
-      <q-tab-panel name="tests">
+      <q-tab-panel name="tests"
+                   class="q-pa-none">
         <entity-index v-if="mounted"
         <entity-index v-if="mounted"
                       ref="entityIndex"
                       ref="entityIndex"
                       v-model:value="testListInputs"
                       v-model:value="testListInputs"
@@ -249,7 +250,8 @@ import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
 import { ProjectAttendanceSheets } from 'src/models/ProjectAttendanceSheets.js'
 import { ProjectAttendanceSheets } from 'src/models/ProjectAttendanceSheets.js'
 import { SessionAttendanceSheets } from 'src/models/SessionAttendanceSheets.js'
 import { SessionAttendanceSheets } from 'src/models/SessionAttendanceSheets.js'
 import ShowClassroomInfo from 'src/components/Widgets/Other/ShowClassroomInfo/ShowClassroomInfo.vue'
 import ShowClassroomInfo from 'src/components/Widgets/Other/ShowClassroomInfo/ShowClassroomInfo.vue'
-import { Team } from 'src/models/Team'
+import { Team } from 'src/models/Team.js'
+import { AnswerBook } from 'src/models/AnswerBook.js'
 
 
 export default {
 export default {
   name: 'UserPanel.Profile.ClassroomInfo',
   name: 'UserPanel.Profile.ClassroomInfo',
@@ -534,7 +536,7 @@ export default {
       testListInputs: [
       testListInputs: [
         { type: 'hidden', name: 'classroom', value: classroomId }
         { type: 'hidden', name: 'classroom', value: classroomId }
       ],
       ],
-      testListApi: APIGateway.test.APIAdresses.base,
+      testListApi: APIGateway.answerBook.APIAdresses.base,
       testListTable: {
       testListTable: {
         columns: [
         columns: [
           {
           {
@@ -556,35 +558,35 @@ export default {
             required: true,
             required: true,
             label: 'عنوان آزمون',
             label: 'عنوان آزمون',
             align: 'left',
             align: 'left',
-            field: row => row.title
+            field: row => row.test_info?.title
           },
           },
           {
           {
             name: 'start_time',
             name: 'start_time',
             required: true,
             required: true,
             label: 'زمان شروع',
             label: 'زمان شروع',
             align: 'left',
             align: 'left',
-            field: row => row.start_time ? ShamsiDate.getDateTime(row.start_time) : '-'
+            field: row => row.test_info?.start_time ? ShamsiDate.getDateTime(row.test_info.start_time) : '-'
           },
           },
           {
           {
             name: 'end_time',
             name: 'end_time',
             required: true,
             required: true,
             label: 'زمان پایان',
             label: 'زمان پایان',
             align: 'left',
             align: 'left',
-            field: row => row.end_time ? ShamsiDate.getDateTime(row.end_time) : '-'
+            field: row => row.test_info?.end_time ? ShamsiDate.getDateTime(row.test_info.end_time) : '-'
           },
           },
           {
           {
             name: 'duration_deadline',
             name: 'duration_deadline',
             required: true,
             required: true,
             label: 'مدت آزمون(دقیقه)',
             label: 'مدت آزمون(دقیقه)',
             align: 'left',
             align: 'left',
-            field: row => row.duration_deadline
+            field: row => row.duration
           },
           },
           {
           {
             name: 'test_questions.length',
             name: 'test_questions.length',
             required: true,
             required: true,
             label: 'تعداد سوالات',
             label: 'تعداد سوالات',
             align: 'left',
             align: 'left',
-            field: row => row.test_questions ? row.test_questions.length : '-'
+            field: row => row.test_info?.test_set_questions_length
           },
           },
           {
           {
             name: 'grade',
             name: 'grade',
@@ -598,7 +600,7 @@ export default {
             required: true,
             required: true,
             label: 'وضعیت تصحیح',
             label: 'وضعیت تصحیح',
             align: 'left',
             align: 'left',
-            field: row => '...'
+            field: row => (new AnswerBook(row)).status_info.label
           },
           },
           {
           {
             name: 'action',
             name: 'action',