ali преди 2 години
родител
ревизия
c84a836698

+ 2 - 0
src/api/APIGateway.js

@@ -30,6 +30,7 @@ import MediaCategoryAPI from 'src/api/models/MediaCategory.js'
 import QuestionChoiceApi from 'src/api/models/QuestionChoice.js'
 import TicketCategoryAPI from 'src/api/models/TicketCategory.js'
 import SessionTemplateAPI from 'src/api/models/SessionTemplate.js'
+import TranscriptSheetAPI from 'src/api/models/TranscriptSheet.js'
 import ContentCategoryAPI from 'src/api/models/ContentCategory.js'
 import InstalmentOfferAPI from 'src/api/models/InstalmentOffer.js'
 import ClassroomGraderAPI from 'src/api/models/ClassroomGraders.js'
@@ -73,6 +74,7 @@ export const APIGateway = {
   mediaCategory: new MediaCategoryAPI(),
   ticketCategory: new TicketCategoryAPI(),
   questionChoice: new QuestionChoiceApi(),
+  transcriptSheet: new TranscriptSheetAPI(),
   sessionTemplate: new SessionTemplateAPI(),
   contentCategory: new ContentCategoryAPI(),
   instalmentOffer: new InstalmentOfferAPI(),

+ 15 - 0
src/api/models/Classroom.js

@@ -16,6 +16,7 @@ export default class ClassroomAPI extends APIRepository {
       drop: (id) => '/lma/classrooms/' + id + '/drop',
       register: (id) => '/lma/classrooms/' + id + '/register',
       leaders: (id) => '/lma/classrooms/' + id + '/leaders',
+      announceResult: (id) => '/lma/classrooms/' + id + '/announce_result',
       members: '/lma/registrations',
       activitySheet: '/lma/registrations/activity_sheet',
       enrollByAdmin: (classroomId, userId) => '/lma/classrooms/' + classroomId + '/enrolll?user_id=' + userId,
@@ -209,4 +210,18 @@ export default class ClassroomAPI extends APIRepository {
       }
     })
   }
+
+  notifyAnnounceResult (classroomId) {
+    return this.sendRequest({
+      apiMethod: 'put',
+      api: this.api,
+      request: this.APIAdresses.announceResult(classroomId),
+      resolveCallback: (response) => {
+        return response.data
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
 }

+ 66 - 0
src/api/models/TranscriptSheet.js

@@ -0,0 +1,66 @@
+import { appApi } from 'src/boot/axios.js'
+import APIRepository from '../classes/APIRepository.js'
+
+export default class TranscriptSheetAPI extends APIRepository {
+  constructor() {
+    super('transcript_sheets', appApi)
+    this.APIAdresses = {
+      base: '/lma/transcript_sheets',
+      exportReport: '/lma/transcript_sheets/export_report',
+      byId: (id) => '/lma/transcript_sheets/' + id
+    }
+    this.CacheList = {
+      base: this.name + this.APIAdresses.base
+    }
+  }
+
+  notifyAnnounceResult (data) {
+    return this.sendRequest({
+      apiMethod: 'put',
+      api: this.api,
+      request: this.APIAdresses.announceResult(data.classroomId),
+      resolveCallback: (response) => {
+        return response.data
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
+  update (data) {
+    return this.sendRequest({
+      apiMethod: 'put',
+      api: this.api,
+      request: this.APIAdresses.byId(data.id),
+      data: this.getNormalizedSendData({
+        final_score: null // Number
+      }, data),
+      resolveCallback: (response) => {
+        return response.data
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
+  exportReport(data) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.exportReport,
+      data: this.getNormalizedSendData({
+        registration__classroom: null, // Number
+        page: null // Number
+      }, data),
+      responseType: 'blob',
+      resolveCallback: (response) => {
+        return response.data // xlsxData
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+}

+ 11 - 1
src/components/Widgets/Classroom/AdminClassroomShow/AdminClassroomShow.vue

@@ -48,6 +48,9 @@
       <q-tab v-if="canShowTabPage('activity_sheet')"
              name="activity_sheet"
              label="فعالیت کلاسی" />
+      <q-tab v-if="canShowTabPage('announce_result')"
+             name="announce_result"
+             label="کارنامه" />
       <q-tab v-if="canShowTabPage('live_streaming_url')"
              name="live_streaming_url"
              label="بخش آنلاین" />
@@ -99,6 +102,10 @@
                    class="q-pa-none">
         <activity-sheet-list :classroom-id="parseInt($route.params.id)" />
       </q-tab-panel>
+      <q-tab-panel name="announce_result"
+                   class="q-pa-none">
+        <announce-result-list :classroom-id="parseInt($route.params.id)" />
+      </q-tab-panel>
       <q-tab-panel name="live_streaming_url">
         <live-streaming :classroom="classroom" />
       </q-tab-panel>
@@ -120,6 +127,7 @@ import { UnitCategory } from 'src/models/UnitCategory.js'
 import ClassroomInfo from './components/ClassroomInfo.vue'
 import LiveStreaming from './components/LiveStreaming.vue'
 import ActivitySheetList from './components/ActivitySheetList.vue'
+import AnnounceResultList from './components/AnnounceResultList.vue'
 import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
 
 export default {
@@ -135,7 +143,8 @@ export default {
     Breadcrumbs,
     ClassroomInfo,
     LiveStreaming,
-    ActivitySheetList
+    ActivitySheetList,
+    AnnounceResultList
   },
   mixins: [mixinWidget],
   data () {
@@ -193,6 +202,7 @@ export default {
             'graders',
             'leaders',
             'activity_sheet',
+            'announce_result',
             'live_streaming_url'
           ],
           EVENT: [

+ 191 - 0
src/components/Widgets/Classroom/AdminClassroomShow/components/AnnounceResultList.vue

@@ -0,0 +1,191 @@
+<template>
+  <entity-index v-if="mounted"
+                ref="announceResultList"
+                v-model:value="announceResultListInputs"
+                title="فعالیت کلاسی"
+                :api="announceResultListApi"
+                :table="announceResultListTable"
+                :table-keys="announceResultListTableKeys"
+                :show-search-button="false"
+                :show-reload-button="false"
+                :show-expand-button="false">
+    <template #toolbar>
+      <q-btn label="خروجی اکسل"
+             color="primary"
+             :loading="exportReportLoading"
+             outline
+             @click="getExcel" />
+    </template>
+    <template v-slot:entity-index-table-cell="{inputData}">
+      <template v-if="inputData.col.name === 'final_score'">
+        <q-input v-model="inputData.props.row.final_score" />
+      </template>
+      <template v-else-if="inputData.col.name === 'actions'">
+        <div class="action-column-entity-index">
+          <q-btn size="md"
+                 color="primary"
+                 outline
+                 label="اعمال تغییرات"
+                 class="q-mr-md"
+                 :loading="updateTranscriptSheetLoading"
+                 @click="updateTranscriptSheets(inputData.props.row)" />
+          <!--                :to="{name: 'Admin.Session.Show', params: {id: inputData.props.row.id}}"-->
+        </div>
+      </template>
+      <template v-else>
+        {{ inputData.col.value }}
+      </template>
+    </template>
+  </entity-index>
+  <q-skeleton v-else
+              type="rect"
+              height="200px" />
+</template>
+
+<script>
+import { shallowRef } from 'vue'
+import { EntityIndex } from 'quasar-crud'
+import Assist from 'assets/js/Assist.js'
+import { APIGateway } from 'src/api/APIGateway.js'
+import { FormBuilderAssist } from 'quasar-form-builder'
+import BtnControl from 'src/components/Control/btn.vue'
+
+const BtnControlComp = shallowRef(BtnControl)
+
+export default {
+  name: 'ActivitySheetList',
+  components: {
+    EntityIndex
+  },
+  props: {
+    classroomId: {
+      type: Number,
+      default: null
+    }
+  },
+  data () {
+    const classroomId = this.classroomId
+    return {
+      mounted: false,
+      exportReportLoading: false,
+      updateTranscriptSheetLoading: false,
+
+      announceResultListInputs: [
+        { type: 'hidden', name: 'registration__classroom', value: classroomId },
+        { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
+      ],
+      announceResultListApi: APIGateway.transcriptSheet.APIAdresses.base,
+      announceResultListTable: {
+        columns: [
+          {
+            name: 'id',
+            required: true,
+            label: 'شماره',
+            align: 'left',
+            field: row => row.id
+          },
+          {
+            name: 'owner_info.fullname',
+            required: true,
+            label: 'نام و نام خانوادگی',
+            align: 'left',
+            field: row => row.registration_info.owner_info.firstname + ' ' + row.registration_info.owner_info.lastname
+          },
+          {
+            name: 'owner_info.national_code',
+            required: true,
+            label: 'کد ملی',
+            align: 'left',
+            field: row => row.registration_info.owner_info.national_code
+          },
+          {
+            name: 'attendance_score',
+            required: true,
+            label: 'نمره حضور و غیاب',
+            align: 'left',
+            field: row => row.attendance_score
+          },
+          {
+            name: 'highest_test_score',
+            required: true,
+            label: 'نمره آزمون',
+            align: 'left',
+            field: row => row.highest_test_score
+          },
+          {
+            name: 'final_score',
+            required: true,
+            label: 'نمره نهایی',
+            align: 'left',
+            field: row => row.final_score
+          },
+          {
+            name: 'status',
+            required: true,
+            label: 'وضعیت نهایی',
+            align: 'left',
+            field: row => row.status
+          },
+          {
+            name: 'actions',
+            required: true,
+            label: 'سابقه آموزشی',
+            align: 'left',
+            field: ''
+          }
+        ],
+        data: []
+      },
+      announceResultListTableKeys: {
+        data: 'results',
+        total: 'count',
+        currentPage: 'current',
+        perPage: 'per_page',
+        pageKey: 'page'
+      }
+    }
+  },
+  mounted () {
+    this.setActivitySheetListActionBtn()
+    this.mounted = true
+  },
+  methods: {
+    setActivitySheetListActionBtn () {
+      FormBuilderAssist.setAttributeByName(this.announceResultListInputs, 'btn', 'atClick', this.searchActivitySheetList)
+    },
+    searchActivitySheetList () {
+      this.$refs.activitySheet.search()
+    },
+    getRemoveMessage (row) {
+      return 'آیا از حذف ' + row.title + ' اطمینان دارید؟'
+    },
+    updateTranscriptSheets(transcriptSheet) {
+      this.updateTranscriptSheetLoading = true
+      APIGateway.transcriptSheet.update({
+        id: transcriptSheet.id,
+        final_score: transcriptSheet.final_score
+      })
+        .then(() => {
+          this.$refs.announceResultList.search()
+          this.updateTranscriptSheetLoading = false
+        })
+        .catch(() => {
+          this.updateTranscriptSheetLoading = false
+        })
+    },
+    getExcel () {
+      this.exportReportLoading = true
+      APIGateway.transcriptSheet.exportReport({
+        registration__classroom: this.classroomId
+      })
+        .then((xlsxData) => {
+          Assist.saveXlsx(xlsxData, this.classroom.title)
+          this.exportReportLoading = false
+        })
+        .catch(() => {
+          this.exportReportLoading = false
+        })
+    }
+  }
+}
+</script>