Files
lernapp/resources/views/admin/questions/index.blade.php
T
root 44f281514b Add grade/Klasse system: assign class levels to users, questions, and quizzes
- users.grade: set per child in admin (Klasse 1–10)
- quizzes.grade, questions.grade: optional target class (null = all)
- Children only see content matching their grade or without grade set
- Admin views show grade badge in user list, quiz list, questions list
- Quiz create/edit and user create/edit have Klasse dropdown
2026-05-06 07:19:17 +00:00

108 lines
5.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@extends('layouts.admin')
@section('title','Fragen')
@section('content')
{{-- 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">
<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>
<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.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">{{ $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
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 hover:file:bg-violet-200">
<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>
{{-- 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-center px-4 py-3 font-medium text-slate-600">Klasse</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 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">
<span class="line-clamp-2">{{ $q->question_text }}</span>
</td>
<td class="px-4 py-3 text-center text-xs text-slate-500">{{ $q->grade ? "Kl.".$q->grade : "" }}</td>
<td class="px-4 py-3 text-center">{{ $q->difficultyStars() }}</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('Frage löschen?')">
@csrf @method('DELETE')
<button class="text-red-500 hover:underline">Löschen</button>
</form>
</td>
</tr>
@empty
<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