Blame view

src/pages/Mark/mark.vue 17.7 KB
006544386   Neeraj Sharma   implement task
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
      <template>
    <v-app id="pages-dasboard">
      <v-tabs grow slider-color="gray">
        <v-tab
          ripple
          @click="activeTab('existing')"
          v-bind:class="{ active: isActive }"
          id="tab"
          class="subheading"
        >Existing Mark</v-tab>
        <v-tab
          ripple
          @click="activeTab('new')"
          v-bind:class="{ active: newActive }"
          id="tab1"
          User
          class="subheading"
        >Add Mark</v-tab>
006544386   Neeraj Sharma   implement task
19
        <v-tab-item>
006544386   Neeraj Sharma   implement task
20
          <!-- ****** EXISTING MARK TABLE ****** -->
006544386   Neeraj Sharma   implement task
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
          <v-card flat>
            <v-flex xs12 sm12 lg12>
              <v-layout wrap>
                <v-flex xs12 sm12 lg3>
                  <v-layout>
                    <v-flex xs3 sm6 lg2 class="subheading mt-4">
                      <label class="right">Class:</label>
                    </v-flex>
                    <v-flex xs12 sm12 lg8 class="ml-2">
                      <v-select
                        v-model="getMark.classId"
                        label="Select your class"
                        type="text"
                        :items="classList"
                        item-text="classNum"
                        item-value="_id"
                        @change="getSections(getMark.classId)"
                        required
                      ></v-select>
                    </v-flex>
                  </v-layout>
                </v-flex>
                <v-flex xs12 sm12 lg3>
                  <v-layout>
                    <v-flex xs3 sm6 lg2 class="subheading mt-4">
                      <label class="right">Section:</label>
                    </v-flex>
                    <v-flex xs12 sm12 lg8 class="ml-2">
                      <v-select
                        :items="addSection"
                        label="Select your Section"
                        v-model="getMark.sectionId"
                        item-text="name"
                        item-value="_id"
                        name="Select Section"
                        required
                      ></v-select>
                    </v-flex>
                  </v-layout>
                </v-flex>
                <v-flex xs12 sm12 lg6>
66a5c3b75   Neeraj Sharma   implement gloabal...
62
                  <v-btn @click="getStudents" round dark :loading="loading" class="right mt-3">Mark</v-btn>
006544386   Neeraj Sharma   implement task
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
                </v-flex>
              </v-layout>
            </v-flex>
          </v-card>
          <v-data-table
            :headers="headers"
            :items="getStudentsList"
            :pagination.sync="pagination"
            :search="search"
          >
            <template slot="items" slot-scope="props">
              <td class="text-xs-center">{{ props.index + 1}}</td>
              <td id="td" class="text-xs-center">
                <v-avatar>
                  <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 id="td" class="text-xs-center">{{ props.item.name}}</td>
              <td id="td" class="text-xs-center">{{ props.item.rollNo }}</td>
              <td id="td" class="text-xs-center">{{ props.item.email }}</td>
              <td class="text-xs-center">
                <span>
006544386   Neeraj Sharma   implement task
86
                  <router-link :to="{ name:'viewMark',params: { markId:props.item._id } }">
495e4037c   Neeraj Sharma   update
87
88
89
90
                    <v-tooltip top>
                      <img
                        slot="activator"
                        style="cursor:pointer; width:20px; height:18px; "
66a5c3b75   Neeraj Sharma   implement gloabal...
91
                        src="/static/icon/eye1.png"
495e4037c   Neeraj Sharma   update
92
                      />
66a5c3b75   Neeraj Sharma   implement gloabal...
93
                      <span>View</span>
79583580d   Neeraj Sharma   implement task ma...
94
                    </v-tooltip>
006544386   Neeraj Sharma   implement task
95
                  </router-link>
006544386   Neeraj Sharma   implement task
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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
174
175
176
177
178
179
180
181
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
                </span>
              </td>
            </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-tab-item>
  
        <!-- ****** ADD  Mark Schedule ****** -->
  
        <v-tab-item>
          <v-snackbar
            :timeout="timeout"
            :top="y === 'top'"
            :right="x === 'right'"
            :vertical="mode === 'vertical'"
            v-model="snackbar"
            :color="color"
          >{{ text }}</v-snackbar>
          <v-form ref="form" v-model="valid" lazy-validation>
            <v-container fluid>
              <v-flex xs12 sm12 lg12>
                <v-layout wrap>
                  <v-flex xs12 sm12 lg10>
                    <v-layout wrap>
                      <v-flex xs12 sm12 lg3>
                        <v-flex xs3 sm2 lg2 class="subheading">
                          <label>Exam:</label>
                        </v-flex>
                        <v-flex xs12 sm12 lg10>
                          <v-select
                            label="Select your Exam Name"
                            :items="examList"
                            v-model="addMark.examId"
                            :rules="examRules"
                            item-text="examName"
                            item-value="_id"
                          ></v-select>
                        </v-flex>
                      </v-flex>
                      <v-flex xs12 sm12 lg3>
                        <v-flex xs3 sm6 lg2 class="subheading">
                          <label>Class:</label>
                        </v-flex>
                        <v-flex xs12 sm12 lg10 class>
                          <v-select
                            v-model="addMark.classId"
                            label="Select your class"
                            type="text"
                            :items="classList"
                            item-text="classNum"
                            item-value="_id"
                            :rules="classRules"
                            @change="getSections(addMark.classId)"
                            required
                          ></v-select>
                        </v-flex>
                      </v-flex>
                      <v-flex xs12 sm12 lg3>
                        <v-flex xs3 sm6 lg2 class="subheading">
                          <label>Section:</label>
                        </v-flex>
                        <v-flex xs12 sm12 lg10 class>
                          <v-select
                            :items="addSection"
                            label="Select your Section"
                            v-model="addMark.sectionId"
                            item-text="name"
                            item-value="_id"
                            name="Select Section"
                            :rules="sectionRules"
                            required
                          ></v-select>
                        </v-flex>
                      </v-flex>
                      <v-flex xs12 sm12 lg3>
                        <v-flex xs3 sm6 lg2 class="subheading">
                          <label>Subject:</label>
                        </v-flex>
                        <v-flex xs12 sm12 lg10 class>
                          <v-select
                            :items="subjects"
                            label="Select your Subject"
                            v-model="addMark.subjectId"
                            item-text="subjectName"
                            item-value="_id"
                            name="Select Section"
                            :rules="subjectRules"
                            required
                          ></v-select>
                        </v-flex>
                      </v-flex>
                    </v-layout>
                  </v-flex>
                  <v-flex xs12 sm12 lg2>
                    <v-flex xs12 sm12 lg12>
                      <v-btn
                        @click="findStudents"
                        round
                        dark
                        :loading="loading"
                        class="right mt-4"
                      >Mark</v-btn>
                    </v-flex>
                  </v-flex>
                </v-layout>
              </v-flex>
66a5c3b75   Neeraj Sharma   implement gloabal...
207
              <!-- ****** ADD  MARK TABLE DATA ****** -->
006544386   Neeraj Sharma   implement task
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
              <v-card class="mt-4">
                <v-data-table
                  :headers="headerOfMark"
                  :items="getStudentData"
                  :pagination.sync="pagination"
                  :search="search"
                >
                  <template slot="items" slot-scope="props">
                    <td class="text-xs-center">{{ props.index + 1}}</td>
                    <td id="td" class="text-xs-center">
                      <v-avatar>
                        <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 id="td" class="text-xs-center">{{ props.item.name}}</td>
                    <td id="td" class="text-xs-center">{{ props.item.rollNo }}</td>
                    <td
                      id="td"
                      class="text-xs-center markTable"
ec5677f43   Neeraj Sharma   implement print o...
228
229
                      v-for="(marks, index) in props.item.marksObtained"
                      :key="'A'+ index"
006544386   Neeraj Sharma   implement task
230
                    >
495e4037c   Neeraj Sharma   update
231
                      <v-text-field v-model="marks.marksScored"></v-text-field>
006544386   Neeraj Sharma   implement task
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
                    </td>
                  </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-card>
              <v-layout class="mt-2">
                <v-flex xs12 sm12>
                  <v-layout>
                    <v-flex xs12>
                      <v-btn @click="submit" round dark :loading="loading" class="right">Add Mark</v-btn>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-form>
        </v-tab-item>
      </v-tabs>
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
    </v-app>
  </template>
  
  <script>
  import http from "@/Services/http.js";
  import moment from "moment";
  
  export default {
    data: () => ({
      snackbar: false,
      date: null,
006544386   Neeraj Sharma   implement task
269
270
271
272
273
274
275
      color: "",
      y: "top",
      x: "right",
      mode: "",
      timeout: 10000,
      text: "",
      loading: false,
006544386   Neeraj Sharma   implement task
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
      search: "",
      showLoader: false,
      dialog: false,
      dialog1: false,
      valid: true,
      isActive: true,
      newActive: false,
      addSection: [],
      pagination: {
        rowsPerPage: 15
      },
      classRules: [v => !!v || "Class is required"],
      sectionRules: [v => !!v || "section is required"],
      subjectRules: [v => !!v || "Subject is required"],
      examRules: [v => !!v || "Exam is required"],
  
      headerOfMark: [
006544386   Neeraj Sharma   implement task
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
        {
          align: "justify-center",
          text: "No",
          sortable: false,
          value: "No"
        },
        {
          text: "Profile Pic",
          vaue: "profilePicUrl",
          sortable: false,
          align: "center"
        },
        {
          text: "Name",
          vaue: "name",
          sortable: false,
          align: "center"
        },
        {
          text: "Roll No.",
          value: "rollNo",
          sortable: false,
          align: "center"
        }
006544386   Neeraj Sharma   implement task
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
      ],
      headers: [
        {
          align: "justify-center",
          text: "No",
          sortable: false,
          value: "No"
        },
        {
          text: "Profile Pic",
          vaue: "profilePicUrl",
          sortable: false,
          align: "center"
        },
        {
          text: "Name",
          vaue: "name",
          sortable: false,
          align: "center"
        },
        {
          text: "Roll No.",
          value: "rollNo",
          sortable: false,
          align: "center"
        },
        {
          text: "Email",
          value: "email",
          sortable: false,
          align: "center"
        },
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
      classList: [],
      examList: [],
      subjects: [],
      addMark: {},
      getMark: {},
006544386   Neeraj Sharma   implement task
356
357
358
359
360
361
362
      getScheduleData: {},
      markData: [],
      getStudentData: [],
      getStudentsList: [],
      token: ""
    }),
    methods: {
006544386   Neeraj Sharma   implement task
363
364
365
366
367
368
369
370
371
372
373
374
375
      activeTab(type) {
        switch (type) {
          case "existing":
            this.newActive = false;
            this.isActive = true;
            break;
  
          default:
            this.newActive = true;
            this.isActive = false;
            break;
        }
      },
006544386   Neeraj Sharma   implement task
376
377
378
379
380
381
382
383
384
      getClass() {
        this.showLoader = true;
        http()
          .get("/getClassesList", {
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.classList = response.data.data;
            this.showLoader = false;
006544386   Neeraj Sharma   implement task
385
386
387
388
389
390
391
392
393
394
          })
          .catch(err => {
            // console.log("err====>", err);
            this.showLoader = false;
          });
      },
      getSections(_id) {
        this.showLoader = true;
        for (let i = 0; i < this.classList.length; i++) {
          if (_id == this.classList[i]._id) {
006544386   Neeraj Sharma   implement task
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
            this.subjects = this.classList[i].subjects;
          }
        }
        http()
          .get(
            "/getSectionsList",
            { params: { classId: _id } },
            {
              headers: { Authorization: "Bearer " + this.token }
            }
          )
          .then(response => {
            this.addSection = response.data.data;
            this.showLoader = false;
          })
          .catch(err => {
66a5c3b75   Neeraj Sharma   implement gloabal...
411
            this.showLoader = false;
006544386   Neeraj Sharma   implement task
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
            // console.log("err====>", err);
          });
      },
      getExamList() {
        this.showLoader = true;
        this.loadingSearch = true;
        http()
          .get("/getExamsList", {
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.examList = response.data.data;
            this.showLoader = false;
            this.loadingSearch = false;
          })
          .catch(error => {
            // 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);
00e4bc4e1   Neeraj Sharma   fixed auntentication
437
              this.$store.dispatch("Role", null);
006544386   Neeraj Sharma   implement task
438
439
440
            }
          });
      },
66a5c3b75   Neeraj Sharma   implement gloabal...
441
442
443
      // clear() {
      //   this.$refs.form.reset();
      // },
006544386   Neeraj Sharma   implement task
444
      findStudents() {
ec5677f43   Neeraj Sharma   implement print o...
445
        this.getStudentData = [];
006544386   Neeraj Sharma   implement task
446
447
448
449
450
451
452
453
454
455
456
457
        if (this.$refs.form.validate()) {
          this.showLoader = true;
          http()
            .get("/getStudentWithClass", {
              params: {
                classId: this.addMark.classId,
                sectionId: this.addMark.sectionId
              }
            })
            .then(response => {
              this.getStudentData = response.data.data;
              this.showLoader = false;
006544386   Neeraj Sharma   implement task
458
459
460
461
462
463
464
              this.showLoader = true;
              http()
                .get("/getMarkDistributionsList", {
                  params: this.addMark
                })
                .then(response => {
                  this.showLoader = false;
ec5677f43   Neeraj Sharma   implement print o...
465
                  this.headerOfMark.length = 4;
006544386   Neeraj Sharma   implement task
466
467
468
469
470
471
472
473
474
475
476
                  for (var i = 0; i < response.data.data.length; i++) {
                    this.headerOfMark.push({
                      text:
                        response.data.data[i].distributionType +
                        " (" +
                        response.data.data[i].markValue +
                        ")",
                      sortable: false,
                      align: "center"
                    });
                  }
ec5677f43   Neeraj Sharma   implement print o...
477
478
                  for (var n = 0; n < this.getStudentData.length; n++) {
                    this.getStudentData[n].marksObtained = [];
006544386   Neeraj Sharma   implement task
479
                    for (var j = 0; j < response.data.data.length; j++) {
ec5677f43   Neeraj Sharma   implement print o...
480
                      this.getStudentData[n].marksObtained.push({
006544386   Neeraj Sharma   implement task
481
482
483
484
485
                        markDistributionId: response.data.data[j]._id,
                        marksScored: 0
                      });
                    }
                  }
006544386   Neeraj Sharma   implement task
486
487
488
489
490
491
492
493
494
495
496
497
498
                })
                .catch(error => {
                  console.log("err====>", error);
                  this.showLoader = false;
                });
            })
            .catch(error => {
              console.log("err====>", error);
              this.showLoader = false;
            });
        }
      },
      submit() {
006544386   Neeraj Sharma   implement task
499
        for (var j = 0; j < this.getStudentData.length; j++) {
79583580d   Neeraj Sharma   implement task ma...
500
501
502
503
504
          let data = {
            examId: this.addMark.examId,
            classId: this.addMark.classId,
            sectionId: this.addMark.sectionId,
            subjectId: this.addMark.subjectId,
006544386   Neeraj Sharma   implement task
505
            studentId: this.getStudentData[j]._id,
79583580d   Neeraj Sharma   implement task ma...
506
507
            studentsMarks: this.getStudentData[j].marksObtained
          };
006544386   Neeraj Sharma   implement task
508
          http()
79583580d   Neeraj Sharma   implement task ma...
509
            .post("/createMark", data)
006544386   Neeraj Sharma   implement task
510
            .then(response => {
66a5c3b75   Neeraj Sharma   implement gloabal...
511
              //  this.addMark = {}
ec5677f43   Neeraj Sharma   implement print o...
512
              this.getStudentData = [];
006544386   Neeraj Sharma   implement task
513
514
515
516
              this.snackbar = true;
              this.text = response.data.message;
              this.color = "green";
              this.loading = false;
006544386   Neeraj Sharma   implement task
517
518
            })
            .catch(error => {
79583580d   Neeraj Sharma   implement task ma...
519
520
521
              this.snackbar = true;
              this.text = error.response.data.message;
              this.color = "red";
006544386   Neeraj Sharma   implement task
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
            });
        }
      },
      getStudents() {
        this.showLoader = true;
        http()
          .get("/getStudentWithClass", {
            params: {
              classId: this.getMark.classId,
              sectionId: this.getMark.sectionId
            }
          })
          .then(response => {
            this.getStudentsList = response.data.data;
            this.showLoader = false;
            // console.log("getSectionsList=====>", response.data.data);
          })
          .catch(error => {
            console.log("err====>", error);
            this.showLoader = false;
          });
      }
    },
    mounted() {
      this.token = this.$store.state.token;
006544386   Neeraj Sharma   implement task
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
      this.getClass();
      this.getExamList();
    },
    created() {
      this.$root.$on("app:search", search => {
        this.search = search;
      });
    },
    beforeDestroy() {
      // dont forget to remove the listener
      this.$root.$off("app:search");
    }
  };
  </script>
  <style scoped>
  .active {
    background-color: gray;
    color: white !important;
  }
  .activebtn {
    color: black !important;
  }
  .markTable {
495e4037c   Neeraj Sharma   update
570
    max-width: 80px !important;
006544386   Neeraj Sharma   implement task
571
  }
ec5677f43   Neeraj Sharma   implement print o...
572
  </style>