From e78c5c8cef959e958b691f704e099700714ff422 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Mon, 27 Apr 2020 02:02:54 -0400 Subject: [PATCH] [+] Implement submitRating --- .../course-head/course-head.vue | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/pages/overall/overall-course/course-head/course-head.vue b/src/pages/overall/overall-course/course-head/course-head.vue index 7608367..d629563 100644 --- a/src/pages/overall/overall-course/course-head/course-head.vue +++ b/src/pages/overall/overall-course/course-head/course-head.vue @@ -70,7 +70,7 @@ Cancel - Submit + Submit @@ -102,6 +102,7 @@ ratingData = [0,0,0,0,0]; ratingComment = ''; ratingAnonymous = false; + ratingPosting = false; /** * Redirect to the course page @@ -131,6 +132,34 @@ this.ratingData[index] = star + 1; this.$forceUpdate(); } + + /** + * Submit a rating + */ + submitRating() + { + this.ratingPosting = true; + + App.http.post('/course-info/rating/set', {rating: { + id_ci: this.course.id_ci, + anonymous: this.ratingAnonymous, + ratings: this.ratingData, + comment: this.ratingComment} + }).then(response => + { + if (response.success) + { + this.course.rated = true; + this.ratingDialog = false; + this.$message.success('Rating successfully posted, thank you!'); + } + else + { + this.$message.error('Sorry, but rating failed to post, please try again or email me if you continues to have issues. ' + + 'But wait! The email system isn\'t created yet... oops!. (Technical error message: ' + response.data + ')'); + } + }); + } }