Ver Fonte

init SessionAttendanceSheets

ali há 3 anos atrás
pai
commit
a81be30255

+ 1 - 1
src/api/models/ProjectAttendanceSheets.js

@@ -4,7 +4,7 @@ import { ProjectAttendanceSheets, ProjectAttendanceSheetsList } from 'src/models
 
 export default class ProjectAttendanceSheetsAPI extends APIRepository {
   constructor() {
-    super('project', appApi, '/lma/projects', ProjectAttendanceSheets)
+    super('project_attendance_sheets', appApi, '/lma/project_attendance_sheets', ProjectAttendanceSheets)
     this.APIAdresses = {
       base: '/lma/project_attendance_sheets',
       project_sheets: '/lma/project_attendance_sheets/project_sheets',

+ 52 - 0
src/api/models/SessionAttendanceSheets.js

@@ -0,0 +1,52 @@
+import { appApi } from 'src/boot/axios.js'
+import APIRepository from '../classes/APIRepository.js'
+import { SessionAttendanceSheets, SessionAttendanceSheetsList } from 'src/models/SessionAttendanceSheets.js'
+
+export default class SessionAttendanceSheetsAPI extends APIRepository {
+  constructor() {
+    super('session', appApi, '/lma/session_attendance_sheets', SessionAttendanceSheets)
+    this.APIAdresses = {
+      base: '/lma/session_attendance_sheets',
+      submitAssignment: '/lma/session_attendance_sheets/submit_assignment',
+      submitAssignmentStatus: '/lma/session_attendance_sheets/submit_attendance_status',
+      byId: (id) => '/lma/project_attendance_sheets/' + id
+    }
+    this.CacheList = {
+      base: this.name + this.APIAdresses.base,
+      byId: (id) => this.name + this.APIAdresses.byId(id)
+    }
+  }
+
+  index(data) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.base,
+      data: this.getNormalizedSendData({
+        category: 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 SessionAttendanceSheetsList(results),
+          paginate
+          // {
+          //   "count": 1,
+          //   "num_pages": 1,
+          //   "per_page": 10,
+          //   "current": 1,
+          //   "next": null,
+          //   "previous": null,
+          // }
+        }
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+}

+ 3 - 3
src/models/Classroom.js

@@ -111,9 +111,9 @@ class Classroom extends Model {
         infoKey: 'audience_gender_type_info',
         enumListKey: 'audience_gender_typeEnums',
         enums: [
-          { label: 'آقا', value: 'MALE' },
-          { label: 'خانم', value: 'FEMALE' },
-          { label: 'خانم و آقا', value: 'FEMALE_MALE' }
+          { label: 'آقایان', value: 'MALE' },
+          { label: 'خانم ها', value: 'FEMALE' },
+          { label: 'خانم ها و آقایان', value: 'FEMALE_MALE' }
         ]
       }
     })

+ 43 - 0
src/models/SessionAttendanceSheets.js

@@ -0,0 +1,43 @@
+import { Model, Collection } from 'js-abstract-model'
+
+class SessionAttendanceSheets extends Model {
+  constructor (data) {
+    super(data, [
+      { key: 'id' },
+      { key: 'session' },
+      { key: 'is_listen_part1' },
+      { key: 'is_listen_part2' },
+      { key: 'is_present_read_part1' },
+      { key: 'is_present_read_part2' }
+    ])
+  }
+
+  getLabel () {
+    if (this.is_listen_part1 && this.is_listen_part2 && this.is_present_read_part1 && this.is_present_read_part2) {
+      return 'حاضر'
+    } else if (this.is_listen_part1 && this.is_listen_part2 && this.is_present_read_part1 && !this.is_present_read_part2) {
+      return 'حاضر'
+    } else if (this.is_listen_part1 && this.is_listen_part2 && !this.is_present_read_part1 && !this.is_present_read_part2) {
+      return 'حاضر'
+    } else if (this.is_listen_part1 && !this.is_listen_part2 && !this.is_present_read_part1 && !this.is_present_read_part2) {
+      return 'حاضر'
+    } else if (this.is_listen_part1) {
+      return 'قسمت اول'
+    } else if (this.is_listen_part2) {
+      return 'قسمت دوم'
+    } else if (this.is_present_read_part1) {
+      return 'قسمت اول'
+    } else if (this.is_present_read_part2) {
+      return 'قسمت اول'
+    } else {
+      return 'غایب'
+    }
+  }
+}
+
+class SessionAttendanceSheetsList extends Collection {
+  model () {
+    return SessionAttendanceSheets
+  }
+}
+export { SessionAttendanceSheets, SessionAttendanceSheetsList }