Files
lernapp/resources/views/admin/questions/create.blade.php
T

55 lines
3.4 KiB
PHP

@extends('layouts.admin')
@section('title','Neue Frage')
@section('content')
<div class="max-w-2xl">
<a href="{{ route('admin.questions.index', ['subject'=>$activeSubject->id]) }}" class="text-sm text-slate-500 hover:text-slate-700 mb-4 inline-block"> Zurück</a>
<div class="bg-white rounded-xl shadow-sm border border-slate-200 p-6" x-data="{type:'multiple_choice'}">
<h2 class="font-semibold text-slate-800 mb-5">Neue Frage erstellen</h2>
<form method="POST" action="{{ route('admin.questions.store') }}" class="space-y-5">
@csrf
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Fach</label>
<select name="subject_id" 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">
@foreach($subjects as $s)<option value="{{ $s->id }}" {{ $s->id==$activeSubject->id?'selected':'' }}>{{ $s->icon }} {{ $s->name }}</option>@endforeach
</select>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Schwierigkeit</label>
<select name="difficulty" 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="1"> Leicht (5 Münzen)</option>
<option value="2">⭐⭐ Mittel (10 Münzen)</option>
<option value="3">⭐⭐⭐ Schwer (20 Münzen)</option>
</select>
</div>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Typ</label>
<select name="type" x-model="type" 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</option>
<option value="number_input">Zahlenantwort</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-1">Frage</label>
<textarea name="question_text" required rows="2" class="w-full border border-slate-300 rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-violet-500 outline-none">{{ old('question_text') }}</textarea>
</div>
<div x-show="type==='multiple_choice'">
<label class="block text-sm font-medium text-slate-700 mb-2">Antwortmöglichkeiten <span class="text-slate-400">(Richtige markieren)</span></label>
@for($i=0;$i<4;$i++)
<div class="flex items-center gap-3 mb-2">
<input type="radio" name="correct" value="{{ $i }}" {{ $i===0?'checked':'' }} class="accent-violet-600">
<input type="text" name="options[]" placeholder="Antwort {{ $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
</div>
<div x-show="type==='number_input'">
<label class="block text-sm font-medium text-slate-700 mb-1">Richtige Antwort (Zahl)</label>
<input type="text" name="number_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">
</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 speichern</button>
</form>
</div>
</div>
@endsection