<?php $__env->startSection('title', 'Edit Bank Soal IKK'); ?>

<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="row mb-4">
        <div class="col-md-12">
            <div class="d-flex justify-content-between align-items-center">
                <div>
                    <h3 class="mb-1"><i class="bi bi-pencil-square me-2"></i>Edit Bank Soal IKK</h3>
                    <p class="text-muted mb-0">Perbarui indikator kinerja kunci</p>
                </div>
                <a href="<?php echo e(route('admin.ikk.bank-soal.index')); ?>" class="btn btn-secondary">
                    <i class="bi bi-arrow-left me-1"></i> Kembali
                </a>
            </div>
        </div>
    </div>

    <div class="card card-gov shadow-sm">
        <div class="card-header">
            <h5 class="mb-0"><i class="bi bi-file-earmark-text me-2"></i>Form Edit Bank Soal</h5>
        </div>
        <div class="card-body">
            <form action="<?php echo e(route('admin.ikk.bank-soal.update', $soal->id)); ?>" method="POST">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PUT'); ?>

                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label for="kode_ikk" class="form-label">Kode IKK <span class="text-danger">*</span></label>
                        <input type="text" class="form-control <?php $__errorArgs = ['kode_ikk'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                               id="kode_ikk" name="kode_ikk" value="<?php echo e(old('kode_ikk', $soal->kode_ikk)); ?>"
                               placeholder="Contoh: 1.a.1" required>
                        <?php $__errorArgs = ['kode_ikk'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="col-md-6 mb-3">
                        <label for="urusan" class="form-label">Urusan <span class="text-danger">*</span></label>
                        <input type="text" class="form-control <?php $__errorArgs = ['urusan'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                               id="urusan" name="urusan" value="<?php echo e(old('urusan', $soal->urusan)); ?>"
                               placeholder="Contoh: Pendidikan" required>
                        <?php $__errorArgs = ['urusan'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="col-md-6 mb-3">
                        <label for="bidang" class="form-label">Bidang <span class="text-danger">*</span></label>
                        <input type="text" class="form-control <?php $__errorArgs = ['bidang'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                               id="bidang" name="bidang" value="<?php echo e(old('bidang', $soal->bidang)); ?>"
                               placeholder="Contoh: Pendidikan Dasar" required>
                        <?php $__errorArgs = ['bidang'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="col-md-6 mb-3">
                        <label for="opd_penanggung_jawab" class="form-label">OPD Penanggung Jawab <span class="text-danger">*</span></label>
                        <select class="form-select <?php $__errorArgs = ['opd_penanggung_jawab'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                id="opd_penanggung_jawab" name="opd_penanggung_jawab" required>
                            <option value="">-- Pilih OPD --</option>
                            <?php $__currentLoopData = $opdList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $opd): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($opd->name); ?>" <?php echo e(old('opd_penanggung_jawab', $soal->opd_penanggung_jawab) == $opd->name ? 'selected' : ''); ?>>
                                    <?php echo e($opd->name); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <?php $__errorArgs = ['opd_penanggung_jawab'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="col-md-12 mb-3">
                        <label for="ikk_output" class="form-label">IKK Output <span class="text-danger">*</span></label>
                        <input type="text" class="form-control <?php $__errorArgs = ['ikk_output'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                               id="ikk_output" name="ikk_output" value="<?php echo e(old('ikk_output', $soal->ikk_output)); ?>" required>
                        <?php $__errorArgs = ['ikk_output'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="col-md-12 mb-3">
                        <label for="ikk_outcome" class="form-label">IKK Outcome <span class="text-danger">*</span></label>
                        <textarea class="form-control <?php $__errorArgs = ['ikk_outcome'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                  id="ikk_outcome" name="ikk_outcome" rows="2" required><?php echo e(old('ikk_outcome', $soal->ikk_outcome)); ?></textarea>
                        <?php $__errorArgs = ['ikk_outcome'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="col-md-12 mb-3">
                        <label for="rumus_perhitungan" class="form-label">Rumus Perhitungan <span class="text-danger">*</span></label>
                        <textarea class="form-control <?php $__errorArgs = ['rumus_perhitungan'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                  id="rumus_perhitungan" name="rumus_perhitungan" rows="2" required><?php echo e(old('rumus_perhitungan', $soal->rumus_perhitungan)); ?></textarea>
                        <?php $__errorArgs = ['rumus_perhitungan'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="col-md-4 mb-3">
                        <label for="satuan" class="form-label">Satuan <span class="text-danger">*</span></label>
                        <input type="text" class="form-control <?php $__errorArgs = ['satuan'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                               id="satuan" name="satuan" value="<?php echo e(old('satuan', $soal->satuan)); ?>"
                               placeholder="Contoh: Persen (%)" required>
                        <?php $__errorArgs = ['satuan'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="col-md-4 mb-3">
                        <label for="tahun_mulai" class="form-label">Tahun Mulai <span class="text-danger">*</span></label>
                        <input type="number" class="form-control <?php $__errorArgs = ['tahun_mulai'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                               id="tahun_mulai" name="tahun_mulai"
                               value="<?php echo e(old('tahun_mulai', $soal->tahun_mulai)); ?>"
                               min="2020" required>
                        <?php $__errorArgs = ['tahun_mulai'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="col-md-4 mb-3">
                        <label for="status" class="form-label">Status <span class="text-danger">*</span></label>
                        <select class="form-select <?php $__errorArgs = ['status'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                id="status" name="status" required>
                            <option value="Aktif" <?php echo e(old('status', $soal->status) == 'Aktif' ? 'selected' : ''); ?>>Aktif</option>
                            <option value="Tidak Aktif" <?php echo e(old('status', $soal->status) == 'Tidak Aktif' ? 'selected' : ''); ?>>Tidak Aktif</option>
                        </select>
                        <?php $__errorArgs = ['status'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="col-md-12 mb-3">
                        <label for="sumber_data" class="form-label">Sumber Data <span class="text-danger">*</span></label>
                        <input type="text" class="form-control <?php $__errorArgs = ['sumber_data'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                               id="sumber_data" name="sumber_data" value="<?php echo e(old('sumber_data', $soal->sumber_data)); ?>" required>
                        <?php $__errorArgs = ['sumber_data'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                </div>

                <hr class="my-4">

                <div class="row">
                    <div class="col-md-12 mb-3">
                        <h5 class="mb-3"><i class="bi bi-input-cursor-text me-2"></i>Konfigurasi Input Jawaban</h5>
                    </div>

                    <div class="col-md-6 mb-3">
                        <label for="tipe_input" class="form-label">Tipe Input <span class="text-danger">*</span></label>
                        <select class="form-select <?php $__errorArgs = ['tipe_input'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                id="tipe_input" name="tipe_input" required>
                            <option value="">Pilih Tipe Input</option>
                            <option value="text" <?php echo e(old('tipe_input', $soal->tipe_input) == 'text' ? 'selected' : ''); ?>>Text (Input singkat)</option>
                            <option value="textarea" <?php echo e(old('tipe_input', $soal->tipe_input) == 'textarea' ? 'selected' : ''); ?>>Textarea (Input panjang)</option>
                            <option value="radio" <?php echo e(old('tipe_input', $soal->tipe_input) == 'radio' ? 'selected' : ''); ?>>Radio Button (Pilihan tunggal)</option>
                            <option value="select" <?php echo e(old('tipe_input', $soal->tipe_input) == 'select' ? 'selected' : ''); ?>>Select Dropdown (Pilihan dari list)</option>
                        </select>
                        <?php $__errorArgs = ['tipe_input'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <small class="text-muted">Pilih jenis input yang akan digunakan untuk menjawab</small>
                    </div>

                    <div class="col-md-6 mb-3" id="pilihanJawabanWrapper" style="display: <?php echo e(in_array(old('tipe_input', $soal->tipe_input), ['radio', 'select']) ? 'block' : 'none'); ?>;">
                        <label for="pilihan_jawaban" class="form-label">Pilihan Jawaban <span class="text-danger">*</span></label>
                        <textarea class="form-control <?php $__errorArgs = ['pilihan_jawaban'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                  id="pilihan_jawaban" name="pilihan_jawaban" rows="5"
                                  placeholder="Masukkan pilihan jawaban (satu per baris)&#10;Contoh:&#10;Ya&#10;Tidak&#10;Tidak Tahu"><?php echo e(old('pilihan_jawaban', $soal->pilihan_jawaban ? implode("\n", json_decode($soal->pilihan_jawaban, true)) : '')); ?></textarea>
                        <?php $__errorArgs = ['pilihan_jawaban'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        <small class="text-muted">Masukkan setiap pilihan pada baris baru</small>
                    </div>
                </div>

                <hr class="my-4">

                <div class="d-flex justify-content-between">
                    <a href="<?php echo e(route('admin.ikk.bank-soal.index')); ?>" class="btn btn-secondary">
                        <i class="bi bi-x-circle me-1"></i> Batal
                    </a>
                    <button type="submit" class="btn btn-gov-primary">
                        <i class="bi bi-save me-1"></i> Simpan Bank Soal
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
document.getElementById('tipe_input').addEventListener('change', function() {
    const pilihanWrapper = document.getElementById('pilihanJawabanWrapper');
    const pilihanInput = document.getElementById('pilihan_jawaban');

    if (this.value === 'radio' || this.value === 'select') {
        pilihanWrapper.style.display = 'block';
        pilihanInput.required = true;
    } else {
        pilihanWrapper.style.display = 'none';
        pilihanInput.required = false;
        pilihanInput.value = '';
    }
});

// Trigger on load if old value exists
document.addEventListener('DOMContentLoaded', function() {
    const tipeInput = document.getElementById('tipe_input');
    if (tipeInput.value === 'radio' || tipeInput.value === 'select') {
        document.getElementById('pilihanJawabanWrapper').style.display = 'block';
        document.getElementById('pilihan_jawaban').required = true;
    }
});
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Users/user/Documents/giriwidyan/project/inhouse/skm/resources/views/admin/ikk/bank_soal/edit.blade.php ENDPATH**/ ?>