fix: hide start learning when no lesson in course

This commit is contained in:
Jannat Patel
2022-12-12 11:17:51 +05:30
parent 424d35bf42
commit 028c0725c3
2 changed files with 25 additions and 11 deletions

View File

@@ -618,9 +618,24 @@ def show_start_learing_cta(course, membership):
and not check_profile_restriction()
and not is_instructor(course.name)
and course.status == "Approved"
and has_lessons(course)
)
def has_lessons(course):
lesson_exists = False
chapter_exists = frappe.db.get_value("Chapter Reference", {
"parent": course.name
}, ["name", "chapter"], as_dict=True)
if chapter_exists:
lesson_exists = frappe.db.exists("Lesson Reference", {
"parent": chapter_exists.chapter
})
return lesson_exists
@frappe.whitelist(allow_guest=True)
def get_chart_data(chart_name, timespan, timegrain, from_date, to_date):
chart = frappe.get_doc("Dashboard Chart", chart_name)

View File

@@ -1,5 +1,6 @@
{% if frappe.session.user != "Guest" %}
{% set membership = frappe.db.get_value("LMS Batch Membership", {"member": frappe.session.user},
{% set membership = frappe.db.get_value("LMS Batch Membership",
{"member": frappe.session.user, "course": course.name},
["name", "course", "batch", "current_lesson", "member_type", "progress"], as_dict=1) %}
{% set progress = frappe.utils.cint(membership.progress) %}
{% else %}
@@ -113,19 +114,17 @@
{% if read_only %}
<a class="stretched-link" href="/courses/{{ course.name }}"></a>
{% else %}
{% set lesson_index = get_lesson_index(membership.current_lesson) if membership and
membership.current_lesson else '1.1' %}
{% set query_parameter = "?batch=" + membership.batch if membership and
membership.batch else "" %}
{% else %}
{% if progress != 100 and membership and not course.upcoming %}
<a class="stretched-link" href="{{ get_lesson_url(course.name, lesson_index) }}{{ query_parameter }}"></a>
{% else %}
<a class="stretched-link" href="/courses/{{ course.name }}"></a>
{% set lesson_index = get_lesson_index(membership.current_lesson or "1.1") %}
{% set query_parameter = "?batch=" + membership.batch if membership.batch else "" %}
<a class="stretched-link" href="{{ get_lesson_url(course.name, lesson_index) }}{{ query_parameter }}"></a>
{% else %}
<a class="stretched-link" href="/courses/{{ course.name }}"></a>
{% endif %}
{% endif %}
</div>