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