diff --git a/lms/public/css/style.css b/lms/public/css/style.css index 7e10ceb0..b4d7b719 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -628,16 +628,6 @@ input[type=checkbox] { margin-bottom: 1rem; } -.lesson-progress { - background: #BFDDF7; - padding: 4px 8px 4px; - font-size: 10px; - line-height: 120%; - margin-left: 1rem; - border-radius: var(--border-radius-md); - font-weight: bold; -} - .profile-page { padding-top: 0; } diff --git a/lms/www/batch/learn.html b/lms/www/batch/learn.html index 67cd8b63..f5805fea 100644 --- a/lms/www/batch/learn.html +++ b/lms/www/batch/learn.html @@ -70,11 +70,14 @@ data-index="{{ lesson_index }}" data-course="{{ course.name }}" data-chapter="{{ chapter }}" {% if lesson.name %} data-lesson="{{ lesson.name }}" {% endif %} >{% if lesson.title %}{{ lesson.title }}{% endif %} - {{ _("COMPLETED") }} + + {% if get_progress(course.name, lesson.name) == 'Complete' %} + {{ _("COMPLETED") }} + {% endif %} {% if (is_instructor or has_course_moderator_role()) and not lesson.edit_mode %} - + {% endif %} @@ -145,42 +148,23 @@ {% macro pagination(prev_url, next_url) %} -
-
+
{% if prev_url %} - - {% endif %} -
- - {% set progress = get_progress(course.name, lesson.name) %} - - {% if not is_mentor(course.name, frappe.session.user) and membership %} -
- -
- {% endif %} - -
- {% if not is_mentor(course.name, frappe.session.user) and membership %} - - -
{% endmacro %} @@ -261,52 +245,6 @@ -
{% endmacro %} diff --git a/lms/www/batch/learn.js b/lms/www/batch/learn.js index 435ff01c..c72ef4d8 100644 --- a/lms/www/batch/learn.js +++ b/lms/www/batch/learn.js @@ -1,5 +1,7 @@ frappe.ready(() => { + this.marked_as_complete = false; + localStorage.removeItem($("#quiz-title").data("name")); fetch_assignments(); @@ -7,15 +9,15 @@ frappe.ready(() => { save_current_lesson(); $(".option").click((e) => { - enable_check(e); - }) - - $(".mark-progress").click((e) => { - mark_progress(e); + enable_check(e); }); - $(".next").click((e) => { - mark_progress(e); + $(window).scroll(() => { + let self = this; + if (!$("#status-indicator").length && !self.marked_as_complete && $(".title").hasClass("is-member")) { + self.marked_as_complete = true; + mark_progress(); + } }); $("#summary").click((e) => { @@ -112,6 +114,7 @@ const mark_active_question = (e = undefined) => { let current_index = $(".active-question").attr("data-qt-index") || 0; let next_index = parseInt(current_index) + 1; + $(".question").addClass("hide").removeClass("active-question"); $(`.question[data-qt-index='${next_index}']`).removeClass("hide").addClass("active-question"); $(".current-question").text(`${next_index}`); @@ -122,82 +125,34 @@ const mark_active_question = (e = undefined) => { }; -const mark_progress = (e) => { - /* Prevent default only for Next button anchor tag and not for progress checkbox */ - if ($(e.currentTarget).prop("nodeName") != "INPUT") - e.preventDefault(); - else - return; - - const target = $(e.currentTarget).attr("data-progress") ? $(e.currentTarget) : $("input.mark-progress"); - const current_status = $(".lesson-progress").hasClass("hide") ? "Incomplete": "Complete"; - - let status = "Incomplete"; - if (target.prop("nodeName") == "INPUT" && target.prop("checked")) { - status = "Complete"; - } - - if (status != current_status) { - frappe.call({ - method: "lms.lms.doctype.course_lesson.course_lesson.save_progress", - args: { - lesson: $(".title").attr("data-lesson"), - course: $(".title").attr("data-course"), - status: status - }, - callback: (data) => { - change_progress_indicators(status, e); - show_certificate_if_course_completed(data); - move_to_next_lesson(status, e); - } - }); - } - else - move_to_next_lesson(status, e); +const mark_progress = () => { + let status = "Complete" + frappe.call({ + method: "lms.lms.doctype.course_lesson.course_lesson.save_progress", + args: { + lesson: $(".title").attr("data-lesson"), + course: $(".title").attr("data-course"), + status: status + }, + callback: (data) => { + change_progress_indicators(); + show_certificate_if_course_completed(data); + } + }); }; -const change_progress_indicators = (status, e) => { - if (status == "Complete") { - $(".lesson-progress").removeClass("hide"); - $(".active-lesson .lesson-progress-tick").removeClass("hide"); - } - else { - $(".lesson-progress").addClass("hide"); - $(".active-lesson .lesson-progress-tick").addClass("hide"); - } - if (status == "Incomplete" && !$(e.currentTarget).hasClass("next")) { - $(e.currentTarget).addClass("hide"); - $("input.mark-progress").prop("checked", false).closest(".custom-checkbox").removeClass("hide"); - } +const change_progress_indicators = () => { + $(".active-lesson .lesson-progress-tick").removeClass("hide"); }; const show_certificate_if_course_completed = (data) => { - if (data.message == 100 && !$(".next").attr("data-next") && $("#certification").hasClass("hide")) { + if (data.message == 100 && !$(".next").length && $("#certification").hasClass("hide")) { $("#certification").removeClass("hide"); - $(".next").addClass("hide"); } }; - -const move_to_next_lesson = (status, e) => { - if ($(e.currentTarget).hasClass("next") && $(e.currentTarget).attr("data-href")) { - window.location.href = $(e.currentTarget).attr("data-href"); - } - else if (status == "Complete") { - $("input.mark-progress").closest(".custom-checkbox").addClass("hide"); - $("div.mark-progress").removeClass("hide"); - $(".next").addClass("hide"); - } - else { - $("input.mark-progress").closest(".custom-checkbox").removeClass("hide"); - $("div.mark-progress").addClass("hide"); - $(".next").removeClass("hide"); - } -}; - - const quiz_summary = (e=undefined) => { e && e.preventDefault(); let quiz_name = $("#quiz-title").data("name");