@extends('layouts.admin')

@section('title', 'Edit Soal Kuis')

@section('content')
<div class="card border-0 shadow-sm rounded-4 p-4 col-lg-9 mx-auto">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h5 class="fw-bold mb-0">Form Edit Soal Kuis</h5>
        <a href="{{ route('admin.quiz.index') }}" class="btn btn-outline-secondary btn-sm rounded-pill">&larr; Batal & Kembali</a>
    </div>

    <form action="{{ route('admin.quiz.update', $quiz->id) }}" method="POST">
        @csrf @method('PUT')
        
        <div class="row">
            <div class="col-md-6 mb-3">
                <label class="form-label fw-bold">Pilih Level Kuis (1 s.d. 5)</label>
                <select name="level" class="form-select" required>
                    @for($i=1; $i<=5; $i++)
                        <option value="{{ $i }}" {{ $quiz->level == $i ? 'selected' : '' }}>Level {{ $i }}</option>
                    @endfor
                </select>
            </div>
            <div class="col-md-6 mb-3">
                <label class="form-label fw-bold">Kunci Jawaban Benar</label>
                <select name="correct_option" class="form-select" required>
                    <option value="A" {{ $quiz->correct_option == 'A' ? 'selected' : '' }}>Jawaban A</option>
                    <option value="B" {{ $quiz->correct_option == 'B' ? 'selected' : '' }}>Jawaban B</option>
                    <option value="C" {{ $quiz->correct_option == 'C' ? 'selected' : '' }}>Jawaban C</option>
                    <option value="D" {{ $quiz->correct_option == 'D' ? 'selected' : '' }}>Jawaban D</option>
                </select>
            </div>
        </div>

        <div class="mb-3">
            <label class="form-label fw-bold">Teks Pertanyaan Soal</label>
            <textarea name="question_text" class="form-control" rows="3" required>{{ old('question_text', $quiz->question_text) }}</textarea>
        </div>

        <div class="row">
            <div class="col-md-6 mb-3">
                <label class="form-label fw-bold">Pilihan A</label>
                <input type="text" name="option_a" class="form-control" value="{{ old('option_a', $quiz->option_a) }}" required>
            </div>
            <div class="col-md-6 mb-3">
                <label class="form-label fw-bold">Pilihan B</label>
                <input type="text" name="option_b" class="form-control" value="{{ old('option_b', $quiz->option_b) }}" required>
            </div>
            <div class="col-md-6 mb-3">
                <label class="form-label fw-bold">Pilihan C</label>
                <input type="text" name="option_c" class="form-control" value="{{ old('option_c', $quiz->option_c) }}" required>
            </div>
            <div class="col-md-6 mb-3">
                <label class="form-label fw-bold">Pilihan D</label>
                <input type="text" name="option_d" class="form-control" value="{{ old('option_d', $quiz->option_d) }}" required>
            </div>
        </div>

        <div class="mb-4">
            <label class="form-label fw-bold">Penjelasan Edukatif Jawaban</label>
            <textarea name="explanation" class="form-control" rows="2">{{ old('explanation', $quiz->explanation) }}</textarea>
        </div>

        <button type="submit" class="btn btn-warning btn-lg w-100 rounded-pill fw-bold">
            <i class="fa-solid fa-pen-to-square me-1"></i> Perbarui Soal Kuis
        </button>
    </form>
</div>
@endsection
