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
72 lines
4.3 KiB
PHP
72 lines
4.3 KiB
PHP
@extends('layouts.admin')
|
||
@section('title','Frage hinzufügen')
|
||
@section('content')
|
||
<div class="max-w-2xl">
|
||
<a href="{{ route('admin.quizzes.edit',$quiz) }}" class="text-sm text-slate-500 hover:text-slate-700 mb-4 inline-block">← Zurück zu {{ $quiz->title }}</a>
|
||
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-6">
|
||
<h2 class="font-semibold text-slate-800 mb-5">Neue Frage hinzufügen</h2>
|
||
<form method="POST" action="{{ route('admin.quizzes.questions.store',$quiz) }}" class="space-y-4">
|
||
@csrf
|
||
@php $qtype='multiple_choice'; $correctIdx=0; $question_text=''; $time_limit=''; $correct_answer=''; $options=[]; @endphp
|
||
|
||
<div x-data="{ qtype: '{{ $qtype }}', correctIdx: {{ $correctIdx }} }">
|
||
<div>
|
||
<label class="block text-sm font-medium text-slate-700 mb-1">Fragetyp</label>
|
||
<select name="type" x-model="qtype" required
|
||
class="w-full border border-slate-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-violet-500 outline-none">
|
||
<option value="multiple_choice">Multiple Choice – Fehlersuche</option>
|
||
<option value="exclusion">Ausschlussverfahren (welches gehört nicht dazu?)</option>
|
||
<option value="true_false">Wahr / Falsch</option>
|
||
<option value="free_text">Freitext – Eingabe</option>
|
||
</select>
|
||
</div>
|
||
<div>
|
||
<label class="block text-sm font-medium text-slate-700 mb-1">Frage</label>
|
||
<textarea name="question_text" required rows="3"
|
||
class="w-full border border-slate-300 rounded-lg px-3 py-2 text-sm font-medium focus:ring-2 focus:ring-violet-500 outline-none">{{ $question_text ?? '' }}</textarea>
|
||
</div>
|
||
<div>
|
||
<label class="block text-sm font-medium text-slate-700 mb-1">Zeitlimit in Sekunden (leer = kein Limit)</label>
|
||
<input name="time_limit" type="number" min="5" max="120" value="{{ $time_limit ?? '' }}" placeholder="z.B. 30"
|
||
class="w-32 border border-slate-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-violet-500 outline-none">
|
||
</div>
|
||
|
||
{{-- MC / Exclusion options --}}
|
||
<div x-show="qtype === 'multiple_choice' || qtype === 'exclusion'" class="space-y-2">
|
||
<label class="block text-sm font-medium text-slate-700">Antwortmöglichkeiten <span class="text-slate-400 font-normal">(● = richtige Antwort)</span></label>
|
||
@for($i = 0; $i < 4; $i++)
|
||
<div class="flex items-center gap-3">
|
||
<input type="radio" name="correct_option" value="{{ $i }}" x-bind:checked="correctIdx === {{ $i }}"
|
||
@change="correctIdx = {{ $i }}"
|
||
class="text-violet-600 w-4 h-4 shrink-0">
|
||
<input type="text" name="options[{{ $i }}][text]" value="{{ $options[$i]['text'] ?? '' }}"
|
||
placeholder="Option {{ $i+1 }}"
|
||
class="flex-1 border border-slate-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-violet-500 outline-none">
|
||
</div>
|
||
@endfor
|
||
<p class="text-xs text-slate-400">Klicke den Radio-Button links neben der richtigen Antwort.</p>
|
||
</div>
|
||
|
||
{{-- True / False --}}
|
||
<div x-show="qtype === 'true_false'">
|
||
<label class="block text-sm font-medium text-slate-700 mb-1">Richtige Antwort</label>
|
||
<select name="correct_answer"
|
||
class="w-full border border-slate-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-violet-500 outline-none">
|
||
<option value="true" {{ ($correct_answer ?? '') === 'true' ? 'selected' : '' }}>✅ Wahr</option>
|
||
<option value="false" {{ ($correct_answer ?? '') === 'false' ? 'selected' : '' }}>❌ Falsch</option>
|
||
</select>
|
||
</div>
|
||
|
||
{{-- Free text --}}
|
||
<div x-show="qtype === 'free_text'">
|
||
<label class="block text-sm font-medium text-slate-700 mb-1">Richtige Antwort (exakter Text, Groß-/Kleinschreibung egal)</label>
|
||
<input type="text" name="correct_answer" value="{{ $correct_answer ?? '' }}" placeholder="z.B. 72"
|
||
class="w-full border border-slate-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-violet-500 outline-none">
|
||
</div>
|
||
</div>
|
||
<button type="submit" class="w-full bg-violet-600 hover:bg-violet-700 text-white py-2 rounded-lg font-medium text-sm">Frage hinzufügen</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
@endsection
|