diff --git a/ham-test-www.py b/ham-test-www.py index af46d4f..0cefecc 100644 --- a/ham-test-www.py +++ b/ham-test-www.py @@ -80,6 +80,7 @@ def generate_html(questions): .question-box {{ background: #fff; padding: 1rem; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); margin-bottom: 2rem; }} .answers label {{ display: block; margin: 0.5rem 0; }} .nav-buttons {{ margin-top: 1rem; }} + .nav-buttons button {{ margin-right: 0.5rem; }} .correct {{ color: green; }} .incorrect {{ color: red; }} #result {{ font-weight: bold; }} @@ -113,6 +114,7 @@ def generate_html(questions): document.getElementById("quiz").innerHTML = `

Finished!

Score: ${{score}} / ${{shuffled.length}} (${{((score / shuffled.length) * 100).toFixed(2)}}%)

`; return; }} + const q = shuffled[current]; const options = q.answers.map((a, i) => {{ return ``; @@ -124,6 +126,7 @@ def generate_html(questions):

${{q.question}}

${{options}}
`; @@ -156,6 +159,15 @@ def generate_html(questions): showQuestion(); }}, isCorrect ? 1000 : 2500); }} + + function quitTest() {{ + const answered = current; + const percent = answered > 0 ? ((score / answered) * 100).toFixed(0) : 0; + document.getElementById("quiz").innerHTML = ` +

Test Score

+

You answered ${{score}} questions correctly out of ${{answered}} questions answered. (${{percent}}%)

+ `; + }}