yunzi7's picture
using global var
d8529e7
raw
history blame
1.38 kB
{% extends 'base.html' %}
{% block content %}
<h1>ํ€ด์ฆˆ ์ƒ์„ฑ ๊ฒฐ๊ณผ</h1>
{% if quizzes %}
<ul>
{% for quiz in quizzes %}
<li>
<h2>๋ฌธ์ œ ์ฃผ์ธ: {{ quiz[3] }}</h2> <!-- ์ด๋ฆ„ ๋ถ€๋ถ„ -->
<h3>์งˆ๋ฌธ: {{ quiz[0] }}</h3> <!-- ์งˆ๋ฌธ ๋ถ€๋ถ„ -->
<ul>
{% for option in quiz[1] %} <!-- 4์ง€์„ ๋‹ค ๋ณด๊ธฐ -->
<li>{{ option }}</li>
{% endfor %}
</ul>
<button onclick="showAnswer('{{ loop.index0 }}')">์ •๋‹ต ๋ณด๊ธฐ</button>
<p id="answer-{{ loop.index0 }}" style="display: none;">์ •๋‹ต: {{ quiz[2] }}</p> <!-- ์ •๋‹ต -->
</li>
{% endfor %}
</ul>
{% else %}
<p>ํ€ด์ฆˆ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ์‹œ๋„ํ•ด ์ฃผ์„ธ์š”.</p>
{% endif %}
<script>
let currentQuizIndex = 0;
function showAnswer(index) {
const answer = document.getElementById(`answer-${index}`);
if (answer.style.display === "none") {
answer.style.display = "block";
} else {
answer.style.display = "none";
}
currentQuizIndex++;
// ํ€ด์ฆˆ๋ฅผ ๋ชจ๋‘ ํ’€๊ณ  ๋‚˜๋ฉด ๋งˆ๋ฌด๋ฆฌ ํŽ˜์ด์ง€๋กœ ์ด๋™
if (currentQuizIndex === { length }) {
setTimeout(() => {
window.location.href = "{{ url_for('quiz.finish') }}";
}, 3000); // 3์ดˆ ํ›„ ์ž๋™ ์ด๋™
}
}
</script>
{% endblock %}