Commit c301facad48a1d4baae2130886040e45c81f1163

Authored by Shikha Mishra
1 parent f808d58753
Exists in master and in 1 other branch ui-design

integrated createCourseAttendance API in live online class screen

Showing 1 changed file with 42 additions and 0 deletions   Show diff stats
src/pages/Dashboard/LiveOnlineClass.vue
... ... @@ -178,6 +178,7 @@ export default {
178 178 this.showLoader = false;
179 179 } else {
180 180 this.startConference();
  181 + this.createAttendence();
181 182 // this.counter += 1;
182 183 this.showJoinSessionButton = false;
183 184 }
... ... @@ -342,6 +343,46 @@ export default {
342 343 this.showLoader = false;
343 344 });
344 345 },
  346 + formatAMPM(date) {
  347 + var hours = date.getHours();
  348 + var minutes = date.getMinutes();
  349 + var ampm = hours >= 12 ? "pm" : "am";
  350 + hours = hours % 12;
  351 + hours = hours ? hours : 12; // the hour '0' should be '12'
  352 + minutes = minutes < 10 ? "0" + minutes : minutes;
  353 + var strTime = hours + ":" + minutes + " " + ampm;
  354 + return strTime;
  355 + },
  356 + createAttendence() {
  357 + let studentId = localStorage.getItem("parentStudentId");
  358 + let todayDate = new Date();
  359 + var attendenceData = {
  360 + classId: this.$route.query.classId,
  361 + studentId: studentId,
  362 + date: new Date().toISOString().substr(0, 10),
  363 + studentAttendance: [
  364 + {
  365 + courseId: this.$route.query.courseId,
  366 + chapterId: this.$route.query.chapterId,
  367 + liveClassId: this.attendenceLiveClassId,
  368 + startTime: this.formatAMPM(new Date()),
  369 + },
  370 + ],
  371 + };
  372 + this.loading = true;
  373 + http()
  374 + .post("/createCourseAttendance", attendenceData)
  375 + .then((response) => {
  376 + this.loading = false;
  377 + // this.snackbar = true;
  378 + // this.color = "green";
  379 + })
  380 + .catch((err) => {
  381 + this.loading = false;
  382 + this.snackbar = true;
  383 + this.color = "error";
  384 + });
  385 + },
345 386 updateLiveClass() {
346 387 this.showLoader = true;
347 388 var payloadData = {
... ... @@ -368,6 +409,7 @@ export default {
368 409 chapterId: this.$route.query.chapterId,
369 410 });
370 411 // console.log("response getLiveClassesesList- ", response);
  412 + this.attendenceLiveClassId = response.data.data[0]._id;
371 413  
372 414 /* CHECK RESPONSE TO ASSIGN MESSAGE INSIDE BUTTON */
373 415 if (response.data.data[0].sessionStatus == "ENDED") {
... ...