Resolve "Detail quiz überarbeiten" #290

Merged
ben8 merged 1 commits from 166-detail-quiz-uberarbeiten into master 2026-01-17 14:47:49 +00:00

View File

@@ -4,60 +4,79 @@
{% load static %} {% load static %}
<script src="{% static 'js/sortablejs/Sortable.min.js' %}"></script> <script src="{% static 'js/sortablejs/Sortable.min.js' %}"></script>
<div class="container mx-auto px-4"> <div class="container mx-auto px-6">
<div class="flex flex-wrap space-y-2 items-center justify-between mb-6 dark:text-white"> <div class="flex flex-wrap space-y-2 items-center justify-between mb-8 dark:text-white">
<h1 class="text-2xl font-bold mr-4 dark:text-white ">{{ quiz.name }}</h1> <div class="container mx-auto">
<h1 class="text-2xl mt-4 font-bold dark:text-white trucate">
{{ quiz.name }}
</h1>
<div class=" flex flex-wrap space-x-2 ">
<div class="flex items-center justify-center lg:justify-start gap-4 mt-4 flex-wrap">
<div class="flex flex-wrap"> {% if quiz.user_id == request.user %}
{% if quiz.user_id == request.user %} <!-- Edit -->
<a href="{% url 'library:edit_quiz' quiz.id %}" class=" text-white px-2 py-2 rounded-md text-sm lg:text-lg hover:scale-110 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-7 text-gray-600 dark:text-white"> <a href="{% url 'library:edit_quiz' quiz.id %}"
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" /> class="inline-flex bg-orange-100 text-orange-800 items-center py-2 px-2 gap-2 rounded-md text-sm lg:text-md hover:border-blue-600 border-2">
</svg> bearbeiten
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
</a> <path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" />
<a href="{% url 'library:delete_quiz' quiz.id %}" class=" text-white px-2 py-2 rounded-md text-sm lg:text-lg hover:scale-110 transition-colors"> </svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-7 text-gray-600 dark:text-white"> </a>
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
</svg> <!-- Delete -->
</a> <a href="{% url 'library:delete_quiz' quiz.id %}"
{% endif %} class="inline-flex bg-red-100 text-red-800 items-center py-2 px-2 gap-2 rounded-md text-sm lg:text-md hover:border-blue-600 border-2">
</div> löschen
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<div class="flex flex-wrap gap-2"> <path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
<a href="{% url 'library:copy_quiz' quiz.id %}" </svg>
class="inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors duration-200"> </a>
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> {% endif %}
<path stroke-linecap="round" stroke-linejoin="round"
d="M11.35 3.836c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m8.9-4.414c.376.023.75.05 1.124.08 1.131.094 1.976 1.057 1.976 2.192V16.5A2.25 2.25 0 0 1 18 18.75h-2.25m-7.5-10.5H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V18.75m-7.5-10.5h6.375c.621 0 1.125.504 1.125 1.125v9.375m-8.25-3 1.5 1.5 3-3.75" />
</svg> <a href="{% url 'library:copy_quiz' quiz.id %}"
Quiz duplizieren class="inline-flex bg-green-100 text-green-800 items-center py-2 px-2 gap-2 rounded-md text-sm lg:text-md hover:border-blue-600 border-2">
</a> duplizieren
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
{% if quiz.questions.count != 0 %} <path stroke-linecap="round" stroke-linejoin="round" d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75" />
<a href="{% url 'play:create_game' quiz.id %}" </svg>
class="inline-flex items-center gap-2 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors duration-200">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"> </a>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z" /> {% if quiz.questions.count %}
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" <a href="{% url 'play:create_game' quiz.id %}"
d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /> class="inline-flex bg-blue-100 text-blue-800 items-center py-2 px-2 gap-2 rounded-md text-sm lg:text-md hover:border-blue-600 border-2">
</svg> spielen
Spielen <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
</a> <path stroke-linecap="round" stroke-linejoin="round" d="M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.347a1.125 1.125 0 0 1 0 1.972l-11.54 6.347a1.125 1.125 0 0 1-1.667-.986V5.653Z" />
{% endif %} </svg>
</div> </a>
</div> {% endif %}
</div>
</div>
</div> </div>
{% if quiz.description %}
<p class="text-gray-600 mb-4 dark:text-gray-400">{{ quiz.description }}</p>
{% endif %}
<summary class="list-none">
<div class="flex items-center gap-3 mt-12">
<p class="text-lg font-bold text-blue-600 dark:text-white">Fragen des Quizzes</p>
<div class="h-0.5 flex-grow bg-gradient-to-r from-blue-600 to-transparent rounded-full"></div>
</div>
</summary>
<details open>
<div class="flex justify-end mb-4"> <div class="flex justify-end mb-4">
{% if detail == True %} {% if detail == True %}
@@ -87,47 +106,63 @@
</div> </div>
<div class="bg-white rounded-lg shadow-md border-blue-600 border-2 rounded-xl shadow-md dark:!bg-transparent dark:text-white">
<div class="border-b border-gray-200 p-4">
<div class="flex justify-between items-center flex-wrap">
<h2 class="text-xl font-semibold">Fragen
{% for question in questions %}{% if forloop.last %}({{ forloop.counter }}) {% endif %} {% endfor %}
</h2>
<div class="flex space-x-2 flex-wrap">
{% if quiz.user_id == request.user %}
<a href="{% url 'library:new_question' %}?type=input&quiz_id={{ quiz.id }}"
class=" mt-1 bg-green-100 text-green-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
Eingabe
</a>
<a href="{% url 'library:new_question' %}?type=multiple_choice&quiz_id={{ quiz.id }}"
class=" mt-1 bg-blue-100 text-blue-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
Multiple Choice
</a>
<a href="{% url 'library:new_question' %}?type=true_false&quiz_id={{ quiz.id }}"
class=" mt-1 bg-purple-100 text-purple-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
Wahr/Falsch
</a>
<a href="{% url 'library:new_question' %}?type=order&quiz_id={{ quiz.id }}"
class=" mt-1 bg-yellow-100 text-yellow-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2">
Reihenfolge
</a>
<a href="{% url 'library:new_question' %}?type=guess&quiz_id={{ quiz.id }}" <div class="bg-white rounded-xl shadow-md border-2 border-blue-600 dark:!bg-transparent dark:text-white">
class=" mt-1 bg-pink-100 text-pink-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2"> <div class="border-b border-gray-200 p-4">
Schätzen <div class="flex justify-between items-center flex-wrap">
</a> <!-- Titel -->
<a href="{% url 'library:new_question' %}?type=map&quiz_id={{ quiz.id }}" <h2 class="text-xl font-semibold">
class=" mt-1 bg-orange-100 text-orange-800 px-4 py-2 rounded-md text-xs lg:text-lg hover:border-blue-600 border-2"> Fragen
Karte {% for question in questions %}{% if forloop.last %}({{ forloop.counter }}) {% endif %}{% endfor %}
</a> </h2>
{% endif %}
</div>
</div>
<!-- Neue Frage Dropdown -->
{% if quiz.user_id == request.user %}
<div class="relative inline-block text-left mt-2 sm:mt-0">
<button type="button" class="inline-flex justify-center w-full rounded-md border border-blue-600 shadow-sm px-4 py-2 bg-blue-600 text-white text-sm font-medium hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" id="menu-button" aria-expanded="true" aria-haspopup="true">
Neue Frage
<!-- Pfeil nach unten -->
<svg class="-mr-1 ml-2 h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.584l3.71-4.354a.75.75 0 011.08 1.04l-4.25 5a.75.75 0 01-1.08 0l-4.25-5a.75.75 0 01.02-1.06z" clip-rule="evenodd" />
</svg>
</button>
<!-- Dropdown Menu -->
<div class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-white dark:bg-gray-800 ring-1 ring-black ring-opacity-5 focus:outline-none hidden group" id="dropdown-menu">
<div class="py-1 flex flex-col" role="menu" aria-orientation="vertical" aria-labelledby="menu-button">
<a href="{% url 'library:new_question' %}?type=input&quiz_id={{ quiz.id }}" class="block px-4 py-2 text-sm text-gray-700 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700" role="menuitem">Eingabe</a>
<a href="{% url 'library:new_question' %}?type=multiple_choice&quiz_id={{ quiz.id }}" class="block px-4 py-2 text-sm text-gray-700 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700" role="menuitem">Multiple Choice</a>
<a href="{% url 'library:new_question' %}?type=true_false&quiz_id={{ quiz.id }}" class="block px-4 py-2 text-sm text-gray-700 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700" role="menuitem">Wahr/Falsch</a>
<a href="{% url 'library:new_question' %}?type=order&quiz_id={{ quiz.id }}" class="block px-4 py-2 text-sm text-gray-700 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700" role="menuitem">Reihenfolge</a>
<a href="{% url 'library:new_question' %}?type=guess&quiz_id={{ quiz.id }}" class="block px-4 py-2 text-sm text-gray-700 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700" role="menuitem">Schätzen</a>
<a href="{% url 'library:new_question' %}?type=map&quiz_id={{ quiz.id }}" class="block px-4 py-2 text-sm text-gray-700 dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700" role="menuitem">Karte</a>
</div>
</div> </div>
</div>
{% endif %}
</div>
</div>
<!-- Dropdown Toggle Script -->
<script>
const btn = document.getElementById('menu-button');
const menu = document.getElementById('dropdown-menu');
btn.addEventListener('click', () => {
menu.classList.toggle('hidden');
});
window.addEventListener('click', (e) => {
if (!btn.contains(e.target) && !menu.contains(e.target)) {
menu.classList.add('hidden');
}
});
</script>
{% if questions %} {% if questions %}
@@ -320,6 +355,7 @@
</div> </div>
{% endif %} {% endif %}
</div> </div>
</details>
<!-- Kritik zum Quiz --> <!-- Kritik zum Quiz -->
@@ -397,11 +433,20 @@
<p class="text-lg font-bold text-gray-800 dark:text-white dark:bg-transparent mb-3"> <p class="text-lg font-bold text-gray-800 dark:text-white dark:bg-transparent mb-3">
Quiz-Infos Quiz-Infos
</p> </p>
<div class="flex">
{% if quiz.description %}
<p class="text-gray-600 dark:text-white">Beschreibung: {{ quiz.description }}</p>
{% endif %}
</div>
<div class="flex"> <div class="flex">
{% if quiz.base_quiz %} {% if quiz.base_quiz %}
<p class="text-gray-600 mt-2 dark:text-white">Bearbeitung:<span class="font-bold"> <a href="{% url 'library:overview_quiz' %}?filter=1&user={{ quiz.user_id }}">{{ quiz.user_id }}</a></span></p> <p class="text-gray-600 dark:text-white">Bearbeitung:<span class="font-bold"> <a href="{% url 'library:overview_quiz' %}?filter=1&user={{ quiz.user_id }}">{{ quiz.user_id }}</a></span></p>
{% else %} {% else %}
<p class="text-gray-600 mt-2 dark:text-white">Autor:<span class="font-bold"> <a href="{% url 'library:overview_quiz' %}?filter=1&user={{ quiz.user_id }}">{{ quiz.user_id }}</a></span></p> <p class="text-gray-600 dark:text-white">Autor:<span class="font-bold"> <a href="{% url 'library:overview_quiz' %}?filter=1&user={{ quiz.user_id }}">{{ quiz.user_id }}</a></span></p>
{% endif %} {% endif %}
</div> </div>
@@ -503,8 +548,8 @@
</details> </details>
{% if user.is_authenticated %}
{% if quiz.user_id != request.user %} {% if quiz.user_id != request.user %}
<summary class="list-none"> <summary class="list-none">
<div class="flex items-center gap-3 mt-12"> <div class="flex items-center gap-3 mt-12">
<p class="text-lg font-bold text-red-800 dark:text-white">Das Quiz kritisieren</p> <p class="text-lg font-bold text-red-800 dark:text-white">Das Quiz kritisieren</p>
@@ -513,6 +558,7 @@
</summary> </summary>
<details> <details>
{% if user.is_authenticated %}
<form method="post" class="space-y-6" enctype="multipart/form-data"> <form method="post" class="space-y-6" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
<div class="max-w-full p-4 mt-4 rounded-2xl bg-gray-100 dark:bg-transparent shadow-sm"> <div class="max-w-full p-4 mt-4 rounded-2xl bg-gray-100 dark:bg-transparent shadow-sm">
@@ -570,8 +616,8 @@
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500"> focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500">
Abschicken Abschicken
</button> </button>
{% endif %} {% elif not user.is_authenticated %}
{% elif quiz.user_id != request.user %}
<div class="max-w-full p-4 mt-8 rounded-2xl bg-gray-100 dark:bg-transparent shadow-sm"> <div class="max-w-full p-4 mt-8 rounded-2xl bg-gray-100 dark:bg-transparent shadow-sm">
<p class="text-lg font-bold text-red-800 dark:text-white dark:bg-transparent "> <p class="text-lg font-bold text-red-800 dark:text-white dark:bg-transparent ">
Quiz kritisieren Quiz kritisieren
@@ -587,6 +633,7 @@
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" href="{% url 'accounts:login' %}">Anmelden</a> focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" href="{% url 'accounts:login' %}">Anmelden</a>
</div> </div>
{% endif %} {% endif %}
{% endif %}
</div> </div>