Blame view
src/pages/Mark/mark.vue
20.8 KB
68d742034
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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 |
<template> <v-container fluid class="body-color"> <!-- ****** EXISTING MARK 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="addMarkDialog = true" > <v-icon dark>add</v-icon> </v-btn> <v-btn round class="open-dialog-button hidden-sm-only hidden-xs-only" dark @click="addMarkDialog = true" > <v-icon class="white--text pr-1" size="20">add</v-icon>Add Mark </v-btn> <v-layout class="hidden-sm-only hidden-xs-only"> <v-flex md3 lg2 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-flex md3 lg2 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-spacer></v-spacer> <v-btn @click="getStudents" round dark :loading="loading" class="right open-dialog-button mt-2" >Mark</v-btn> </v-layout> <v-spacer class="hidden-lg-only hidden-xl-only hidden-md-only"></v-spacer> <v-card-title class="body-1" v-show="show"> <v-btn icon large flat @click="displaySearch"> <v-avatar size="27"> |
aa310d61a
|
59 |
<img src="/static/icon/search.png" alt="icon" /> |
68d742034
|
60 61 62 |
</v-avatar> </v-btn> </v-card-title> |
612b79bb4
|
63 |
<v-flex xs8 sm8 md3 lg2 v-if="showSearch"> |
68d742034
|
64 |
<v-layout> |
8e8d14254
|
65 66 67 68 69 70 71 |
<v-text-field autofocus v-model="search" label="Search" prepend-inner-icon="search" color="primary" ></v-text-field> |
68d742034
|
72 73 74 75 76 77 78 79 80 81 82 |
<v-icon @click="closeSearch" color="error">close</v-icon> </v-layout> </v-flex> </v-toolbar> <v-card flat class="elevation-0 transparent hidden-lg-only hidden-xl-only hidden-md-only"> <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> |
006544386
|
83 |
</v-flex> |
68d742034
|
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
<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> |
006544386
|
102 |
</v-flex> |
68d742034
|
103 104 105 106 107 108 109 110 111 112 |
<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> |
006544386
|
113 114 115 |
</v-flex> </v-layout> </v-flex> |
68d742034
|
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 |
<v-flex xs12 sm12 lg6> <v-btn @click="getStudents" round dark :loading="loading" class="right mt-3 open-dialog-button" >Mark</v-btn> </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"> <tr class="tr"> <td class="td td-row">{{ props.index + 1}}</td> <td class="td td-row text-xs-center"> <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> <td class="td td-row text-xs-center"> <span> |
2fe1115d8
|
148 |
<router-link :to="{ name:'view Mark',params: { markId:props.item._id } }"> |
68d742034
|
149 150 151 152 |
<v-tooltip top> <img slot="activator" style="cursor:pointer; width:25px; height:25px; " |
aa310d61a
|
153 |
src="/static/icon/view.png" |
68d742034
|
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
/> <span>View</span> </v-tooltip> </router-link> </span> </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> <!-- ****** ADD Mark Schedule ****** --> |
db965de89
|
170 |
<v-dialog v-model="addMarkDialog" max-width v-if="addMarkDialog" persistent> |
68d742034
|
171 172 173 174 |
<v-card flat class> <v-layout class="pa-3 card-style white--text"> <v-flex xs12> <label class="title text-xs-center">Add Mark</label> |
8e8d14254
|
175 176 177 178 179 |
<v-icon size="24" class="right white--text" @click="$refs.form.reset();addMarkDialog = false" >cancel</v-icon> |
68d742034
|
180 181 |
</v-flex> </v-layout> |
006544386
|
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 |
<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" |
68d742034
|
264 |
class="right mt-4 open-dialog-button" |
006544386
|
265 266 267 268 269 |
>Mark</v-btn> </v-flex> </v-flex> </v-layout> </v-flex> |
66a5c3b75
|
270 |
<!-- ****** ADD MARK TABLE DATA ****** --> |
68d742034
|
271 |
<v-card class="mt-4 elevation-0 body-color"> |
006544386
|
272 273 274 275 276 |
<v-data-table :headers="headerOfMark" :items="getStudentData" :pagination.sync="pagination" :search="search" |
68d742034
|
277 |
class="body-color" |
006544386
|
278 279 |
> <template slot="items" slot-scope="props"> |
68d742034
|
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
<tr class="tr"> <td class="td td-row">{{ props.index + 1}}</td> <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="text-xs-center td td-row">{{ props.item.name}}</td> <td class="text-xs-center td td-row">{{ props.item.rollNo }}</td> <td class="text-xs-center markTable td td-row" v-for="(marks, index) in props.item.marksObtained" :key="'A'+ index" > <v-text-field v-model="marks.marksScored"></v-text-field> </td> </tr> |
006544386
|
298 299 300 301 302 303 304 305 306 307 308 309 310 |
</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> |
67a276510
|
311 312 313 314 315 316 317 |
<v-btn @click="submit" round dark :loading="loading" class="right add-button" >Add Mark</v-btn> |
006544386
|
318 319 320 321 322 323 |
</v-flex> </v-layout> </v-flex> </v-layout> </v-container> </v-form> |
68d742034
|
324 325 |
</v-card> </v-dialog> |
006544386
|
326 327 328 |
<div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> |
68d742034
|
329 330 331 332 333 334 335 336 337 |
<v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" :color="color" >{{ text }}</v-snackbar> </v-container> |
006544386
|
338 339 340 341 342 343 344 345 |
</template> <script> import http from "@/Services/http.js"; import moment from "moment"; export default { data: () => ({ |
68d742034
|
346 347 |
show: true, showSearch: false, |
006544386
|
348 349 |
snackbar: false, date: null, |
006544386
|
350 351 352 353 354 355 356 |
color: "", y: "top", x: "right", mode: "", timeout: 10000, text: "", loading: false, |
006544386
|
357 |
search: "", |
68d742034
|
358 359 |
show: true, showSearch: false, |
006544386
|
360 361 362 363 |
showLoader: false, dialog: false, dialog1: false, valid: true, |
68d742034
|
364 365 |
addMarkDialog: false, |
006544386
|
366 367 |
addSection: [], pagination: { |
8e8d14254
|
368 |
rowsPerPage: 10, |
006544386
|
369 |
}, |
8e8d14254
|
370 371 372 373 |
classRules: [(v) => !!v || "Class is required"], sectionRules: [(v) => !!v || "section is required"], subjectRules: [(v) => !!v || "Subject is required"], examRules: [(v) => !!v || "Exam is required"], |
006544386
|
374 375 |
headerOfMark: [ |
006544386
|
376 |
{ |
68d742034
|
377 |
align: "", |
006544386
|
378 379 |
text: "No", sortable: false, |
8e8d14254
|
380 |
value: "No", |
006544386
|
381 382 383 384 385 |
}, { text: "Profile Pic", vaue: "profilePicUrl", sortable: false, |
8e8d14254
|
386 |
align: "center", |
006544386
|
387 388 389 390 391 |
}, { text: "Name", vaue: "name", sortable: false, |
8e8d14254
|
392 |
align: "center", |
006544386
|
393 394 395 396 397 |
}, { text: "Roll No.", value: "rollNo", sortable: false, |
8e8d14254
|
398 399 |
align: "center", }, |
006544386
|
400 401 402 |
], headers: [ { |
68d742034
|
403 |
align: "", |
006544386
|
404 405 |
text: "No", sortable: false, |
8e8d14254
|
406 |
value: "No", |
006544386
|
407 408 409 410 411 |
}, { text: "Profile Pic", vaue: "profilePicUrl", sortable: false, |
8e8d14254
|
412 |
align: "center", |
006544386
|
413 414 415 416 417 |
}, { text: "Name", vaue: "name", sortable: false, |
8e8d14254
|
418 |
align: "center", |
006544386
|
419 420 421 422 423 |
}, { text: "Roll No.", value: "rollNo", sortable: false, |
8e8d14254
|
424 |
align: "center", |
006544386
|
425 426 427 428 429 |
}, { text: "Email", value: "email", sortable: false, |
8e8d14254
|
430 |
align: "center", |
006544386
|
431 |
}, |
8e8d14254
|
432 |
{ text: "Action", value: "", sortable: false, align: "center" }, |
006544386
|
433 434 435 436 437 438 |
], classList: [], examList: [], subjects: [], addMark: {}, getMark: {}, |
006544386
|
439 440 441 442 |
getScheduleData: {}, markData: [], getStudentData: [], getStudentsList: [], |
8e8d14254
|
443 |
token: "", |
006544386
|
444 |
}), |
8e8d14254
|
445 446 447 448 449 450 451 452 |
watch: { addMarkDialog: function (val) { if (!val) { this.addMark = []; this.getStudentData = []; } }, }, |
006544386
|
453 |
methods: { |
006544386
|
454 455 456 457 |
getClass() { this.showLoader = true; http() .get("/getClassesList", { |
8e8d14254
|
458 |
headers: { Authorization: "Bearer " + this.token }, |
006544386
|
459 |
}) |
8e8d14254
|
460 |
.then((response) => { |
006544386
|
461 462 |
this.classList = response.data.data; this.showLoader = false; |
006544386
|
463 |
}) |
8e8d14254
|
464 |
.catch((err) => { |
006544386
|
465 466 467 468 469 470 471 472 |
// 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
|
473 474 475 |
this.subjects = this.classList[i].subjects; } } |
7014df603
|
476 |
this.getStudentsList = []; |
006544386
|
477 478 479 480 481 |
http() .get( "/getSectionsList", { params: { classId: _id } }, { |
8e8d14254
|
482 |
headers: { Authorization: "Bearer " + this.token }, |
006544386
|
483 484 |
} ) |
8e8d14254
|
485 |
.then((response) => { |
006544386
|
486 487 488 |
this.addSection = response.data.data; this.showLoader = false; }) |
8e8d14254
|
489 |
.catch((err) => { |
66a5c3b75
|
490 |
this.showLoader = false; |
006544386
|
491 492 493 494 495 496 497 498 |
// console.log("err====>", err); }); }, getExamList() { this.showLoader = true; this.loadingSearch = true; http() .get("/getExamsList", { |
8e8d14254
|
499 |
headers: { Authorization: "Bearer " + this.token }, |
006544386
|
500 |
}) |
8e8d14254
|
501 |
.then((response) => { |
006544386
|
502 503 504 505 |
this.examList = response.data.data; this.showLoader = false; this.loadingSearch = false; }) |
8e8d14254
|
506 |
.catch((error) => { |
006544386
|
507 508 509 510 511 512 513 514 515 |
// 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
|
516 |
this.$store.dispatch("Role", null); |
006544386
|
517 518 519 520 |
} }); }, findStudents() { |
ec5677f43
|
521 |
this.getStudentData = []; |
006544386
|
522 523 524 525 526 527 |
if (this.$refs.form.validate()) { this.showLoader = true; http() .get("/getStudentWithClass", { params: { classId: this.addMark.classId, |
8e8d14254
|
528 529 |
sectionId: this.addMark.sectionId, }, |
006544386
|
530 |
}) |
8e8d14254
|
531 |
.then((response) => { |
006544386
|
532 |
this.getStudentData = response.data.data; |
a5767c232
|
533 |
// this.showLoader = false; |
006544386
|
534 535 536 |
this.showLoader = true; http() .get("/getMarkDistributionsList", { |
8e8d14254
|
537 |
params: this.addMark, |
006544386
|
538 |
}) |
8e8d14254
|
539 |
.then((response) => { |
006544386
|
540 |
this.showLoader = false; |
ec5677f43
|
541 |
this.headerOfMark.length = 4; |
006544386
|
542 543 544 545 546 547 548 549 |
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, |
8e8d14254
|
550 |
align: "center", |
006544386
|
551 552 |
}); } |
ec5677f43
|
553 554 |
for (var n = 0; n < this.getStudentData.length; n++) { this.getStudentData[n].marksObtained = []; |
006544386
|
555 |
for (var j = 0; j < response.data.data.length; j++) { |
ec5677f43
|
556 |
this.getStudentData[n].marksObtained.push({ |
006544386
|
557 |
markDistributionId: response.data.data[j]._id, |
a5767c232
|
558 559 |
marksScored: 0, markValue: response.data.data[j].markValue, |
8e8d14254
|
560 |
distributionType: response.data.data[j].distributionType, |
006544386
|
561 562 |
}); } |
46993dc1d
|
563 564 565 566 |
// if (marks.marksScored > marks.marksObtained) { // this.getStudentData[n].marksScored = this.getStudentData[n].marksObtained; // this.marks.marksScored = marks.marksObtained; // } |
006544386
|
567 |
} |
006544386
|
568 |
}) |
8e8d14254
|
569 |
.catch((error) => { |
006544386
|
570 571 572 |
this.showLoader = false; }); }) |
8e8d14254
|
573 |
.catch((error) => { |
006544386
|
574 575 576 577 |
this.showLoader = false; }); } }, |
a5767c232
|
578 579 580 581 582 583 584 585 586 587 588 589 590 |
async submit() { for (let [j, item] of this.getStudentData.entries()) { for (var k = 0; k < item.marksObtained.length; k++) { if ( item.marksObtained[k].marksScored > item.marksObtained[k].markValue ) { this.snackbar = true; this.text = `Student (${item.name}) marks (${item.marksObtained[k].marksScored}) in "${item.marksObtained[k].distributionType}" should not be greater than Total Marks (${item.marksObtained[k].markValue})`; this.color = "error"; return; } } |
79583580d
|
591 592 593 594 595 |
let data = { examId: this.addMark.examId, classId: this.addMark.classId, sectionId: this.addMark.sectionId, subjectId: this.addMark.subjectId, |
a5767c232
|
596 |
studentId: item._id, |
8e8d14254
|
597 |
studentsMarks: item.marksObtained, |
79583580d
|
598 |
}; |
a5767c232
|
599 600 601 |
try { let response = await http().post("/createMark", data); if (j + 1 === this.getStudentData.length) { |
ec5677f43
|
602 |
this.getStudentData = []; |
006544386
|
603 |
this.snackbar = true; |
67a276510
|
604 |
this.addMarkDialog = false; |
006544386
|
605 606 |
this.text = response.data.message; this.color = "green"; |
8e8d14254
|
607 |
this.$refs.form.reset(); |
a5767c232
|
608 609 610 611 612 613 |
} } catch (error) { this.snackbar = true; this.text = error.response.data.message; this.color = "red"; } |
006544386
|
614 615 616 617 618 619 620 621 |
} }, getStudents() { this.showLoader = true; http() .get("/getStudentWithClass", { params: { classId: this.getMark.classId, |
8e8d14254
|
622 623 |
sectionId: this.getMark.sectionId, }, |
006544386
|
624 |
}) |
8e8d14254
|
625 |
.then((response) => { |
006544386
|
626 627 |
this.getStudentsList = response.data.data; this.showLoader = false; |
006544386
|
628 |
}) |
8e8d14254
|
629 |
.catch((error) => { |
860da881d
|
630 |
// console.log("err====>", error); |
006544386
|
631 |
this.showLoader = false; |
860da881d
|
632 633 634 |
this.snackbar = true; this.color = "error"; this.text = error.response.data.message; |
006544386
|
635 |
}); |
68d742034
|
636 637 638 639 640 641 642 643 |
}, displaySearch() { (this.show = false), (this.showSearch = true); }, closeSearch() { this.showSearch = false; this.show = true; this.search = ""; |
8e8d14254
|
644 |
}, |
006544386
|
645 646 647 |
}, mounted() { this.token = this.$store.state.token; |
006544386
|
648 649 |
this.getClass(); this.getExamList(); |
8e8d14254
|
650 |
}, |
006544386
|
651 652 653 |
}; </script> <style scoped> |
006544386
|
654 |
.markTable { |
495e4037c
|
655 |
max-width: 80px !important; |
006544386
|
656 |
} |
ec5677f43
|
657 |
</style> |