Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c64d46e99 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -5,3 +5,6 @@
|
||||
tags
|
||||
community/docs/current
|
||||
community/public/dist
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
@@ -165,7 +165,8 @@ whitelist = [
|
||||
"/add-a-new-batch",
|
||||
"/new-sign-up",
|
||||
"/message",
|
||||
"/about"
|
||||
"/about",
|
||||
"/lms-course-review"
|
||||
]
|
||||
whitelist_rules = [{"from_route": p, "to_route": p[1:]} for p in whitelist]
|
||||
|
||||
|
||||
@@ -199,7 +199,12 @@ class LMSCourse(Document):
|
||||
}
|
||||
if batch:
|
||||
filters["batch"] = batch
|
||||
membership = frappe.db.get_value("LMS Batch Membership", filters, ["name","batch", "current_lesson"], as_dict=True)
|
||||
|
||||
membership = frappe.db.get_value("LMS Batch Membership",
|
||||
filters,
|
||||
["name", "batch", "current_lesson", "member_type"],
|
||||
as_dict=True)
|
||||
|
||||
if membership and membership.batch:
|
||||
membership.batch_title = frappe.db.get_value("LMS Batch", membership.batch, "title")
|
||||
return membership
|
||||
@@ -241,6 +246,32 @@ class LMSCourse(Document):
|
||||
member_names = [m['member'] for m in memberships]
|
||||
return find_all("User", name=["IN", member_names])
|
||||
|
||||
def get_reviews(self):
|
||||
reviews = frappe.get_all("LMS Course Review",
|
||||
{
|
||||
"course": self.name
|
||||
},
|
||||
["review", "rating", "owner"],
|
||||
order_by= "creation desc")
|
||||
|
||||
for review in reviews:
|
||||
review.owner_details = frappe.get_doc("User", review.owner)
|
||||
|
||||
return reviews
|
||||
|
||||
def is_eligibleto_review(self, membership):
|
||||
""" Checks if user is eligible to review the course """
|
||||
if not membership:
|
||||
return False
|
||||
if frappe.db.count("LMS Course Review",
|
||||
{
|
||||
"course": self.name,
|
||||
"owner": frappe.session.user
|
||||
}):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def get_outline(self):
|
||||
return CourseOutline(self)
|
||||
|
||||
|
||||
0
community/lms/doctype/lms_course_review/__init__.py
Normal file
0
community/lms/doctype/lms_course_review/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2021, FOSS United and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('LMS Course Review', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"actions": [],
|
||||
"creation": "2021-06-28 13:36:36.146718",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"review",
|
||||
"rating",
|
||||
"course"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "review",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Review"
|
||||
},
|
||||
{
|
||||
"fieldname": "rating",
|
||||
"fieldtype": "Rating",
|
||||
"label": "Rating"
|
||||
},
|
||||
{
|
||||
"fieldname": "course",
|
||||
"fieldtype": "Link",
|
||||
"label": "Course",
|
||||
"options": "LMS Course"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-06-28 15:00:35.146196",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Course Review",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) 2021, FOSS United and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class LMSCourseReview(Document):
|
||||
pass
|
||||
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) 2021, FOSS United and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestLMSCourseReview(unittest.TestCase):
|
||||
pass
|
||||
61
community/lms/widgets/Reviews.html
Normal file
61
community/lms/widgets/Reviews.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<div>
|
||||
<div class="reviews-heading">
|
||||
<div class="reviews-title">Review</div>
|
||||
{% if course.is_eligibleto_review(membership) %}
|
||||
<a href="/lms-course-review?new=1">
|
||||
Provide your Feedback
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
{% for review in course.get_reviews() %}
|
||||
<div class="review-card">
|
||||
<div class="review-content"> {{ review.review }} </div>
|
||||
<div class="review-card-footer">
|
||||
<div>
|
||||
{{ widgets.Avatar(member=review.owner_details, avatar_class="avatar-medium") }} <a
|
||||
href="/{{review.owner_details.username}}">{{ review.owner_details.full_name }}</a>
|
||||
</div>
|
||||
<div class="rating">
|
||||
{% for i in [1, 2, 3, 4, 5] %}
|
||||
<svg class="icon icon-md {% if i <= review.rating %} star-click {% endif %}" data-rating="{{ i }}">
|
||||
<use href="#icon-star"></use>
|
||||
</svg>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="review-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Modal title</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<iframe src="/lms-course-review?new=1"></iframe>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
frappe.ready(() => {
|
||||
frappe.provide('frappe.ui');
|
||||
console.log(frappe.ui)
|
||||
})
|
||||
|
||||
</script>
|
||||
37
community/templates/pages/reviews.js
Normal file
37
community/templates/pages/reviews.js
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
frappe.ready(() => {
|
||||
$("#provide-feedback").click((e) => {
|
||||
e.preventDefault();
|
||||
let d = new frappe.ui.Dialog({
|
||||
title: 'Provide your Feedback',
|
||||
fields: [
|
||||
{
|
||||
label: 'Rating',
|
||||
fieldname: 'rating',
|
||||
fieldtype: 'Rating'
|
||||
},
|
||||
{
|
||||
label: 'Review',
|
||||
fieldname: 'review',
|
||||
fieldtype: 'Small Text'
|
||||
}
|
||||
],
|
||||
primary_action_label: 'Submit',
|
||||
primary_action(values) {
|
||||
console.log(values);
|
||||
frappe.call({
|
||||
method: "community.lms.doctype.lms_course.lms_course",
|
||||
args: {
|
||||
course: "{{ course.name }}",
|
||||
rating: values.rating,
|
||||
review: values.review
|
||||
},
|
||||
callback: (data) => {
|
||||
d.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
})
|
||||
})
|
||||
0
community/www/__init__.py
Normal file
0
community/www/__init__.py
Normal file
0
community/www/courses/__init__.py
Normal file
0
community/www/courses/__init__.py
Normal file
@@ -15,7 +15,7 @@
|
||||
</div>
|
||||
<div class="d-flex justify-content-between align-items-end">
|
||||
<h2 id="course-title" data-course="{{course.name}}">{{course.title}}</h2>
|
||||
{% if not course.disable_self_learning and not course.is_mentor(frappe.session.user) %}
|
||||
{% if not course.disable_self_learning and not membership %}
|
||||
<div>
|
||||
<button class="btn btn-primary join-batch" data-course="{{ course.name | urlencode }}"> Start Learning </button>
|
||||
</div>
|
||||
@@ -32,6 +32,7 @@
|
||||
{{ widgets.InstructorSection(instructor=course.get_instructor()) }}
|
||||
{{ BatchSection(course) }}
|
||||
{{ widgets.CourseOutline(course=course, show_link=membership) }}
|
||||
{{ widgets.Reviews(course=course, membership=membership) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,5 +20,5 @@ def get_context(context):
|
||||
context.course.query_parameter = "?batch=" + membership.batch if membership and membership.batch else ""
|
||||
context.membership = membership
|
||||
if not course.is_mentor(frappe.session.user) and membership:
|
||||
frappe.local.flags.redirect_location = f"/courses/{course.name}/learn"
|
||||
raise frappe.Redirect
|
||||
""" frappe.local.flags.redirect_location = f"/courses/{course.name}/learn"
|
||||
raise frappe.Redirect """
|
||||
|
||||
0
community/www/dashboard/__init__.py
Normal file
0
community/www/dashboard/__init__.py
Normal file
0
community/www/hackathons/__init__.py
Normal file
0
community/www/hackathons/__init__.py
Normal file
0
community/www/hackathons/macros/__init__.py
Normal file
0
community/www/hackathons/macros/__init__.py
Normal file
0
community/www/home/__init__.py
Normal file
0
community/www/home/__init__.py
Normal file
0
community/www/macros/__init__.py
Normal file
0
community/www/macros/__init__.py
Normal file
0
community/www/my-courses/__init__.py
Normal file
0
community/www/my-courses/__init__.py
Normal file
0
community/www/profiles/__init__.py
Normal file
0
community/www/profiles/__init__.py
Normal file
0
community/www/sketches/__init__.py
Normal file
0
community/www/sketches/__init__.py
Normal file
Reference in New Issue
Block a user