Merge pull request #397 from pateljannat/misc-fixes
This commit is contained in:
@@ -202,7 +202,8 @@ jinja = {
|
||||
"lms.lms.utils.format_number",
|
||||
"lms.lms.utils.get_lesson_count",
|
||||
"lms.lms.utils.get_all_memberships",
|
||||
"lms.lms.utils.get_filtered_membership"
|
||||
"lms.lms.utils.get_filtered_membership",
|
||||
"lms.lms.utils.show_start_learing_cta"
|
||||
],
|
||||
"filters": []
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2022-09-01 17:11:08.065998",
|
||||
"modified": "2022-10-10 12:38:17.839525",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Batch Membership",
|
||||
@@ -140,5 +140,5 @@
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"title_field": "member"
|
||||
"title_field": "member_name"
|
||||
}
|
||||
@@ -522,6 +522,7 @@ def get_lesson_count(course):
|
||||
def check_profile_restriction():
|
||||
return frappe.db.get_single_value("LMS Settings", "force_profile_completion")
|
||||
|
||||
|
||||
def get_restriction_details():
|
||||
user = frappe.db.get_value("User", frappe.session.user, ["profile_complete", "username"], as_dict=True)
|
||||
return {
|
||||
@@ -540,3 +541,8 @@ def get_all_memberships(member):
|
||||
def get_filtered_membership(course, memberships):
|
||||
current_membership = list(filter(lambda x: x.course == course, memberships))
|
||||
return current_membership[0] if len(current_membership) else None
|
||||
|
||||
|
||||
def show_start_learing_cta(course, membership):
|
||||
return not course.disable_self_learning and not membership and not course.upcoming \
|
||||
and not check_profile_restriction() and not is_instructor(course.name) and course.status == "Approved"
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
{% if not course.upcoming %}
|
||||
<div class="reviews-parent">
|
||||
{% set reviews = get_reviews(course.name) %}
|
||||
<div class="mb-5">
|
||||
<span class="course-home-headings"> {{ _("Reviews") }} </span>
|
||||
{% if is_eligible_to_review(course.name, membership) %}
|
||||
<span class="btn btn-secondary btn-sm review-link">
|
||||
{{ _("Write a review") }}
|
||||
</span>
|
||||
{% elif not is_instructor(course.name) and frappe.session.user == "Guest" %}
|
||||
<a class="btn btn-secondary btn-sm pull-right" href="/login?redirect-to=/courses/{{ course.name }}"> {{ _("Login") }} </a>
|
||||
{% elif not is_instructor(course.name) and not membership and course.status == "Approved" %}
|
||||
<div class="btn btn-secondary btn-sm join-batch pull-right" data-course="{{ course.name | urlencode }}"> {{ _("Start Learning") }} </div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="course-home-headings mb-5"> {{ _("Reviews") }} </div>
|
||||
|
||||
|
||||
{% set avg_rating = get_average_rating(course.name) %}
|
||||
@@ -22,7 +11,9 @@
|
||||
<div class="avg-rating">
|
||||
{{ frappe.utils.flt(avg_rating, frappe.get_system_settings("float_precision") or 3) }}
|
||||
</div>
|
||||
|
||||
<div class="course-meta"> {{ reviews | length }} {{ _("ratings") }} </div>
|
||||
|
||||
<div class="avg-rating-stars">
|
||||
<div class="rating">
|
||||
{% for i in [1, 2, 3, 4, 5] %}
|
||||
@@ -32,9 +23,24 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="course-meta">
|
||||
{{ frappe.utils.flt(avg_rating, frappe.get_system_settings("float_precision") or 3) }} {{ _("out of 5 ") }}
|
||||
</div>
|
||||
|
||||
{% if is_eligible_to_review(course.name, membership) %}
|
||||
<span class="btn btn-secondary btn-sm review-link mt-5">
|
||||
{{ _("Write a review") }}
|
||||
</span>
|
||||
{% elif not is_instructor(course.name) and frappe.session.user == "Guest" %}
|
||||
<a class="btn btn-secondary btn-sm mt-5" href="/login?redirect-to=/courses/{{ course.name }}">
|
||||
{{ _("Write a review") }}
|
||||
</a>
|
||||
{% elif show_start_learing_cta(course, membership) %}
|
||||
<div class="btn btn-secondary btn-sm join-batch mt-5" data-course="{{ course.name | urlencode }}">
|
||||
{{ _("Start Learning") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -1678,10 +1678,6 @@ li {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.review-link {
|
||||
float: right
|
||||
}
|
||||
|
||||
.role {
|
||||
margin-bottom: 0;
|
||||
cursor: pointer;
|
||||
|
||||
@@ -62,7 +62,7 @@ const join_course = (e) => {
|
||||
if (data.message == "OK") {
|
||||
$(".no-preview-modal").modal("hide");
|
||||
frappe.show_alert({
|
||||
message: __("You are now a student of this course."),
|
||||
message: __("Enrolled successfully"),
|
||||
indicator:'green'
|
||||
}, 3);
|
||||
setTimeout(function () {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% set portal_course_creation = frappe.db.get_single_value("LMS Settings", "portal_course_creation") %}
|
||||
|
||||
<div class="course-search-header">
|
||||
<input class="search" id="search-course" placeholder="{{ _(search_placeholder) }}">
|
||||
<input class="search" id="search-course" placeholder="{{ _(search_placeholder) or 'Search' }}">
|
||||
{% if portal_course_creation == "Anyone" or has_course_instructor_role() %}
|
||||
<a class="btn btn-secondary btn-md ml-2" href="/courses/new-course"> {{ _("Create a Course") }} </a>
|
||||
{% endif %}
|
||||
|
||||
@@ -292,10 +292,9 @@
|
||||
{% set lesson_index = get_lesson_index(membership.current_lesson) if membership and
|
||||
membership.current_lesson else "1.1" if first_lesson_exists(course.name) else None %}
|
||||
|
||||
{% if show_start_learing_cta %}
|
||||
{% if show_start_learing_cta(course, membership) %}
|
||||
<div class="btn btn-primary wide-button join-batch mb-2" data-course="{{ course.name | urlencode }}">
|
||||
{{ _("Start Learning") }}
|
||||
<img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
|
||||
</div>
|
||||
|
||||
{% elif is_instructor(course.name) and not course.published and course.status != "Under Review" %}
|
||||
@@ -305,13 +304,13 @@
|
||||
|
||||
{% elif is_instructor(course.name) and lesson_index %}
|
||||
<a class="btn btn-primary wide-button" id="continue-learning"
|
||||
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
|
||||
{{ _("Checkout Course") }} <img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
|
||||
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
|
||||
{{ _("Checkout Course") }}
|
||||
</a>
|
||||
|
||||
{% elif course.upcoming and not is_user_interested and not is_instructor %}
|
||||
<div class="btn btn-secondary wide-button notify-me" data-course="{{course.name | urlencode}}">
|
||||
{{ _("Notify me when available") }}
|
||||
{{ _("Notify me when available") }}
|
||||
</div>
|
||||
|
||||
{% elif is_cohort_staff(course.name, frappe.session.user) %}
|
||||
@@ -321,29 +320,29 @@
|
||||
|
||||
{% elif membership %}
|
||||
<a class="btn btn-primary wide-button" id="continue-learning"
|
||||
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
|
||||
{{ _("Continue Learning") }} <img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
|
||||
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
|
||||
{{ _("Continue Learning") }}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% set progress = frappe.utils.cint(membership.progress) %}
|
||||
|
||||
{% if membership and course.enable_certification %}
|
||||
{% if certificate %}
|
||||
<a class="btn btn-secondary wide-button mt-3" href="/courses/{{ course.name }}/{{ certificate }}">
|
||||
{{ _("Get Certificate") }}
|
||||
</a>
|
||||
{% if certificate %}
|
||||
<a class="btn btn-secondary wide-button mt-3" href="/courses/{{ course.name }}/{{ certificate }}">
|
||||
{{ _("Get Certificate") }}
|
||||
</a>
|
||||
|
||||
{% elif eligible_for_evaluation %}
|
||||
<a class="btn btn-secondary wide-button mt-3" id="apply-certificate" data-course="{{ course.name }}">
|
||||
{{ _("Apply for Certificate") }}
|
||||
</a>
|
||||
{% elif eligible_for_evaluation %}
|
||||
<a class="btn btn-secondary wide-button mt-3" id="apply-certificate" data-course="{{ course.name }}">
|
||||
{{ _("Apply for Certificate") }}
|
||||
</a>
|
||||
|
||||
{% elif course.grant_certificate_after == "Completion" and progress == 100 %}
|
||||
<div class="btn btn-secondary wide-button is-secondary mt-3" id="certification" data-course="{{ course.name }}">
|
||||
{{ _("Get Certificate") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% elif course.grant_certificate_after == "Completion" and progress == 100 %}
|
||||
<div class="btn btn-secondary wide-button is-secondary mt-3" id="certification" data-course="{{ course.name }}">
|
||||
{{ _("Get Certificate") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if is_instructor(course.name) or has_course_moderator_role() %}
|
||||
|
||||
@@ -146,10 +146,10 @@ const highlight_rating = (e) => {
|
||||
};
|
||||
|
||||
|
||||
var submit_review = (e) => {
|
||||
const submit_review = (e) => {
|
||||
e.preventDefault();
|
||||
var rating = $(".rating-field").children(".star-click").length;
|
||||
var review = $(".review-field").val();
|
||||
let rating = $(".rating-field").children(".star-click").length;
|
||||
let review = $(".review-field").val();
|
||||
if (!rating) {
|
||||
$(".error-field").text("Please provide a rating.");
|
||||
return;
|
||||
@@ -164,7 +164,13 @@ var submit_review = (e) => {
|
||||
callback: (data) => {
|
||||
if (data.message == "OK") {
|
||||
$(".review-modal").modal("hide");
|
||||
window.location.reload();
|
||||
frappe.show_alert({
|
||||
message: __("Review submitted."),
|
||||
indicator:'green'
|
||||
}, 3);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import frappe
|
||||
from lms.lms.utils import check_profile_restriction, get_membership, get_restriction_details, has_course_moderator_role, is_instructor, is_certified, get_evaluation_details, redirect_to_courses_list
|
||||
from lms.lms.utils import get_membership, has_course_moderator_role, is_instructor, is_certified, get_evaluation_details, redirect_to_courses_list
|
||||
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
@@ -50,12 +51,6 @@ def set_course_context(context, course_name):
|
||||
context.eligible_for_evaluation = eval_details.eligible
|
||||
context.certificate_request = eval_details.request
|
||||
context.no_of_attempts = eval_details.no_of_attempts
|
||||
context.restriction = check_profile_restriction()
|
||||
|
||||
if context.restriction:
|
||||
context.restriction_details = get_restriction_details()
|
||||
|
||||
context.show_start_learing_cta = show_start_learing_cta(course, membership, context.restriction)
|
||||
if context.course.upcoming:
|
||||
context.is_user_interested = get_user_interest(context.course.name)
|
||||
|
||||
@@ -73,7 +68,3 @@ def get_user_interest(course):
|
||||
"user": frappe.session.user
|
||||
})
|
||||
|
||||
|
||||
def show_start_learing_cta(course, membership, restriction):
|
||||
return not course.disable_self_learning and not membership and not course.upcoming \
|
||||
and not restriction and not is_instructor(course.name) and course.status == "Approved"
|
||||
|
||||
Reference in New Issue
Block a user