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
64 lines
2.8 KiB
PHP
64 lines
2.8 KiB
PHP
@extends('layouts.child')
|
||
@section('content')
|
||
<div class="text-center mb-8">
|
||
<div class="text-6xl mb-3">{{ $attempt->stars() }}</div>
|
||
<h1 class="text-3xl font-black text-slate-800">{{ $attempt->score }} / 40 Münzen</h1>
|
||
<p class="text-slate-500 mt-1">{{ $attempt->quiz->title }}</p>
|
||
<div class="mt-3 inline-flex items-center gap-2 bg-amber-100 text-amber-700 font-bold px-5 py-2 rounded-full text-lg">
|
||
+{{ $attempt->score }} 🪙 verdient!
|
||
</div>
|
||
</div>
|
||
|
||
{{-- Per-question breakdown --}}
|
||
<div class="bg-white rounded-2xl shadow-sm border border-slate-200 overflow-hidden mb-6">
|
||
<table class="w-full text-sm">
|
||
<thead class="bg-slate-50 border-b border-slate-100">
|
||
<tr>
|
||
<th class="px-4 py-3 text-left font-medium text-slate-500">#</th>
|
||
<th class="px-4 py-3 text-left font-medium text-slate-500">Frage</th>
|
||
<th class="px-4 py-3 text-center font-medium text-slate-500">Ergebnis</th>
|
||
<th class="px-4 py-3 text-center font-medium text-slate-500">Münzen</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody class="divide-y divide-slate-100">
|
||
@foreach($answers as $i => $a)
|
||
@php
|
||
$display = $a->answer_given;
|
||
if ($display === '__timeout__') {
|
||
$display = '⏱ Zeit abgelaufen';
|
||
} elseif (in_array($a->question->type, ['multiple_choice','exclusion'])) {
|
||
$opt = $a->question->answerOptions->firstWhere('id', (int)$a->answer_given);
|
||
$display = $opt ? $opt->text : '–';
|
||
} elseif ($a->question->type === 'true_false') {
|
||
$display = $display === 'true' ? 'Wahr' : 'Falsch';
|
||
}
|
||
$points_scale = \App\Models\QuizAttempt::POINTS;
|
||
@endphp
|
||
<tr class="{{ $a->is_correct ? 'bg-green-50' : '' }}">
|
||
<td class="px-4 py-3 text-slate-400 font-medium">{{ $i+1 }}</td>
|
||
<td class="px-4 py-3 text-slate-700">{{ Str::limit($a->question->question_text, 55) }}</td>
|
||
<td class="px-4 py-3 text-center">
|
||
@if($a->is_correct)
|
||
<span class="text-green-700 font-medium">✅ {{ $display }}</span>
|
||
@else
|
||
<span class="text-red-600">❌ {{ $display }}</span>
|
||
@endif
|
||
</td>
|
||
<td class="px-4 py-3 text-center font-bold {{ $a->is_correct ? 'text-amber-600' : 'text-slate-300' }}">
|
||
{{ $a->is_correct ? '+' . $a->points_earned : '0' }}
|
||
</td>
|
||
</tr>
|
||
@endforeach
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="flex gap-3">
|
||
<form method="POST" action="{{ route('quiz.start',$attempt->quiz) }}" class="flex-1">
|
||
@csrf
|
||
<button class="w-full bg-slate-100 hover:bg-slate-200 text-slate-700 py-3 rounded-xl font-medium">🔁 Nochmal spielen</button>
|
||
</form>
|
||
<a href="{{ route('quiz.index') }}" class="flex-1 bg-indigo-600 hover:bg-indigo-700 text-white py-3 rounded-xl font-bold text-center">← Zur Quiz-Übersicht</a>
|
||
</div>
|
||
@endsection
|