Files
lms/lms/templates/quiz/quiz.html
2023-10-17 20:06:04 +05:30

172 lines
5.3 KiB
HTML

{% if not hide_quiz %}
<div class="mt-4">
<ul class="alert alert-info pl-8">
<li>
{{ _("This quiz consists of {0} questions.").format(quiz.questions | length) }}
</li>
{% if quiz.passing_percentage %}
<li>
{{ _("You will have to get {0}% correct answers in order to pass the quiz.").format(quiz.passing_percentage) }}
</li>
<li>
{{ _("Without passing the quiz you won't be able to complete the lesson.") }}
</li>
{% endif %}
{% if quiz.max_attempts %}
{% set suffix = "times" if quiz.max_attempts > 1 else "time" %}
<li>
{{ _("You can attempt this quiz only {0} {1}").format(quiz.max_attempts, suffix) }}
</li>
{% endif %}
{% if quiz.time %}
<li class="alert alert-info medium">
{{ _("The quiz has a time limit. For each question you will be given {0} seconds.").format(quiz.time) }}
</li>
{% endif %}
</ul>
<div id="start-banner" class="common-card-style column-card align-items-center">
<div class="text-center my-10">
<div class="bold-heading" id="quiz-title" data-max-attempts="{{ quiz.max_attempts }}"
data-name="{{ quiz.name }}" data-show-answers="{{ quiz.show_answers }}">
{{ quiz.title }}
</div>
{% if not quiz.max_attempts or no_of_attempts < quiz.max_attempts %}
<button class="btn btn-secondary btn-sm btn-start-quiz mt-4">
{{ _("Start") }}
</button>
{% else %}
<div>
{{ _("You have already exceeded the maximum number of attempts allowed for this quiz.") }}
</div>
{% endif %}
</div>
</div>
<form id="quiz-form" class="common-card-style column-card hide">
<div class="questions">
{% for question in quiz.questions %}
{% set instruction = _("Choose all answers that apply") if question.type == "Choices" and question.multiple else _("Choose one answer") if question.type == "Choices" else _("Enter the correct answer") %}
<div class="question hide" data-name="{{ question.name }}" data-type="{{ question.type }}"
data-multi="{{ question.multiple }}" data-qt-index="{{ loop.index }}">
<div>
<div class="pull-right font-weight-bold">
{{ question.marks }} {{ _("Marks") }}
</div>
<div class="question-number">
{{ _("Question ") }}{{ loop.index }}: {{ instruction }}
</div>
<div class="question-text">
{{ question.question }}
</div>
</div>
{% if question.type == "Choices" %}
{% set options = [question.option_1, question.option_2, question.option_3, question.option_4] %}
{% for option in options %}
{% if option %}
<div class="mb-2">
<div class="custom-checkbox">
<label class="option-row">
<input class="option" value="{{ option | urlencode }}"
{% if question.multiple %} type="checkbox" {% else %} type="radio" name="{{ question.question | urlencode }}" {% endif %}>
<div class="option-text">{{ frappe.utils.md_to_html(option) }}</div>
</label>
</div>
{% set explanation = question['explanation_' + loop.index | string] %}
{% if explanation %}
<small class="explanation ml-10 hide">{{ explanation }}</small>
{% endif %}
</div>
{% endif %}
{% endfor %}
{% else %}
<div class="control-input-wrapper">
<div class="control-input">
<textarea type="text" autocomplete="off" class="input-with-feedback form-control bold possibility mt-4" style="height: 150px;" spellcheck="false"></textarea>
</div>
</div>
{% endif %}
</div>
{% endfor %}
</div>
<div class="quiz-footer">
<span>
{{ _("Question") }}
<span class="current-question">1</span>
{{ _("of") }}
{{ quiz.questions | length }}
</span>
{% if quiz.time %}
<div class="progress timer w-75" data-time="{{ quiz.time }}">
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0"
aria-valuemax="100"style="width:100%">
</div>
</div>
{% endif %}
{% if quiz.show_answers %}
<button class="btn btn-secondary btn-sm pull-right" id="check" disabled>
{{ _("Check") }}
</button>
{% endif %}
<button class="btn btn-secondary btn-sm {% if quiz.show_answers %} hide {% endif %}" id="next" disabled>
{{ _("Next Question") }}
</button>
<button class="btn btn-secondary btn-sm hide" id="summary">
{{ _("Submit") }}
</button>
<button class="btn btn-secondary btn-sm mx-auto hide" id="try-again" data-quiz="{{ quiz.name }}">
{{ _("Try Again") }}
</button>
</div>
</form>
</div>
{% endif %}
{% if quiz.show_submission_history and all_submissions | length %}
<article class="mt-8">
<div class="field-label">
{{ _("All Submissions") }}
</div>
<div class="form-grid">
<div class="grid-heading-row">
<div class="grid-row">
<div class="data-row row">
<div class="col grid-static-col col-xs-1">{{ _("No.") }}</div>
<div class="col grid-static-col text-right">{{ _("Score") }}</div>
<div class="col grid-static-col">{{ _("Date") }}</div>
</div>
</div>
</div>
<div>
{% for submission in all_submissions %}
<div class="grid-row">
<div class="data-row row">
<div class="col grid-static-col col-xs-1">{{ loop.index }}</div>
<div class="col grid-static-col text-right">{{ submission.score }}</div>
<div class="col grid-static-col" title="{{ frappe.utils.format_datetime(submission.creation, "medium") }}">
{{ frappe.utils.pretty_date(submission.creation) }}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</article>
{% endif %}