Blame view

src/pages/Exam/examAttendence.vue 25.5 KB
710438de6   Shikha Mishra   added teacher mod...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  <template>
    <v-container fluid class="body-color">
      <!-- *****  Exam Schedule TABLE****** -->
      <v-toolbar color="transparent" flat>
        <v-btn
          fab
          dark
          class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
          small
          @click="addExamAttendenceDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-btn
          round
          class="open-dialog-button hidden-sm-only hidden-xs-only"
          dark
          @click="addExamAttendenceDialog = true"
        >
          <v-icon class="white--text pr-1" size="20">add</v-icon>Add Exam Attendence
        </v-btn>
        <v-spacer></v-spacer>
        <v-flex xs8 sm3 md2 class="mr-3">
          <v-select
b039d39fb   Shikha Mishra   Hide Edit functio...
25
            v-model="getAttendence.examId"
710438de6   Shikha Mishra   added teacher mod...
26
27
28
29
30
31
32
33
34
35
            label="Select Exam"
            :rules="examRules"
            :items="examList"
            item-text="examName"
            item-value="_id"
            required
          ></v-select>
        </v-flex>
        <v-flex xs8 sm3 md2 class="mr-3">
          <v-select
b039d39fb   Shikha Mishra   Hide Edit functio...
36
            v-model="getAttendence.classId"
710438de6   Shikha Mishra   added teacher mod...
37
38
39
40
41
            label="Select your class"
            type="text"
            :items="classList"
            item-text="classNum"
            item-value="_id"
b039d39fb   Shikha Mishra   Hide Edit functio...
42
            @change="getSections(getAttendence.classId)"
710438de6   Shikha Mishra   added teacher mod...
43
44
45
46
47
            required
          ></v-select>
        </v-flex>
        <v-flex xs8 sm3 md2 class="mr-3">
          <v-select
b039d39fb   Shikha Mishra   Hide Edit functio...
48
            v-model="getAttendence.sectionId"
710438de6   Shikha Mishra   added teacher mod...
49
50
51
52
53
            label="Select your section"
            type="text"
            :items="addSection"
            item-text="name"
            item-value="_id"
b039d39fb   Shikha Mishra   Hide Edit functio...
54
            @change="getClassSubject(getAttendence.classId)"
710438de6   Shikha Mishra   added teacher mod...
55
56
57
58
59
            required
          ></v-select>
        </v-flex>
        <v-flex xs8 sm3 md2 class="mr-3">
          <v-select
b039d39fb   Shikha Mishra   Hide Edit functio...
60
            v-model="getAttendence.subjectId"
710438de6   Shikha Mishra   added teacher mod...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
            label="Select Subject"
            :rules="subjectRules"
            :items="subjectList.subjects"
            item-text="subjectName"
            item-value="_id"
            @change="getExamAttendenceList()"
            required
          ></v-select>
        </v-flex>
  
        <v-card-title class="body-1" v-show="show">
          <v-btn icon large flat @click="displaySearch">
            <v-avatar size="27">
              <img src="/static/icon/search.png" alt="icon" />
            </v-avatar>
          </v-btn>
        </v-card-title>
612b79bb4   Amber Dev   made serch auto f...
78
        <v-flex xs8 sm8 md3 lg2 v-if="showSearch">
710438de6   Shikha Mishra   added teacher mod...
79
          <v-layout>
73679431a   Shikha Mishra   clear add exam at...
80
81
82
83
84
85
86
            <v-text-field
              autofocus
              v-model="search"
              label="Search"
              prepend-inner-icon="search"
              color="primary"
            ></v-text-field>
710438de6   Shikha Mishra   added teacher mod...
87
88
89
90
91
92
            <v-icon @click="closeSearch" color="error">close</v-icon>
          </v-layout>
        </v-flex>
      </v-toolbar>
  
      <v-data-table
058c4a6cf   Shikha Mishra   Improve the funct...
93
        v-if="showData"
710438de6   Shikha Mishra   added teacher mod...
94
95
96
97
98
99
100
101
102
103
        :headers="headers"
        :items="examData.students"
        :pagination.sync="pagination"
        :search="search"
      >
        <template slot="items" slot-scope="props">
          <tr class="tr">
            <td class="td td-row">{{ props.index + 1}}</td>
            <td class="text-xs-center td td-row">
              <v-avatar size="40">
058c4a6cf   Shikha Mishra   Improve the funct...
104
105
106
107
108
                <img
                  :src="props.item.studentId.profilePicUrl"
                  v-if="props.item.studentId.profilePicUrl"
                />
                <img src="/static/icon/user.png" v-else-if="!props.item.studentId.profilePicUrl" />
710438de6   Shikha Mishra   added teacher mod...
109
110
111
112
113
114
              </v-avatar>
            </td>
            <td class="td td-row text-xs-center">{{ props.item.studentId.name}}</td>
            <td class="td td-row text-xs-center">{{ props.item.studentId.rollNo}}</td>
            <td class="td td-row text-xs-center">{{ props.item.studentId.email }}</td>
            <td class="td td-row text-xs-center">
058c4a6cf   Shikha Mishra   Improve the funct...
115
116
117
118
119
120
121
122
123
              <!-- <v-radio-group v-model="isPresent" row>
                <v-radio :value="props.item.isPresent"></v-radio>
              </v-radio-group>-->
              <v-checkbox
                v-model="props.item.isPresent"
                @click="markStudentAttendence(props.item)"
                primary
                hide-details
              ></v-checkbox>
710438de6   Shikha Mishra   added teacher mod...
124
125
126
127
128
129
130
131
132
133
            </td>
          </tr>
        </template>
        <v-alert
          slot="no-results"
          :value="true"
          color="error"
          icon="warning"
        >Your search for "{{ search }}" found no results.</v-alert>
      </v-data-table>
058c4a6cf   Shikha Mishra   Improve the funct...
134
      <!-- ****** ADD  Student Attendence ****** -->
db965de89   Amber Dev   added dialog pers...
135
      <v-dialog v-model="changeStudentAttendenceDialog" max-width="500px" persistent>
058c4a6cf   Shikha Mishra   Improve the funct...
136
        <v-card flat>
4dd422bef   Shikha Mishra   change ui of card...
137
          <v-layout class="pa-3 Card-style">
058c4a6cf   Shikha Mishra   Improve the funct...
138
139
            <v-flex xs12>
              <label class="title text-xs-center">Change Student's Attendence</label>
4dd422bef   Shikha Mishra   change ui of card...
140
              <v-icon size="24" class="right" @click="changeStudentAttendenceDialog = false">cancel</v-icon>
058c4a6cf   Shikha Mishra   Improve the funct...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
            </v-flex>
          </v-layout>
          <v-container fluid>
            <v-flex xs12>
              <h3>Are you sure you want to change the attendence</h3>
            </v-flex>
            <v-spacer></v-spacer>
  
            <v-flex xs12>
              <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn
                  @click.native="closeStudentAttendenceDialog"
                  round
                  dark
                  class="clear-button"
                >cancel</v-btn>
                <v-btn
                  @click="selectParticularStudent"
                  round
                  dark
                  :loading="loading"
                  class="add-button"
                >Yes</v-btn>
              </v-card-actions>
            </v-flex>
          </v-container>
        </v-card>
      </v-dialog>
710438de6   Shikha Mishra   added teacher mod...
170
      <!-- ****** ADD  Exam Attendence ****** -->
860da881d   Shikha Mishra   comment all consoles
171
172
173
174
175
176
      <v-dialog
        v-model="addExamAttendenceDialog"
        max-width="800px"
        v-if="addExamAttendenceDialog"
        persistent
      >
058c4a6cf   Shikha Mishra   Improve the funct...
177
        <v-card flat>
4dd422bef   Shikha Mishra   change ui of card...
178
          <v-layout class="pa-3 Card-style">
710438de6   Shikha Mishra   added teacher mod...
179
180
            <v-flex xs12>
              <label class="title text-xs-center">Add Exam Attendence</label>
4dd422bef   Shikha Mishra   change ui of card...
181
              <v-icon size="24" class="right" @click="closeAttendenceModel">cancel</v-icon>
710438de6   Shikha Mishra   added teacher mod...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
            </v-flex>
          </v-layout>
          <v-form ref="form" v-model="valid" lazy-validation class="text-xs-center">
            <v-container fluid>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs5 class="pt-4 subheading">
                    <label class="right">Exam Name:</label>
                  </v-flex>
                  <v-flex xs7 sm7 md6 class="ml-3">
                    <v-select
                      label="Select Exam"
                      :rules="examRules"
                      :items="examList"
                      v-model="addAttendence.examId"
                      item-text="examName"
                      item-value="_id"
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs5 class="pt-4 subheading">
                    <label class="right">Class:</label>
                  </v-flex>
                  <v-flex xs7 sm7 md6 class="ml-3">
                    <v-select
                      v-model="addAttendence.classId"
                      label="Select Class"
                      type="text"
                      :items="classList"
                      item-text="classNum"
                      item-value="_id"
                      :rules="classRules"
                      @change="getSections(addAttendence.classId)"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs5 class="pt-4 subheading">
                    <label class="right">Section:</label>
                  </v-flex>
                  <v-flex xs7 sm7 md6 class="ml-3">
                    <v-select
                      :items="addSection"
                      label="Select Section"
                      v-model="addAttendence.sectionId"
                      item-text="name"
                      item-value="_id"
                      name="Select Section"
                      :rules="sectionRules"
                      @change="getClassSubject(addAttendence.classId)"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs5 class="pt-4 subheading">
                    <label class="right">Subject Name:</label>
                  </v-flex>
                  <v-flex xs7 sm7 md6 class="ml-3">
                    <v-select
                      :items="subjectList.subjects"
                      label="Select Subject"
                      item-text="subjectName"
                      v-model="addAttendence.subjectId"
                      item-value="_id"
                      name="Select Subject"
                      :rules="subjectRules"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-layout>
                <v-flex xs12>
                  <v-card-actions>
                    <v-spacer class="hidden-xs-only"></v-spacer>
                    <v-btn
                      round
                      dark
                      @click="showTable"
                      :loading="loading"
                      class="add-button"
                    >Attendence</v-btn>
                  </v-card-actions>
                </v-flex>
              </v-layout>
            </v-container>
          </v-form>
          <v-flex xs12 v-show="attendeceTable" class>
            <v-data-table
058c4a6cf   Shikha Mishra   Improve the funct...
280
              :headers="studentheader"
710438de6   Shikha Mishra   added teacher mod...
281
282
283
              :items="studentsData"
              :pagination.sync="pagination"
              :search="search"
058c4a6cf   Shikha Mishra   Improve the funct...
284
285
286
              select-all
              v-model="selected"
              item-key="_id"
710438de6   Shikha Mishra   added teacher mod...
287
288
289
            >
              <template slot="items" slot-scope="props">
                <tr class="tr">
058c4a6cf   Shikha Mishra   Improve the funct...
290
291
292
293
294
295
296
297
298
                  <!-- <td class="td td-row">{{ props.index + 1}}</td> -->
                  <td class="td td-row">
                    <v-checkbox
                      v-model="props.item.attendence"
                      @change="markParticularStudentAttendence(props.item)"
                      primary
                      hide-details
                    ></v-checkbox>
                  </td>
710438de6   Shikha Mishra   added teacher mod...
299
300
301
302
303
304
305
306
307
                  <td class="text-xs-center td td-row">
                    <v-avatar size="40">
                      <img :src="props.item.profilePicUrl" v-if="props.item.profilePicUrl" />
                      <img src="/static/icon/user.png" v-else-if="!props.item.profilePicUrl" />
                    </v-avatar>
                  </td>
                  <td class="td td-row text-xs-center">{{ props.item.name}}</td>
                  <td class="td td-row text-xs-center">{{ props.item.rollNo}}</td>
                  <td class="td td-row text-xs-center">{{ props.item.email }}</td>
058c4a6cf   Shikha Mishra   Improve the funct...
308
                  <!-- <td class="td td-row text-xs-center">
710438de6   Shikha Mishra   added teacher mod...
309
310
311
312
313
314
315
316
                    <v-radio-group v-model="props.item.attendence" :mandatory="false" row>
                      <v-radio
                        v-for="attendences in attendenceType"
                        :key="attendences.value"
                        :label="`${attendences.label}`"
                        :value="attendences.value"
                      ></v-radio>
                    </v-radio-group>
058c4a6cf   Shikha Mishra   Improve the funct...
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
                  </td>-->
                </tr>
              </template>
              <template slot="headers" slot-scope="props">
                <tr>
                  <th>
                    <v-checkbox
                      :input-value="props.all"
                      :indeterminate="props.indeterminate"
                      primary
                      hide-details
                      @click.native="selectAll"
                    ></v-checkbox>
                  </th>
                  <th
                    v-for="header in props.headers"
                    :key="header.text"
                    :class="['column sortable', pagination.descending ? 'desc' : 'asc', header.value === pagination.sortBy ? 'active' : '']"
                    @click="changeSort(header.value)"
                  >
                    <v-icon small>arrow_upward</v-icon>
                    {{ header.text }}
                  </th>
710438de6   Shikha Mishra   added teacher mod...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
                </tr>
              </template>
              <v-alert
                slot="no-results"
                :value="true"
                color="error"
                icon="warning"
              >Your search for "{{ search }}" found no results.</v-alert>
            </v-data-table>
            <v-flex xs12 sm12>
              <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn @click="submit()" round dark :loading="loading" class="add-button">Submit</v-btn>
              </v-card-actions>
            </v-flex>
          </v-flex>
        </v-card>
      </v-dialog>
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        :color="color"
      >{{ text }}</v-snackbar>
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
    </v-container>
  </template>
  
  <script>
  import http from "@/Services/http.js";
  import Util from "@/util";
  import moment from "moment";
  
  export default {
    data: () => ({
      snackbar: false,
      editDate: false,
      menu1: false,
      menuB: false,
      menu2: false,
      menuEdit: false,
      timeToEdit: false,
      show: true,
      showSearch: false,
      addExamAttendenceDialog: false,
      color: "",
      y: "top",
      x: "right",
      mode: "",
      timeout: 10000,
      text: "",
      loading: false,
      search: "",
      showLoader: false,
      valid: true,
      role: "",
      pagination: {
058c4a6cf   Shikha Mishra   Improve the funct...
401
        rowsPerPage: 10,
710438de6   Shikha Mishra   added teacher mod...
402
403
404
      },
      attendeceTable: false,
      isPresent: true,
058c4a6cf   Shikha Mishra   Improve the funct...
405
406
407
408
409
410
411
412
      examRules: [(v) => !!v || "Exam Name is required"],
      classRules: [(v) => !!v || "Class Name is required"],
      sectionRules: [(v) => !!v || "section is required"],
      subjectRules: [(v) => !!v || "Subject is required"],
      timeInRules: [(v) => !!v || "Time In is required"],
      timeOutRules: [(v) => !!v || "time Out s is required"],
      roomRules: [(v) => !!v || "Room is required"],
      examScheduleDateRules: [(v) => !!v || "Date is required"],
710438de6   Shikha Mishra   added teacher mod...
413
414
415
416
417
418
419
420
421
      studentsData: [],
      examData: [],
      students: [],
  
      headers: [
        {
          align: "",
          text: "No",
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
422
          value: "No",
710438de6   Shikha Mishra   added teacher mod...
423
424
425
        },
        {
          text: "Profile Pic",
058c4a6cf   Shikha Mishra   Improve the funct...
426
          value: "profilePicUrl",
710438de6   Shikha Mishra   added teacher mod...
427
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
428
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
429
430
431
432
433
        },
        {
          text: "Name",
          value: "name",
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
434
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
435
436
437
438
439
        },
        {
          text: "Roll No",
          value: "rollNo",
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
440
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
441
442
443
444
445
        },
        {
          text: "Email",
          value: "email",
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
446
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
447
448
449
        },
        {
          text: "Action",
058c4a6cf   Shikha Mishra   Improve the funct...
450
          value: "isPresent",
710438de6   Shikha Mishra   added teacher mod...
451
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
          align: "center",
        },
      ],
      studentheader: [
        {
          text: "Profile Pic",
          value: "profilePicUrl",
          sortable: false,
          align: "center",
        },
        {
          text: "Name",
          value: "name",
          sortable: false,
          align: "center",
        },
        {
          text: "Roll No",
          value: "rollNo",
          sortable: false,
          align: "center",
        },
        {
          text: "Email",
          value: "email",
          sortable: false,
          align: "center",
        },
710438de6   Shikha Mishra   added teacher mod...
480
481
482
483
      ],
      attendenceType: [
        {
          label: "",
058c4a6cf   Shikha Mishra   Improve the funct...
484
485
          value: true,
        },
710438de6   Shikha Mishra   added teacher mod...
486
487
488
489
490
491
492
      ],
      classList: [],
      addSection: [],
      examList: [],
      subjectList: [],
      subjects: [],
      addAttendence: {},
b039d39fb   Shikha Mishra   Hide Edit functio...
493
      getAttendence: {},
710438de6   Shikha Mishra   added teacher mod...
494
495
      editedItem: {
        sectionId: {
058c4a6cf   Shikha Mishra   Improve the funct...
496
497
          name: "",
        },
710438de6   Shikha Mishra   added teacher mod...
498
499
500
      },
      getScheduleData: {},
      ScheduleData: [],
058c4a6cf   Shikha Mishra   Improve the funct...
501
502
503
504
505
506
507
508
509
510
      token: "",
      showData: false,
      selected: [],
      changeStudentAttendenceDialog: false,
      closeStudentAttendenceDialog() {
        this.changeStudentAttendenceDialog = false;
      },
      selectedStudent: {},
      presentStudent: [],
      absentStudent: [],
710438de6   Shikha Mishra   added teacher mod...
511
    }),
a4ac8d20f   Shikha Mishra   fixed issues of c...
512
513
514
515
516
517
518
519
520
521
522
    watch: {
      addExamAttendenceDialog: function (val) {
        if (!val) {
          this.studentsData = [];
          this.selected = [];
          this.attendeceTable = false;
          this.valid = false;
          this.addAttendence = [];
        }
      },
    },
710438de6   Shikha Mishra   added teacher mod...
523
524
525
526
    methods: {
      pickFile() {
        this.$refs.image.click();
      },
058c4a6cf   Shikha Mishra   Improve the funct...
527
528
529
530
531
532
533
      markStudentAttendence(item) {
        this.selectedStudent = {
          id: item.studentId._id,
          isPresent: !item.isPresent,
        };
        this.changeStudentAttendenceDialog = true;
      },
710438de6   Shikha Mishra   added teacher mod...
534
535
536
537
538
      getSchedulesList() {
        this.showLoader = true;
        http()
          .get("/getSchedulesList", {
            params: { classId: this.getScheduleData.classId },
058c4a6cf   Shikha Mishra   Improve the funct...
539
            headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
540
          })
058c4a6cf   Shikha Mishra   Improve the funct...
541
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
542
            this.ScheduleData = response.data.data;
710438de6   Shikha Mishra   added teacher mod...
543
544
            this.showLoader = false;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
545
          .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
            // console.log("err====>", err);
            this.showLoader = false;
            this.loadingSearch = false;
            this.snackbar = true;
            this.text = error.response.data.message;
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
          });
      },
      close() {
        this.dialog = false;
      },
a4ac8d20f   Shikha Mishra   fixed issues of c...
561
562
563
564
565
566
567
568
      closeAttendenceModel() {
        this.addExamAttendenceDialog = false;
        this.studentsData = [];
        this.selected = [];
        this.attendeceTable = false;
        this.valid = false;
        this.addAttendence = [];
      },
710438de6   Shikha Mishra   added teacher mod...
569
570
571
572
573
574
      submit() {
        var examAttendence = {
          examId: this.addAttendence.examId,
          classId: this.addAttendence.classId,
          sectionId: this.addAttendence.sectionId,
          subjectId: this.addAttendence.subjectId,
058c4a6cf   Shikha Mishra   Improve the funct...
575
          students: [],
710438de6   Shikha Mishra   added teacher mod...
576
        };
058c4a6cf   Shikha Mishra   Improve the funct...
577
578
579
580
581
582
583
        for (var j = 0; j < this.presentStudent.length; j++) {
          examAttendence.students.push({
            studentId: this.presentStudent[j],
            isPresent: true,
          });
        }
        for (var j = 0; j < this.absentStudent.length; j++) {
710438de6   Shikha Mishra   added teacher mod...
584
          examAttendence.students.push({
058c4a6cf   Shikha Mishra   Improve the funct...
585
586
            studentId: this.absentStudent[j],
            isPresent: false,
710438de6   Shikha Mishra   added teacher mod...
587
588
          });
        }
710438de6   Shikha Mishra   added teacher mod...
589
590
591
        if (this.$refs.form.validate()) {
          http()
            .post("/createExamAttendance", examAttendence)
058c4a6cf   Shikha Mishra   Improve the funct...
592
            .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
593
594
595
596
              this.snackbar = true;
              this.color = "success";
              this.text = "Successfully created exam attendence";
              this.addExamAttendenceDialog = false;
73679431a   Shikha Mishra   clear add exam at...
597
598
599
600
601
              this.studentsData = [];
              this.selected = [];
              this.attendeceTable = false;
              this.valid = false;
              this.addAttendence = [];
710438de6   Shikha Mishra   added teacher mod...
602
            })
058c4a6cf   Shikha Mishra   Improve the funct...
603
            .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
604
605
606
607
608
609
610
611
612
613
614
615
616
              this.snackbar = true;
              this.text = error.response.data.message;
            });
        }
      },
      clear() {
        this.$refs.form.reset();
        this.disable = false;
        this.loading = false;
      },
      getClass() {
        http()
          .get("/getClassesList", {
058c4a6cf   Shikha Mishra   Improve the funct...
617
            headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
618
          })
058c4a6cf   Shikha Mishra   Improve the funct...
619
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
620
621
            this.classList = response.data.data;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
622
          .catch((err) => {
710438de6   Shikha Mishra   added teacher mod...
623
624
625
626
627
628
629
630
631
            // console.log("err====>", err);
          });
      },
      getSections(_id) {
        for (let i = 0; i < this.classList.length; i++) {
          if (_id == this.classList[i]._id) {
            // this.subjects = this.classList[i].subjects;
          }
        }
e05668b28   Shikha Mishra   Clear preavious d...
632
        this.examData = [];
710438de6   Shikha Mishra   added teacher mod...
633
634
635
636
637
        http()
          .get(
            "/getSectionsList",
            { params: { classId: _id } },
            {
058c4a6cf   Shikha Mishra   Improve the funct...
638
              headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
639
640
            }
          )
058c4a6cf   Shikha Mishra   Improve the funct...
641
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
642
643
            this.addSection = response.data.data;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
644
          .catch((err) => {});
710438de6   Shikha Mishra   added teacher mod...
645
646
647
648
649
650
651
652
653
      },
      getClassSubject(_id) {
        this.showLoader = true;
        // this.classId = this.classId;
        http()
          .get(
            "/getParticularClass",
            { params: { classId: _id } },
            {
058c4a6cf   Shikha Mishra   Improve the funct...
654
              headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
655
656
            }
          )
058c4a6cf   Shikha Mishra   Improve the funct...
657
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
658
659
660
            this.subjectList = response.data.data;
            this.showLoader = false;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
661
          .catch((err) => {
710438de6   Shikha Mishra   added teacher mod...
662
663
664
665
666
667
668
669
            this.showLoader = false;
          });
      },
      getExamList() {
        this.showLoader = true;
        this.loadingSearch = true;
        http()
          .get("/getExamsList", {
058c4a6cf   Shikha Mishra   Improve the funct...
670
            headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
671
          })
058c4a6cf   Shikha Mishra   Improve the funct...
672
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
673
674
675
676
            this.examList = response.data.data;
            this.showLoader = false;
            this.loadingSearch = false;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
677
          .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
            this.showLoader = false;
            this.loadingSearch = false;
            this.snackbar = true;
            this.text = error.response.data.message;
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
          });
      },
      showTable() {
        this.attendeceTable = true;
        this.getStudentList();
      },
      getStudentList() {
        this.showLoader = true;
        http()
          .get("/getStudentWithClass", {
            params: {
              classId: this.addAttendence.classId,
058c4a6cf   Shikha Mishra   Improve the funct...
699
700
              sectionId: this.addAttendence.sectionId,
            },
710438de6   Shikha Mishra   added teacher mod...
701
          })
058c4a6cf   Shikha Mishra   Improve the funct...
702
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
703
704
705
706
707
708
709
710
            this.studentsData = response.data.data;
            this.showLoader = false;
            // this.addExamAttendenceDialog = false;
            var attendence = "";
            for (let i = 0; i < this.studentsData.length; i++) {
              this.studentsData[i].attendence = false;
            }
          })
058c4a6cf   Shikha Mishra   Improve the funct...
711
          .catch((err) => {
860da881d   Shikha Mishra   comment all consoles
712
            //   console.log("err====>", err);
710438de6   Shikha Mishra   added teacher mod...
713
            this.showLoader = false;
860da881d   Shikha Mishra   comment all consoles
714
715
716
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
710438de6   Shikha Mishra   added teacher mod...
717
718
719
720
721
722
723
          });
      },
      getExamAttendenceList() {
        this.showLoader = true;
        http()
          .get("/getExamAttendenceList", {
            params: {
b039d39fb   Shikha Mishra   Hide Edit functio...
724
725
726
              examId: this.getAttendence.examId,
              classId: this.getAttendence.classId,
              sectionId: this.getAttendence.sectionId,
058c4a6cf   Shikha Mishra   Improve the funct...
727
728
              subjectId: this.getAttendence.subjectId,
            },
710438de6   Shikha Mishra   added teacher mod...
729
          })
058c4a6cf   Shikha Mishra   Improve the funct...
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
          .then((response) => {
            this.examData = response.data.data;
            if (this.examData.length === 0) {
              this.showLoader = false;
              this.snackbar = true;
              this.text = "No Attendence found!";
              this.color = "error";
              return;
            }
            this.examData = this.examData[0];
            //   if (this.examData.students.length === 0) {
            //     this.showLoader = false;
            //     this.snackbar = true;
            //     this.text = "No Students found!";
            //     this.color = "error";
            //     return;
            //   }
            this.showData = true;
710438de6   Shikha Mishra   added teacher mod...
748
749
            this.showLoader = false;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
750
          .catch((error) => {
860da881d   Shikha Mishra   comment all consoles
751
            //   console.log("error", error);
710438de6   Shikha Mishra   added teacher mod...
752
            this.showLoader = false;
860da881d   Shikha Mishra   comment all consoles
753
754
755
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
710438de6   Shikha Mishra   added teacher mod...
756
757
          });
      },
058c4a6cf   Shikha Mishra   Improve the funct...
758
759
760
761
762
763
764
765
766
767
768
769
      markParticularStudentAttendence(selected) {
        if (selected.attendence) {
          this.selected.push(selected);
        } else {
          for (var i = 0; i < this.selected.length; i++) {
            if (this.selected[i]._id === selected._id) {
              this.selected.splice(i, 1);
              break;
            }
          }
        }
        let presentIndex = this.presentStudent.indexOf(selected._id);
73679431a   Shikha Mishra   clear add exam at...
770
        let absentIndex = this.absentStudent.indexOf(selected._id);
058c4a6cf   Shikha Mishra   Improve the funct...
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
        if (presentIndex > -1) {
          this.presentStudent.splice(presentIndex, 1);
          this.absentStudent.push(selected._id);
        } else {
          if (absentIndex > -1) {
            this.absentStudent.splice(absentIndex, 1);
          }
          this.presentStudent.push(selected._id);
        }
      },
      selectAll() {
        let markAbsent = false;
        if (this.selected.length === this.studentsData.length) markAbsent = true;
  
        this.presentStudent = [];
        this.absentStudent = [];
        this.selected = [];
  
        for (let i = 0; i < this.studentsData.length; i++) {
          if (markAbsent) {
            this.studentsData[i].attendence = false;
            this.absentStudent.push(this.studentsData[i]._id);
          } else {
            this.studentsData[i].attendence = true;
            this.presentStudent.push(this.studentsData[i]._id);
            this.selected.push(this.studentsData[i]);
          }
        }
      },
      selectParticularStudent(_id) {
        var payload = {
          examAttendanceId: this.examData._id,
          studentId: this.selectedStudent.id,
          isPresent: this.selectedStudent.isPresent,
        };
  
        http()
          .put("/updateExamAttendance", payload)
          .then((response) => {
            this.snackbar = true;
            this.color = "success";
            this.text = "Successfully change attendence";
            this.changeStudentAttendenceDialog = false;
            this.selectedStudent = {};
            this.getExamAttendenceList();
          })
          .catch((error) => {
            this.snackbar = true;
            this.text = error.response.data.message;
          });
      },
      changeSort(column) {
        if (this.pagination.sortBy === column) {
          this.pagination.descending = !this.pagination.descending;
        } else {
          this.pagination.sortBy = column;
          this.pagination.descending = false;
        }
      },
710438de6   Shikha Mishra   added teacher mod...
830
831
832
833
834
835
836
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
058c4a6cf   Shikha Mishra   Improve the funct...
837
      },
710438de6   Shikha Mishra   added teacher mod...
838
839
840
841
842
843
    },
    mounted() {
      this.token = this.$store.state.token;
      this.getClass();
      this.getExamList();
      this.role = this.$store.state.role;
058c4a6cf   Shikha Mishra   Improve the funct...
844
    },
710438de6   Shikha Mishra   added teacher mod...
845
846
  };
  </script>