fix: quiz submission
This commit is contained in:
@@ -114,7 +114,7 @@
|
||||
{% if show_lesson %}
|
||||
|
||||
{% if is_instructor and not lesson.include_in_preview and not lesson.edit_mode %}
|
||||
<div class="small alert alert-secondary alert-dismissible mb-4">
|
||||
<div class="medium alert alert-info alert-dismissible mb-4">
|
||||
{{ _("This lesson is not available for preview. As you are the Instructor of the course only you can see it.") }}
|
||||
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
||||
</div>
|
||||
@@ -127,13 +127,11 @@
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
{% set course_link = "<a class='join-batch' data-course=" + course.name | urlencode + " href=''>" + _('here') + "</a>" %}
|
||||
<div class="">
|
||||
<div>
|
||||
{{ _("There is no preview available for this lesson.
|
||||
Please join the course to access it.
|
||||
Click {0} to enroll.").format(course_link) }}
|
||||
</div>
|
||||
{% set course_link = "<a class='join-batch' data-course=" + course.name | urlencode + " href=''>" + _('here') + "</a>" %}
|
||||
<div class="alert alert-info medium mb-0">
|
||||
{{ _("There is no preview available for this lesson.
|
||||
Please join the course to access it.
|
||||
Click {0} to enroll.").format(course_link) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -148,6 +146,7 @@
|
||||
|
||||
<!-- Pagination -->
|
||||
{% macro pagination(prev_url, next_url) %}
|
||||
{% if prev_url or next_url %}
|
||||
<div class="lesson-pagination">
|
||||
{% if prev_url %}
|
||||
<div>
|
||||
@@ -165,6 +164,7 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
frappe.ready(() => {
|
||||
|
||||
this.marked_as_complete = false;
|
||||
this.quiz_submitted = false;
|
||||
|
||||
localStorage.removeItem($("#quiz-title").data("name"));
|
||||
|
||||
@@ -76,9 +77,12 @@ frappe.ready(() => {
|
||||
});
|
||||
|
||||
if ($("#quiz-title").data("max-attempts")) {
|
||||
let self = this;
|
||||
window.addEventListener("beforeunload", (e) => {
|
||||
e.returnValue = "";
|
||||
$(".active-question").length && quiz_summary();
|
||||
if ($(".active-question").length && !self.quiz_submitted) {
|
||||
quiz_summary();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -157,6 +161,7 @@ const quiz_summary = (e=undefined) => {
|
||||
e && e.preventDefault();
|
||||
let quiz_name = $("#quiz-title").data("name");
|
||||
let total_questions = $(".question").length;
|
||||
let self = this;
|
||||
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_quiz.lms_quiz.quiz_summary",
|
||||
@@ -169,9 +174,12 @@ const quiz_summary = (e=undefined) => {
|
||||
$(".question").addClass("hide");
|
||||
$("#summary").addClass("hide");
|
||||
$("#quiz-form").parent().prepend(
|
||||
`<div class="text-center summary"><h2> ${message} </h2>
|
||||
<div class="font-weight-bold">${data.message}/${total_questions}</div></div>`);
|
||||
`<div class="text-center summary">
|
||||
<h2> ${message} </h2>
|
||||
<div class="font-weight-bold"> ${data.message}/${total_questions} </div>
|
||||
</div>`);
|
||||
$("#try-again").removeClass("hide");
|
||||
self.quiz_submitted = true;
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -232,7 +240,7 @@ const add_icon = (element, icon) => {
|
||||
let label = $(element).siblings(".option-text").text();
|
||||
$(element).siblings(".option-text").html(`
|
||||
<div>
|
||||
<img class="mr-3" src="/assets/lms/icons/${icon}.svg">
|
||||
<img class="d-inline mr-3" src="/assets/lms/icons/${icon}.svg">
|
||||
${label}
|
||||
</div>
|
||||
`);
|
||||
|
||||
Reference in New Issue
Block a user