6c6dd26823
- Quizzes table with questions, answer options, attempts, answers - Question types: multiple_choice, exclusion, true_false, free_text - Progressive scoring: [1,1,2,2,3,3,4,6,8,10] = max 40 per quiz - Alpine.js countdown timer per question with auto-submit on timeout - Admin: CRUD for quizzes + per-question editor, JSON export/import - Child: quiz overview with best scores, question view, result breakdown - Nav: Quiz link in child header and admin sidebar
62 lines
3.5 KiB
PHP
62 lines
3.5 KiB
PHP
@extends('layouts.admin')
|
|
@section('title','Quizzes')
|
|
@section('content')
|
|
<div class="flex justify-between items-center mb-6" x-data="{showImport:false}">
|
|
<h2 class="text-lg font-semibold text-slate-700">Quizzes</h2>
|
|
<div class="flex gap-2">
|
|
<button @click="showImport=!showImport"
|
|
class="flex items-center gap-1.5 bg-slate-100 hover:bg-slate-200 text-slate-700 px-3 py-2 rounded-lg text-sm font-medium"
|
|
:class="showImport && 'bg-amber-100 text-amber-700'">⬆ Import</button>
|
|
<a href="{{ route('admin.quizzes.create') }}" class="bg-violet-600 hover:bg-violet-700 text-white px-4 py-2 rounded-lg text-sm font-medium">+ Neues Quiz</a>
|
|
</div>
|
|
<div x-show="showImport" x-cloak class="w-full mt-3">
|
|
<div class="bg-amber-50 border border-amber-200 rounded-xl p-4">
|
|
<p class="text-xs text-slate-500 mb-3">JSON im gleichen Format wie der Export. Erstellt immer ein neues Quiz.</p>
|
|
<form method="POST" action="{{ route('admin.quizzes.import') }}" enctype="multipart/form-data" class="flex gap-3">
|
|
@csrf
|
|
<input type="file" name="file" accept=".json" required
|
|
class="flex-1 text-sm text-slate-600 file:mr-3 file:py-1.5 file:px-3 file:rounded-lg file:border-0 file:text-sm file:font-medium file:bg-violet-100 file:text-violet-700">
|
|
<button type="submit" class="bg-violet-600 hover:bg-violet-700 text-white px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap">Importieren</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden">
|
|
<table class="w-full text-sm">
|
|
<thead class="bg-slate-50 border-b border-slate-200">
|
|
<tr>
|
|
<th class="text-left px-4 py-3 font-medium text-slate-600">Fach</th>
|
|
<th class="text-left px-4 py-3 font-medium text-slate-600">Titel</th>
|
|
<th class="text-center px-4 py-3 font-medium text-slate-600">Fragen</th>
|
|
<th class="text-center px-4 py-3 font-medium text-slate-600">Status</th>
|
|
<th class="px-4 py-3"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-slate-100">
|
|
@forelse($quizzes as $quiz)
|
|
<tr class="hover:bg-slate-50">
|
|
<td class="px-4 py-3 text-slate-600">{{ $quiz->subject->icon }} {{ $quiz->subject->name }}</td>
|
|
<td class="px-4 py-3 font-medium text-slate-800">{{ $quiz->title }}</td>
|
|
<td class="px-4 py-3 text-center">
|
|
<span class="{{ $quiz->questions_count < 10 ? 'text-amber-600' : 'text-green-600' }} font-medium">
|
|
{{ $quiz->questions_count }}/10
|
|
</span>
|
|
</td>
|
|
<td class="px-4 py-3 text-center">{{ $quiz->active ? '✅' : '⏸️' }}</td>
|
|
<td class="px-4 py-3 text-right whitespace-nowrap">
|
|
<a href="{{ route('admin.quizzes.export',$quiz) }}" class="text-slate-500 hover:text-slate-700 mr-3 text-xs">⬇ Export</a>
|
|
<a href="{{ route('admin.quizzes.edit',$quiz) }}" class="text-violet-600 hover:underline mr-3">Bearbeiten</a>
|
|
<form method="POST" action="{{ route('admin.quizzes.destroy',$quiz) }}" class="inline" onsubmit="return confirm('Quiz löschen?')">
|
|
@csrf @method('DELETE')
|
|
<button class="text-red-500 hover:underline">Löschen</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr><td colspan="5" class="px-4 py-10 text-center text-slate-400">Noch keine Quizzes. <a href="{{ route('admin.quizzes.create') }}" class="text-violet-600 hover:underline">Erstes Quiz erstellen →</a></td></tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
@endsection
|