Mark elements that should remain visible in quiz mode at build time via data-quiz-shown attributes (toolbar, breadcrumb, h1, questions, solution links, next-section/-chapter links). The runtime tail detection becomes obsolete and the CSS collapses to a single show/hide rule. Switch the body markers to data-quiz-mode / data-quiz-has-questions attributes, swap the toggle between btn-secondary and btn-primary instead of hardcoded colors, and use Bootstrap's alert alert-info for the no-questions notice.
37 lines
1.8 KiB
HTML
37 lines
1.8 KiB
HTML
<div class="question layout-{{ layout }}" id="{{ number }}" data-quiz-shown>
|
|
<div class="question-text">
|
|
{{ number }}: {{ question }}
|
|
</div>
|
|
{% if picture_question %}
|
|
<div class="question-picture"><img src="pictures/{{ picture_question }}.svg" alt="{{ alt_text_question }}"></div>
|
|
{% endif %}
|
|
<div class="answers">
|
|
{% for i in range(4) %}
|
|
<button onclick="answer(this, {{ 'true' if i == 0 else 'false' }} );">
|
|
{% if answers[i] %}
|
|
{{ answers[i] }}
|
|
{% endif %}
|
|
{% if answer_pictures[i] %}
|
|
<div class="question-picture"><img src="pictures/{{ answer_pictures[i] }}.svg" alt="{{ alt_text_answers[i] }}"></div>
|
|
{% endif %}
|
|
{% if i == 0 %}
|
|
<div class="result material-icons">check</div>
|
|
{% else %}
|
|
<div class="result material-icons">clear</div>
|
|
{% endif %}
|
|
</button>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
<div class="solution" data-quiz-shown>
|
|
{% if has_solution %}
|
|
<a class="btn btn-warning btn-sm d-inline-flex align-items-center" href="{{ number }}.html" aria-label="Lösungshinweis zu Frage {{ number }}" title="Lösungshinweis">
|
|
<svg class="solution-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" fill="currentColor" aria-hidden="true" focusable="false">
|
|
<path d="M420.9 448C428.2 425.7 442.8 405.5 459.3 388.1C492 353.7 512 307.2 512 256C512 150 426 64 320 64C214 64 128 150 128 256C128 307.2 148 353.7 180.7 388.1C197.2 405.5 211.9 425.7 219.1 448L420.8 448zM416 496L224 496L224 512C224 556.2 259.8 592 304 592L336 592C380.2 592 416 556.2 416 512L416 496zM312 176C272.2 176 240 208.2 240 248C240 261.3 229.3 272 216 272C202.7 272 192 261.3 192 248C192 181.7 245.7 128 312 128C325.3 128 336 138.7 336 152C336 165.3 325.3 176 312 176z"/>
|
|
</svg>
|
|
<span>Lösungsweg anzeigen</span>
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
|
|
|