|
|
|
@@ -1,33 +1,54 @@
|
|
|
|
|
@extends('layouts.admin')
|
|
|
|
|
@section('title','Fragen')
|
|
|
|
|
@section('content')
|
|
|
|
|
<div class="flex flex-wrap gap-3 items-center justify-between mb-6" x-data="{showImport:false}">
|
|
|
|
|
<form method="GET" class="flex gap-2">
|
|
|
|
|
<select name="subject" class="border border-slate-300 rounded-lg px-3 py-2 text-sm">
|
|
|
|
|
<option value="">Alle Fächer</option>
|
|
|
|
|
@foreach($subjects as $s)<option value="{{ $s->id }}" {{ request('subject')==$s->id?'selected':'' }}>{{ $s->icon }} {{ $s->name }}</option>@endforeach
|
|
|
|
|
</select>
|
|
|
|
|
<button class="bg-slate-700 text-white px-4 py-2 rounded-lg text-sm">Filtern</button>
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
{{-- Subject Tabs --}}
|
|
|
|
|
<div class="flex gap-1 mb-6 bg-slate-100 p-1 rounded-xl w-fit">
|
|
|
|
|
@foreach($subjects as $s)
|
|
|
|
|
<a href="{{ route('admin.questions.index', ['subject'=>$s->id]) }}"
|
|
|
|
|
class="flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors
|
|
|
|
|
{{ $s->id == $activeSubject->id
|
|
|
|
|
? 'bg-white text-slate-800 shadow-sm'
|
|
|
|
|
: 'text-slate-500 hover:text-slate-700' }}">
|
|
|
|
|
<span>{{ $s->icon }}</span>
|
|
|
|
|
<span>{{ $s->name }}</span>
|
|
|
|
|
<span class="text-xs {{ $s->id == $activeSubject->id ? 'text-violet-600 font-bold' : 'text-slate-400' }}">
|
|
|
|
|
{{ $s->total }}
|
|
|
|
|
</span>
|
|
|
|
|
</a>
|
|
|
|
|
@endforeach
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{{-- Toolbar for active subject --}}
|
|
|
|
|
<div class="flex flex-wrap gap-2 items-center justify-between mb-5" x-data="{showImport:false}">
|
|
|
|
|
<h2 class="font-semibold text-slate-700 text-base flex items-center gap-2">
|
|
|
|
|
<span class="text-xl">{{ $activeSubject->icon }}</span> {{ $activeSubject->name }}
|
|
|
|
|
<span class="text-slate-400 font-normal text-sm">({{ $questions->total() }} Fragen)</span>
|
|
|
|
|
</h2>
|
|
|
|
|
<div class="flex gap-2 flex-wrap">
|
|
|
|
|
{{-- Export --}}
|
|
|
|
|
<a href="{{ route('admin.questions.export', request()->only('subject')) }}"
|
|
|
|
|
class="flex items-center gap-1.5 bg-slate-100 hover:bg-slate-200 text-slate-700 px-4 py-2 rounded-lg text-sm font-medium">
|
|
|
|
|
⬇ Export JSON
|
|
|
|
|
<a href="{{ route('admin.questions.export', ['subject'=>$activeSubject->id]) }}"
|
|
|
|
|
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">
|
|
|
|
|
⬇ Export
|
|
|
|
|
</a>
|
|
|
|
|
{{-- Import trigger --}}
|
|
|
|
|
<button @click="showImport=!showImport"
|
|
|
|
|
class="flex items-center gap-1.5 bg-slate-100 hover:bg-slate-200 text-slate-700 px-4 py-2 rounded-lg text-sm font-medium">
|
|
|
|
|
⬆ Import JSON
|
|
|
|
|
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.questions.create') }}" class="bg-violet-600 hover:bg-violet-700 text-white px-4 py-2 rounded-lg text-sm font-medium">+ Neue Frage</a>
|
|
|
|
|
<a href="{{ route('admin.questions.create', ['subject'=>$activeSubject->id]) }}"
|
|
|
|
|
class="bg-violet-600 hover:bg-violet-700 text-white px-4 py-2 rounded-lg text-sm font-medium">
|
|
|
|
|
+ Neue Frage
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{{-- Import panel --}}
|
|
|
|
|
<div x-show="showImport" x-cloak class="w-full mt-1">
|
|
|
|
|
<div class="bg-amber-50 border border-amber-200 rounded-xl p-5">
|
|
|
|
|
<h3 class="font-semibold text-slate-800 mb-1">Fragen importieren</h3>
|
|
|
|
|
<p class="text-xs text-slate-500 mb-3">JSON-Datei im gleichen Format wie der Export. Bestehende Fragen bleiben erhalten.</p>
|
|
|
|
|
<h3 class="font-semibold text-slate-800 mb-1">{{ $activeSubject->name }}-Fragen importieren</h3>
|
|
|
|
|
<p class="text-xs text-slate-500 mb-3">
|
|
|
|
|
Alle bestehenden <strong>{{ $activeSubject->name }}</strong>-Fragen werden durch den Import ersetzt.
|
|
|
|
|
Andere Fächer bleiben unberührt.
|
|
|
|
|
</p>
|
|
|
|
|
<form method="POST" action="{{ route('admin.questions.import') }}" enctype="multipart/form-data" class="flex items-center gap-3">
|
|
|
|
|
@csrf
|
|
|
|
|
<input type="file" name="file" accept=".json" required
|
|
|
|
@@ -39,37 +60,46 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{{-- Questions table --}}
|
|
|
|
|
<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">Frage</th>
|
|
|
|
|
<th class="text-left px-4 py-3 font-medium text-slate-600">Fach</th>
|
|
|
|
|
<th class="text-center px-4 py-3 font-medium text-slate-600">Schwierigkeit</th>
|
|
|
|
|
<th class="text-center px-4 py-3 font-medium text-slate-600">Aktiv</th>
|
|
|
|
|
<th class="text-center px-4 py-3 font-medium text-slate-600 hidden sm:table-cell">Aktiv</th>
|
|
|
|
|
<th class="px-4 py-3"></th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody class="divide-y divide-slate-100">
|
|
|
|
|
@forelse($questions as $q)
|
|
|
|
|
<tr class="hover:bg-slate-50">
|
|
|
|
|
<td class="px-4 py-3 text-slate-700 max-w-xs truncate">{{ $q->question_text }}</td>
|
|
|
|
|
<td class="px-4 py-3"><span class="text-base">{{ $q->subject->icon }}</span> {{ $q->subject->name }}</td>
|
|
|
|
|
<td class="px-4 py-3 text-slate-700 max-w-xs">
|
|
|
|
|
<span class="line-clamp-2">{{ $q->question_text }}</span>
|
|
|
|
|
</td>
|
|
|
|
|
<td class="px-4 py-3 text-center">{{ $q->difficultyStars() }}</td>
|
|
|
|
|
<td class="px-4 py-3 text-center">{{ $q->active ? '✅' : '⏸️' }}</td>
|
|
|
|
|
<td class="px-4 py-3 text-center hidden sm:table-cell">{{ $q->active ? '✅' : '⏸️' }}</td>
|
|
|
|
|
<td class="px-4 py-3 text-right whitespace-nowrap">
|
|
|
|
|
<a href="{{ route('admin.questions.edit',$q) }}" class="text-violet-600 hover:underline mr-3">Bearbeiten</a>
|
|
|
|
|
<form method="POST" action="{{ route('admin.questions.destroy',$q) }}" class="inline" onsubmit="return confirm('Löschen?')">
|
|
|
|
|
<form method="POST" action="{{ route('admin.questions.destroy',$q) }}" class="inline"
|
|
|
|
|
onsubmit="return confirm('Frage 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-8 text-center text-slate-400">Keine Fragen vorhanden.</td></tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan="4" class="px-4 py-10 text-center text-slate-400">
|
|
|
|
|
Noch keine Fragen für {{ $activeSubject->name }}.
|
|
|
|
|
<a href="{{ route('admin.questions.create', ['subject'=>$activeSubject->id]) }}" class="text-violet-600 hover:underline ml-1">Erste Frage erstellen →</a>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
@endforelse
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-4">{{ $questions->links() }}</div>
|
|
|
|
|
|
|
|
|
|
@endsection
|
|
|
|
|