From c301facad48a1d4baae2130886040e45c81f1163 Mon Sep 17 00:00:00 2001 From: Shikha Mishra Date: Thu, 10 Sep 2020 19:02:25 +0530 Subject: [PATCH] integrated createCourseAttendance API in live online class screen --- src/pages/Dashboard/LiveOnlineClass.vue | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/pages/Dashboard/LiveOnlineClass.vue b/src/pages/Dashboard/LiveOnlineClass.vue index cc88ba5..e0b35be 100644 --- a/src/pages/Dashboard/LiveOnlineClass.vue +++ b/src/pages/Dashboard/LiveOnlineClass.vue @@ -178,6 +178,7 @@ export default { this.showLoader = false; } else { this.startConference(); + this.createAttendence(); // this.counter += 1; this.showJoinSessionButton = false; } @@ -342,6 +343,46 @@ export default { this.showLoader = false; }); }, + formatAMPM(date) { + var hours = date.getHours(); + var minutes = date.getMinutes(); + var ampm = hours >= 12 ? "pm" : "am"; + hours = hours % 12; + hours = hours ? hours : 12; // the hour '0' should be '12' + minutes = minutes < 10 ? "0" + minutes : minutes; + var strTime = hours + ":" + minutes + " " + ampm; + return strTime; + }, + createAttendence() { + let studentId = localStorage.getItem("parentStudentId"); + let todayDate = new Date(); + var attendenceData = { + classId: this.$route.query.classId, + studentId: studentId, + date: new Date().toISOString().substr(0, 10), + studentAttendance: [ + { + courseId: this.$route.query.courseId, + chapterId: this.$route.query.chapterId, + liveClassId: this.attendenceLiveClassId, + startTime: this.formatAMPM(new Date()), + }, + ], + }; + this.loading = true; + http() + .post("/createCourseAttendance", attendenceData) + .then((response) => { + this.loading = false; + // this.snackbar = true; + // this.color = "green"; + }) + .catch((err) => { + this.loading = false; + this.snackbar = true; + this.color = "error"; + }); + }, updateLiveClass() { this.showLoader = true; var payloadData = { @@ -368,6 +409,7 @@ export default { chapterId: this.$route.query.chapterId, }); // console.log("response getLiveClassesesList- ", response); + this.attendenceLiveClassId = response.data.data[0]._id; /* CHECK RESPONSE TO ASSIGN MESSAGE INSIDE BUTTON */ if (response.data.data[0].sessionStatus == "ENDED") { -- 2.0.0