From cd56fc6179a3dd04d83863a4994676e82db09e15 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 17 May 2022 17:29:11 +0530 Subject: [PATCH] fix: banner style and page exit condition --- lms/templates/quiz.html | 18 +++++------------- lms/www/batch/learn.js | 5 ++--- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/lms/templates/quiz.html b/lms/templates/quiz.html index 093bceda..47dc65ef 100644 --- a/lms/templates/quiz.html +++ b/lms/templates/quiz.html @@ -9,21 +9,13 @@
-
{{ quiz.title }}
-
- {{ _("There are {0} questions in this quiz.").format(quiz.questions | length) }} - - {% if quiz.max_attempts %} - {% set suffix = "times" if quiz.max_attempts > 1 else "time" %} - {{ _("This quiz can only be taken {0} {1}. If you attempt the quiz and leave the page before submitting, the quiz will be automatically submitted.").format(quiz.max_attempts, suffix) }} - {% endif %} - - {% if quiz.time %} - {{ _("The quiz has a time limit. Each question will be given {0} seconds.").format(quiz.time) }} - {% endif %} +
{{ quiz.title }}
+
{{ _("There are {0} questions in this quiz.").format(quiz.questions | length) }}{% if quiz.max_attempts %} + {% set suffix = "times" if quiz.max_attempts > 1 else "time" %} {{ _("This quiz can only be taken {0} {1}. If you attempt the quiz and leave the page before submitting, the quiz will be automatically submitted.").format(quiz.max_attempts, suffix) }}{% endif %} + {% if quiz.time %}{{ _("The quiz has a time limit. Each question will be given {0} seconds.").format(quiz.time) }}{% endif %}
-
{{ _("Start") }}
+
diff --git a/lms/www/batch/learn.js b/lms/www/batch/learn.js index 21089e50..387e9319 100644 --- a/lms/www/batch/learn.js +++ b/lms/www/batch/learn.js @@ -51,11 +51,10 @@ frappe.ready(() => { mark_active_question(); }); - if ($("#quiz-form").length) { + if ($("#quiz-title").data("max-attempts") && $(".active-question").length) { window.addEventListener("beforeunload", (e) => { e.preventDefault(); - if ($("#quiz-title").data("max-attempts") && $(".active-question").length) - quiz_summary(); + quiz_summary(); e.returnValue = ''; }); }