Blame view

src/pages/Exam/examAttendence.vue 25.6 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
137
138
139
140
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
170
171
172
173
        <v-card flat>
          <v-layout class="pa-3 card-style white--text">
            <v-flex xs12>
              <label class="title text-xs-center">Change Student's Attendence</label>
              <v-icon
                size="24"
                class="right white--text"
                @click="changeStudentAttendenceDialog = false"
              >cancel</v-icon>
            </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...
174
      <!-- ****** ADD  Exam Attendence ****** -->
860da881d   Shikha Mishra   comment all consoles
175
176
177
178
179
180
      <v-dialog
        v-model="addExamAttendenceDialog"
        max-width="800px"
        v-if="addExamAttendenceDialog"
        persistent
      >
058c4a6cf   Shikha Mishra   Improve the funct...
181
182
        <v-card flat>
          <v-layout class="pa-3 card-style white--text">
710438de6   Shikha Mishra   added teacher mod...
183
184
            <v-flex xs12>
              <label class="title text-xs-center">Add Exam Attendence</label>
a4ac8d20f   Shikha Mishra   fixed issues of c...
185
              <v-icon size="24" class="right white--text" @click="closeAttendenceModel">cancel</v-icon>
710438de6   Shikha Mishra   added teacher mod...
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
280
281
282
283
            </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...
284
              :headers="studentheader"
710438de6   Shikha Mishra   added teacher mod...
285
286
287
              :items="studentsData"
              :pagination.sync="pagination"
              :search="search"
058c4a6cf   Shikha Mishra   Improve the funct...
288
289
290
              select-all
              v-model="selected"
              item-key="_id"
710438de6   Shikha Mishra   added teacher mod...
291
292
293
            >
              <template slot="items" slot-scope="props">
                <tr class="tr">
058c4a6cf   Shikha Mishra   Improve the funct...
294
295
296
297
298
299
300
301
302
                  <!-- <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...
303
304
305
306
307
308
309
310
311
                  <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...
312
                  <!-- <td class="td td-row text-xs-center">
710438de6   Shikha Mishra   added teacher mod...
313
314
315
316
317
318
319
320
                    <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...
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
                  </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...
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
401
402
403
404
                </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...
405
        rowsPerPage: 10,
710438de6   Shikha Mishra   added teacher mod...
406
407
408
      },
      attendeceTable: false,
      isPresent: true,
058c4a6cf   Shikha Mishra   Improve the funct...
409
410
411
412
413
414
415
416
      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...
417
418
419
420
421
422
423
424
425
      studentsData: [],
      examData: [],
      students: [],
  
      headers: [
        {
          align: "",
          text: "No",
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
426
          value: "No",
710438de6   Shikha Mishra   added teacher mod...
427
428
429
        },
        {
          text: "Profile Pic",
058c4a6cf   Shikha Mishra   Improve the funct...
430
          value: "profilePicUrl",
710438de6   Shikha Mishra   added teacher mod...
431
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
432
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
433
434
435
436
437
        },
        {
          text: "Name",
          value: "name",
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
438
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
439
440
441
442
443
        },
        {
          text: "Roll No",
          value: "rollNo",
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
444
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
445
446
447
448
449
        },
        {
          text: "Email",
          value: "email",
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
450
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
451
452
453
        },
        {
          text: "Action",
058c4a6cf   Shikha Mishra   Improve the funct...
454
          value: "isPresent",
710438de6   Shikha Mishra   added teacher mod...
455
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
          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...
484
485
486
487
      ],
      attendenceType: [
        {
          label: "",
058c4a6cf   Shikha Mishra   Improve the funct...
488
489
          value: true,
        },
710438de6   Shikha Mishra   added teacher mod...
490
491
492
493
494
495
496
      ],
      classList: [],
      addSection: [],
      examList: [],
      subjectList: [],
      subjects: [],
      addAttendence: {},
b039d39fb   Shikha Mishra   Hide Edit functio...
497
      getAttendence: {},
710438de6   Shikha Mishra   added teacher mod...
498
499
      editedItem: {
        sectionId: {
058c4a6cf   Shikha Mishra   Improve the funct...
500
501
          name: "",
        },
710438de6   Shikha Mishra   added teacher mod...
502
503
504
      },
      getScheduleData: {},
      ScheduleData: [],
058c4a6cf   Shikha Mishra   Improve the funct...
505
506
507
508
509
510
511
512
513
514
      token: "",
      showData: false,
      selected: [],
      changeStudentAttendenceDialog: false,
      closeStudentAttendenceDialog() {
        this.changeStudentAttendenceDialog = false;
      },
      selectedStudent: {},
      presentStudent: [],
      absentStudent: [],
710438de6   Shikha Mishra   added teacher mod...
515
    }),
a4ac8d20f   Shikha Mishra   fixed issues of c...
516
517
518
519
520
521
522
523
524
525
526
    watch: {
      addExamAttendenceDialog: function (val) {
        if (!val) {
          this.studentsData = [];
          this.selected = [];
          this.attendeceTable = false;
          this.valid = false;
          this.addAttendence = [];
        }
      },
    },
710438de6   Shikha Mishra   added teacher mod...
527
528
529
530
    methods: {
      pickFile() {
        this.$refs.image.click();
      },
058c4a6cf   Shikha Mishra   Improve the funct...
531
532
533
534
535
536
537
      markStudentAttendence(item) {
        this.selectedStudent = {
          id: item.studentId._id,
          isPresent: !item.isPresent,
        };
        this.changeStudentAttendenceDialog = true;
      },
710438de6   Shikha Mishra   added teacher mod...
538
539
540
541
542
      getSchedulesList() {
        this.showLoader = true;
        http()
          .get("/getSchedulesList", {
            params: { classId: this.getScheduleData.classId },
058c4a6cf   Shikha Mishra   Improve the funct...
543
            headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
544
          })
058c4a6cf   Shikha Mishra   Improve the funct...
545
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
546
            this.ScheduleData = response.data.data;
710438de6   Shikha Mishra   added teacher mod...
547
548
            this.showLoader = false;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
549
          .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
            // 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...
565
566
567
568
569
570
571
572
      closeAttendenceModel() {
        this.addExamAttendenceDialog = false;
        this.studentsData = [];
        this.selected = [];
        this.attendeceTable = false;
        this.valid = false;
        this.addAttendence = [];
      },
710438de6   Shikha Mishra   added teacher mod...
573
574
575
576
577
578
      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...
579
          students: [],
710438de6   Shikha Mishra   added teacher mod...
580
        };
058c4a6cf   Shikha Mishra   Improve the funct...
581
582
583
584
585
586
587
        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...
588
          examAttendence.students.push({
058c4a6cf   Shikha Mishra   Improve the funct...
589
590
            studentId: this.absentStudent[j],
            isPresent: false,
710438de6   Shikha Mishra   added teacher mod...
591
592
          });
        }
710438de6   Shikha Mishra   added teacher mod...
593
594
595
        if (this.$refs.form.validate()) {
          http()
            .post("/createExamAttendance", examAttendence)
058c4a6cf   Shikha Mishra   Improve the funct...
596
            .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
597
598
599
600
              this.snackbar = true;
              this.color = "success";
              this.text = "Successfully created exam attendence";
              this.addExamAttendenceDialog = false;
73679431a   Shikha Mishra   clear add exam at...
601
602
603
604
605
              this.studentsData = [];
              this.selected = [];
              this.attendeceTable = false;
              this.valid = false;
              this.addAttendence = [];
710438de6   Shikha Mishra   added teacher mod...
606
            })
058c4a6cf   Shikha Mishra   Improve the funct...
607
            .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
608
609
610
611
612
613
614
615
616
617
618
619
620
              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...
621
            headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
622
          })
058c4a6cf   Shikha Mishra   Improve the funct...
623
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
624
625
            this.classList = response.data.data;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
626
          .catch((err) => {
710438de6   Shikha Mishra   added teacher mod...
627
628
629
630
631
632
633
634
635
            // 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...
636
        this.examData = [];
710438de6   Shikha Mishra   added teacher mod...
637
638
639
640
641
        http()
          .get(
            "/getSectionsList",
            { params: { classId: _id } },
            {
058c4a6cf   Shikha Mishra   Improve the funct...
642
              headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
643
644
            }
          )
058c4a6cf   Shikha Mishra   Improve the funct...
645
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
646
647
            this.addSection = response.data.data;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
648
          .catch((err) => {});
710438de6   Shikha Mishra   added teacher mod...
649
650
651
652
653
654
655
656
657
      },
      getClassSubject(_id) {
        this.showLoader = true;
        // this.classId = this.classId;
        http()
          .get(
            "/getParticularClass",
            { params: { classId: _id } },
            {
058c4a6cf   Shikha Mishra   Improve the funct...
658
              headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
659
660
            }
          )
058c4a6cf   Shikha Mishra   Improve the funct...
661
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
662
663
664
            this.subjectList = response.data.data;
            this.showLoader = false;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
665
          .catch((err) => {
710438de6   Shikha Mishra   added teacher mod...
666
667
668
669
670
671
672
673
            this.showLoader = false;
          });
      },
      getExamList() {
        this.showLoader = true;
        this.loadingSearch = true;
        http()
          .get("/getExamsList", {
058c4a6cf   Shikha Mishra   Improve the funct...
674
            headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
675
          })
058c4a6cf   Shikha Mishra   Improve the funct...
676
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
677
678
679
680
            this.examList = response.data.data;
            this.showLoader = false;
            this.loadingSearch = false;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
681
          .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
            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...
703
704
              sectionId: this.addAttendence.sectionId,
            },
710438de6   Shikha Mishra   added teacher mod...
705
          })
058c4a6cf   Shikha Mishra   Improve the funct...
706
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
707
708
709
710
711
712
713
714
            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...
715
          .catch((err) => {
860da881d   Shikha Mishra   comment all consoles
716
            //   console.log("err====>", err);
710438de6   Shikha Mishra   added teacher mod...
717
            this.showLoader = false;
860da881d   Shikha Mishra   comment all consoles
718
719
720
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
710438de6   Shikha Mishra   added teacher mod...
721
722
723
724
725
726
727
          });
      },
      getExamAttendenceList() {
        this.showLoader = true;
        http()
          .get("/getExamAttendenceList", {
            params: {
b039d39fb   Shikha Mishra   Hide Edit functio...
728
729
730
              examId: this.getAttendence.examId,
              classId: this.getAttendence.classId,
              sectionId: this.getAttendence.sectionId,
058c4a6cf   Shikha Mishra   Improve the funct...
731
732
              subjectId: this.getAttendence.subjectId,
            },
710438de6   Shikha Mishra   added teacher mod...
733
          })
058c4a6cf   Shikha Mishra   Improve the funct...
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
          .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...
752
753
            this.showLoader = false;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
754
          .catch((error) => {
860da881d   Shikha Mishra   comment all consoles
755
            //   console.log("error", error);
710438de6   Shikha Mishra   added teacher mod...
756
            this.showLoader = false;
860da881d   Shikha Mishra   comment all consoles
757
758
759
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
710438de6   Shikha Mishra   added teacher mod...
760
761
          });
      },
058c4a6cf   Shikha Mishra   Improve the funct...
762
763
764
765
766
767
768
769
770
771
772
773
      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...
774
        let absentIndex = this.absentStudent.indexOf(selected._id);
058c4a6cf   Shikha Mishra   Improve the funct...
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
830
831
832
833
        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...
834
835
836
837
838
839
840
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
058c4a6cf   Shikha Mishra   Improve the funct...
841
      },
710438de6   Shikha Mishra   added teacher mod...
842
843
844
845
846
847
    },
    mounted() {
      this.token = this.$store.state.token;
      this.getClass();
      this.getExamList();
      this.role = this.$store.state.role;
058c4a6cf   Shikha Mishra   Improve the funct...
848
    },
710438de6   Shikha Mishra   added teacher mod...
849
850
  };
  </script>