1
0

vault backup: 2025-12-21 20:21:58
All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m30s

This commit is contained in:
2025-12-21 20:21:58 +01:00
parent ec61b89af6
commit 2ec904d899
132 changed files with 1283 additions and 233 deletions

21
quiz/templates/base.html Normal file
View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quiz</title>
<script src="https://unpkg.com/htmx.org@1.9.10"></script>
<style>
body { font-family: system-ui, -apple-system, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }
.question { background: #f5f5f5; padding: 20px; border-radius: 8px; margin: 20px 0; }
.option { padding: 10px; margin: 5px 0; cursor: pointer; border: 2px solid #ddd; border-radius: 4px; }
.option:hover { background: #e9e9e9; }
.progress { background: #ddd; height: 20px; border-radius: 10px; margin: 20px 0; }
.progress-bar { background: #4CAF50; height: 100%; border-radius: 10px; transition: width 0.3s; }
</style>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>

10
quiz/templates/index.html Normal file
View File

@@ -0,0 +1,10 @@
{% extends "base.html" %}
{% block content %}
<h1>Quiz Application</h1>
<div class="progress">
<div class="progress-bar" style="width: {% if total_questions > 0 %}{{ answered_count|floatformat:0 }}{% else %}0{% endif %}%"></div>
</div>
<p>Besvarade frågor: {{ answered_count }} / {{ total_questions }}</p>
<div id="quiz-container" hx-get="{% url 'next_question' %}" hx-trigger="load"></div>
{% endblock %}

View File

@@ -0,0 +1,6 @@
<div class="question">
<h2>Quiz Completed!</h2>
<p>Du har besvarat alla frågor.</p>
<a href="{% url 'stats' %}">Se dina resultat</a>
</div>

View File

@@ -0,0 +1,14 @@
<div class="question">
<h2>{{ question.text }}</h2>
<form hx-post="{% url 'submit_answer' %}" hx-target="#quiz-container">
{% csrf_token %}
<input type="hidden" name="question_id" value="{{ question.id }}">
{% for option in question.options.all %}
<div class="option" onclick="this.querySelector('input').checked = true; this.closest('form').requestSubmit();">
<input type="radio" name="answer" value="{{ option.letter }}" id="opt_{{ option.letter }}" style="display:none;">
<label for="opt_{{ option.letter }}">{{ option.letter }}. {{ option.text }}</label>
</div>
{% endfor %}
</form>
</div>

11
quiz/templates/stats.html Normal file
View File

@@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block content %}
<h1>Dina Resultat</h1>
<div class="question">
<p>Totalt besvarade: {{ total }}</p>
<p>Rätt svar: {{ correct }}</p>
<p>Procent: {{ percentage }}%</p>
</div>
<a href="{% url 'index' %}">Tillbaka till quiz</a>
{% endblock %}