fix: banner style and page exit condition

This commit is contained in:
Jannat Patel
2022-05-17 17:29:11 +05:30
parent 1ef70dd4e4
commit cd56fc6179
2 changed files with 7 additions and 16 deletions

View File

@@ -9,21 +9,13 @@
<div class="common-card-style question-card">
<div id="start-banner" class="text-center">
<div class="font-weight-bold mb-2" style="font-size: var(--text-lg);"> {{ quiz.title }} </div>
<div class="mb-2">
{{ _("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 %}
<div class="font-weight-bold mb-3" style="font-size: var(--text-lg);"> {{ quiz.title }} </div>
<div class="mb-3">{{ _("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 %}
</div>
<div class="btn btn-primary btn-start-quiz"> {{ _("Start") }} </div>
<button class="button is-default m-auto btn-start-quiz"> {{ _("Start") }} </bu>
</div>
<form id="quiz-form" class="hide">

View File

@@ -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 = '';
});
}