<?php
require("config/koneksi.php");
require("config/function.php");
require("config/crud.php");
cek_session_siswa();
$ac = $_POST['idm'];
$id_siswa = $_POST['ids'];
$query = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM ujian WHERE id_ujian='$ac'"));
$idmapel = $query['id_mapel'];
$namamapel = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM ujian WHERE id_ujian='$ac'"));
$pesan = '';
?>
<div class='row'>
    <div class='col-md-3'></div>
    <div class='col-md-6'>
        <div class="card">
             <div class="card-header">	
                <h5 class='box-title'>Konfirmasi Tes</h5>
                <div class='right'>
                    <a href='<?= $homeurl ?>'><span class='btn btn-sm btn-outline-danger'>Kembali</span></a>
                </div>
            </div>
            <div class='card-body'>

                <div class='table-responsive'>
                    <form id="formmulaiujian" action='' method='post'>
                        <input type='hidden' value='<?= $id_siswa ?>' name='ids'>
                        <input type='hidden' value='<?= $ac ?>' name='idm'>
                        <table class='table no-margin'>
                            <tbody>
                                <tr>
                                    <td>
                                        <b>Nama Tes</b><br />
                                        <span class='badge badge-primary'><?= $namamapel['kode_ujian'] ?></span>
                                        <span class='badge badge-primary'><?= $namamapel['nama'] ?></span>
                                        <span class='badge badge-primary'><?= $namamapel['level'] ?></span>
										<span class='badge badge-primary'><?= $namamapel['groupsoal'] ?></span>
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>
                                        <b>Status Tes</b><br />
                                        <span>Tersedia</span>
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>
                                        <b>Jumlah Soal</b><br />
										<?php if($menu['soal']==1){ ?>
                                        <span class='badge badge-dark'><?= $namamapel['tampil_pg'] . ' PG / ' . $namamapel['tampil_multi'] . ' Multi / ' . $namamapel['tampil_bs'] . ' BS / ' . $namamapel['tampil_urut'] . ' Urut / '.$namamapel['tampil_esai'] ?> Esai</span>
                                        <?php }else{ ?>
										<span class='badge badge-dark'><?= $namamapel['tampil_pg'] . ' PG / ' .$namamapel['tampil_esai'] ?> Esai</span>
										<?php } ?>
									</td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>
                                        <b>Tanggal Waktu Tes</b><br />
                                        <span> <?= buat_tanggal('D, d M Y') ?></span>
                                        <span class='badge badge-warning'><?= $namamapel['waktu_ujian'] ?></span>
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>
                                        <b>Pembuat Jadwal</b>
                                        <br>
                                        <?php $guru = mysqli_fetch_array(mysqli_query($koneksi, "SELECT nama FROM users WHERE id_user='$namamapel[id_guru]'")); ?>
                                        <span><?= $guru['nama'] ?></span>
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td>
                                        <b>Alokasi Waktu Tes</b><br />
                                        <span><?= $namamapel['lama_ujian'] ?> menit</span>
                                    </td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <?php if ($namamapel['token'] == 1) : ?>
									 <?php $token=fetch($koneksi,'token',['id_token'=>1]); ?>
                                        <td>
                                            <input type='text' value="<?= $token['token'] ?>" class='form-control' name='token' placeholder='masukan token' autofocus readonly />
                                        </td>
                                    <?php endif ?>
                                    <td>
                                        <button type='submit' name='mulai' class='btn btn-primary btn-block right'>Mulai Test</button>
                                    </td>
                                </tr>
								
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $('#formmulaiujian').submit(function(e) {
        e.preventDefault();
        $.ajax({
            type: 'POST',
            url: 'cekkonfirmasi.php',
            data: $(this).serialize(),
            success: function(data) {
                toastr.success(data);
            }
        });
        return false;
    });
</script>