Merge pull request #281 from pateljannat/rating-field

This commit is contained in:
Jannat Patel
2021-12-27 15:19:43 +05:30
committed by GitHub
3 changed files with 18 additions and 5 deletions

View File

@@ -312,8 +312,15 @@ class LMSCourse(Document):
},
["review", "rating", "owner"],
order_by= "creation desc")
out_of_ratings = frappe.db.get_all("DocField",
{
"parent": "LMS Course Review",
"fieldtype": "Rating"
},
["options"])
out_of_ratings = (len(out_of_ratings) and out_of_ratings[0].options) or 5
for review in reviews:
review.rating = review.rating * out_of_ratings
review.owner_details = frappe.get_doc("User", review.owner)
return reviews

View File

@@ -3,12 +3,21 @@
import frappe
from frappe.model.document import Document
from frappe.utils import cint
class LMSCourseReview(Document):
pass
@frappe.whitelist()
def submit_review(rating, review, course):
out_of_ratings = frappe.db.get_all("DocField",
{
"parent": "LMS Course Review",
"fieldtype": "Rating"
},
["options"])
out_of_ratings = (len(out_of_ratings) and out_of_ratings[0].options) or 5
rating = cint(rating)/out_of_ratings
frappe.get_doc({
"doctype": "LMS Course Review",
"rating": rating,

View File

@@ -192,10 +192,7 @@ var submit_review = (e) => {
callback: (data) => {
if (data.message == "OK") {
$(".review-modal").modal("hide");
frappe.msgprint("Thanks for providing your feedback!");
setTimeout(() => {
window.location.reload();
}, 2000);
window.location.reload();
}
}
})