<?php $__env->startSection('title', 'Daftar Ujian'); ?>
<?php $__env->startSection('page_title', 'Ujian & Kuis'); ?>

<?php $__env->startSection('content'); ?>
<!-- TITLE CARD -->
<div class="card" style="margin-bottom: 24px;">
    <div class="card-body">
        <h3 style="color: var(--text-dark); margin-bottom: 8px;">Daftar Ujian Kelas <?php echo e($kelas ?? '-'); ?></h3>
        <p style="color: var(--text-gray); margin-bottom: 0;">Berikut adalah daftar ujian berstatus aktif untuk kelas Anda. Tombol mulai akan aktif ketika waktu ujian sudah dibuka.</p>
    </div>
</div>

<!-- TABLE CONTAINER CARD -->
<div class="card">
    <div class="card-body" style="padding: 0;">
        <div class="table-responsive">
            <table class="modern-table">
                <thead>
                    <tr>
                        <th>Judul Ujian</th>
                        <th>Mata Pelajaran</th>
                        <th>Durasi</th>
                        <th>Waktu Ujian</th>
                        <th>Status</th>
                        <th style="text-align: center;">Nilai</th>
                        <th style="width: 150px; text-align: center;">Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $ujianList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ujian): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <?php
                            $sub = $submissions->get($ujian->id);
                            $startsAt = $ujian->waktu_mulai_ujian;
                            $endsAt = $ujian->waktu_selesai_otomatis;
                            $statusText = 'Belum Dikerjakan';
                            $badgeClass = 'badge-selesai';
                            $scoreText = '-';

                            if ($sub) {
                                $statusText = 'Sudah Selesai';
                                $badgeClass = 'badge-aktif';
                                $scoreText = $sub->nilai;
                            } elseif (now('Asia/Jakarta')->greaterThanOrEqualTo($endsAt)) {
                                $statusText = 'Ujian Ditutup';
                                $badgeClass = 'badge-libur';
                            } elseif (now('Asia/Jakarta')->isBefore($startsAt)) {
                                $statusText = 'Ujian Belum Dimulai';
                                $badgeClass = 'badge-draft';
                            } else {
                                $statusText = 'Siap Dikerjakan';
                                $badgeClass = 'badge-selesai';
                            }
                        ?>
                        <tr>
                            <td style="font-weight: 600; color: var(--text-dark);"><?php echo e($ujian->judul); ?></td>
                            <td><?php echo e($ujian->mataPelajaran?->nama_mapel ?? '-'); ?></td>
                            <td><?php echo e($ujian->durasi); ?> Menit</td>
                            <td style="font-size: 14px; color: var(--text-gray);">
                                Mulai <?php echo e($startsAt->translatedFormat('d M Y, H:i')); ?> WIB<br>
                                s.d <?php echo e($endsAt->translatedFormat('d M Y, H:i')); ?> WIB
                            </td>
                            <td>
                                <span class="badge <?php echo e($badgeClass); ?>"><?php echo e($statusText); ?></span>
                            </td>
                            <td style="font-weight: 800; text-align: center; font-size: 1.1rem; color: <?php echo e($scoreText !== '-' && $scoreText >= 70 ? 'var(--success-color)' : ($scoreText !== '-' ? 'var(--danger-color)' : 'var(--text-gray)')); ?>">
                                <?php echo e($scoreText); ?>

                            </td>
                            <td style="text-align: center;">
                                <a href="<?php echo e(route('siswa.ujian.show', $ujian)); ?>" class="btn btn-primary btn-sm" style="text-decoration: none; display: inline-flex; align-items: center; gap: 6px;">
                                    <i class="fa-solid fa-file-signature"></i> Detail
                                </a>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="7" style="text-align: center; color: var(--text-gray); padding: 32px;">Tidak ada ujian aktif saat ini. Hore! 🎉</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.siswa', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\elearningsd-allFitur-main\resources\views/siswa/ujian/index.blade.php ENDPATH**/ ?>