<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="shortcut icon" href="<?= $logo ?>" type="image/x-icon">
    <script language="JavaScript">
        document.addEventListener("contextmenu", function(e) {
            e.preventDefault();
        }, false);
    </script>



    <title> <?= $page_title ?? "Print Jawaban" ?></title>
    <style>
        * {
            margin: auto;
            padding: 0;
            line-height: 100%;
        }

        td {
            padding: 1px 3px 1px 3px;
        }

        .garis {
            border: 1px solid #000;
            border-left: 0px;
            border-right: 0px;
            padding: 1px;
            margin-top: 5px;
            margin-bottom: 5px;
        }

        @media print {
            .pgi {
                page-break-inside: avoid;
            }

            .pbb {
                page-break-before: always;
            }
        }
    </style>
</head>

<body onload="window.print();setTimeout(()=>window.close(),500)">

    <!-- <body> -->
    <?php foreach ($ujian as $uk => $uv) :  ?>
        <?php $v['index'] = ['text' => ["A", "B", "C", "D", "E"], 'num' => 0]; ?>
        <table class="<?= $uk > 0 ? 'pbb' : '' ?>">
            <tbody>
                <tr>
                    <td rowspan="6">
                        <img src="<?= $logo ?>" width="90px">
                    </td>
                    <td width="200">Mata Pelajaran </td>
                    <td width="200">: <?= $mapel ?> </td>
                    <td rowspan="5" width="300">
                        <center>
                            SKOR
                            <br />
                            <h1>
                                <?= $uv['person']['nilai_pg'] + $uv['person']['nilai_esai'] ?>
                            </h1>
                        </center>
                    </td>
                </tr>
                <tr>
                    <td>Nama Peserta</td>
                    <td>: <?= $uv['person']['nama'] ?></td>
                </tr>
                <tr>
                    <td>Nomor Peserta</td>
                    <td>: <?= $uv['person']['nomor_induk'] ?></td>
                </tr>
                <tr>
                    <td>Kelas</td>
                    <?php if ($uv['person']['kelas'] && $uv['person']['tingkat']) : ?>
                        <td>: <?= $uv['person']['tingkat']  ?> - <?= $uv['person']['kelas'] ?></td>
                    <?php elseif ($uv['person']['kelas'] && !$uv['person']['tingkat']) : ?>
                        <td>: <?= $uv['person']['kelas'] ?></td>
                    <?php else : ?>
                        <td>: -</td>
                    <?php endif ?>
                </tr>
                <tr>
                    <td>Nilai</td>
                    <td>: <?= $uv['person']['nilai_pg'] + $uv['person']['nilai_esai'] ?></td>
                </tr>
                <?php if (!empty(options('nama_sekolah'))) : ?>
                    <tr>
                        <td>Satuan Pendidikan</td>
                        <td>: <?= options('nama_sekolah') ?></td>
                    </tr>
                <?php endif ?>
            </tbody>
        </table>

        <div class="garis"></div>
        <br>
        <?php $pgindex = 1 ?>

        <?php if (count($uv['pg']) > 0 || count($uv['pgmulti']) > 0 || count($uv['pgcouple']) > 0 || count($uv['pgtf']) > 0) : ?>
            <h3 class="panel-title">
                <b><?= $v['index']['text'][$v['index']['num']++] ?>. Soal Pilihan Ganda</b>
            </h3>
            <br>
            <!-- START PG COMMON -->
            <?php foreach ($uv['pg'] as $pgk => $pgv) : ?>
                <table width="100%" border="0">
                    <tbody>
                        <tr>
                            <td width="30px" valign="top">
                                <p><?= $pgindex++ ?></p>
                            </td>
                            <td valign="top">
                                <?= str_replace("../../../", "../../../../", $pgv['question']) ?>
                            </td>
                        </tr>
                        <tr>

                            <td width="30px">&nbsp;</td>
                            <td>JAWABAN : <?= $pgv['response'] ?></td>
                        </tr>
                    </tbody>
                </table>
            <?php endforeach ?>
            <!-- END PG COMMON -->
            <!-- START PG MULTI -->
            <?php foreach ($uv['pgmulti'] as $pgmk => $pgmv) : ?>
                <table width="100%" border="0">
                    <tbody>
                        <tr>
                            <td width="30px" valign="top">
                                <p><?= $pgindex++ ?></p>
                            </td>
                            <td valign="top">
                                <?= str_replace("../../../", "../../../../", $pgmv['question']) ?>
                            </td>
                        </tr>
                        <tr>

                            <td width="30px">&nbsp;</td>
                            <td>JAWABAN :
                                <ul>
                                    <?php foreach ($pgmv['responses'] as $response) : ?>
                                        <li>
                                            <?= $response ?>
                                        </li>
                                    <?php endforeach ?>
                                </ul>
                            </td>
                        </tr>
                    </tbody>
                </table>
            <?php endforeach ?>
            <!-- END PG MULTI  -->
            <!-- START PG COUPLE  -->
            <?php foreach ($uv['pgcouple'] as $pgck => $pgcv) : ?>
                <table width="100%" border="0">
                    <tbody>
                        <tr>
                            <td width="30px" valign="top">
                                <p><?= $pgindex++ ?></p>
                            </td>
                            <td valign="top">
                                <?= str_replace("../../../", "../../../../", $pgcv['question']) ?>
                            </td>
                        </tr>
                        <tr>

                            <td width="30px">&nbsp;</td>
                            <td>JAWABAN :
                                <br>
                                <table width="100%" border="0">
                                    <tbody>
                                        <tr>
                                            <td width="2%">&nbsp;</td>
                                            <!-- Start Question -->
                                            <td width="49%">
                                                <ol>
                                                    <?php foreach ($pgcv['responses'] as $sck => $o) : ?>
                                                        <li class="pgi"><?= str_replace("../../../", "../../../../", $o[0]) ?>
                                                        </li>
                                                        <br>
                                                    <?php endforeach ?>
                                                </ol>
                                            </td>
                                            <!-- End Question -->
                                            <!-- Start Option -->
                                            <td width="49%">
                                                <ol>
                                                    <?php foreach ($pgcv['responses'] as $sck => $o) : ?>
                                                        <li class="pgi"><?= str_replace("../../../", "../../../../", $o[1]) ?>
                                                        </li>
                                                        <br>
                                                    <?php endforeach ?>
                                                </ol>
                                            </td>
                                            <!-- End Option -->
                                        </tr>
                                    </tbody>
                                </table>
                                </ul>
                            </td>
                        </tr>
                    </tbody>
                </table>
            <?php endforeach ?>
            <!-- END PG COUPLE -->
            <!-- START PG TRUE FALSE -->
            <?php foreach ($uv['pgtf'] as $pgtfk => $pgtfv) : ?>
                <table width="100%" border="0">
                    <tbody>
                        <tr>
                            <td width="30px" valign="top">
                                <p><?= $pgindex++ ?></p>
                            </td>
                            <td valign="top">
                                <?= str_replace("../../../", "../../../../", $pgtfv['question']) ?>
                            </td>
                        </tr>
                        <tr>

                            <td width="30px">&nbsp;</td>
                            <td>JAWABAN :
                                <br>
                                <table width="100%" border="0">
                                    <tbody>
                                        <tr>
                                            <td width="2%">&nbsp;</td>
                                            <!-- Start Question -->
                                            <td width="49%">
                                                <ol>
                                                    <?php foreach ($pgtfv['responses'] as $sck => $o) : ?>
                                                        <li class="pgi"><?= str_replace("../../../", "../../../../", $o[0]) ?>
                                                        </li>
                                                        <br>
                                                    <?php endforeach ?>
                                                </ol>
                                            </td>
                                            <!-- End Question -->
                                            <!-- Start Option -->
                                            <td width="49%">
                                                <ol>
                                                    <?php foreach ($pgtfv['responses'] as $sck => $o) : ?>
                                                        <li class="pgi"><?= $o[1] == 1 ? "BENAR" : "SALAH" ?>
                                                        </li>
                                                        <br>
                                                    <?php endforeach ?>
                                                </ol>
                                            </td>
                                            <!-- End Option -->
                                        </tr>
                                    </tbody>
                                </table>
                                </ul>
                            </td>
                        </tr>
                    </tbody>
                </table>
            <?php endforeach ?>
            <!-- END PG TRUE FALSE -->
            <br>
        <?php endif; ?>

        <?php if (count($uv['shortentry']) > 0) : ?>
            <h3 class="panel-title">
                <b><?= $v['index']['text'][$v['index']['num']++] ?>. Soal Isian Singkat</b>
            </h3>
            <?php foreach ($uv['shortentry'] as $sek => $sev) : ?>
                <table width="100%" border="0">
                    <tbody>
                        <tr>
                            <td width="30px" valign="top">
                                <p><?= $sek + 1 ?></p>
                            </td>
                            <td valign="top">
                                <?= str_replace("../../../", "../../../../", $sev['question']) ?>
                            </td>
                        </tr>
                        <tr>
                            <td width="30px">&nbsp;</td>
                            <td>JAWABAN : <?= $sev['respond'] ?></td>
                        </tr>
                    </tbody>
                </table>
            <?php endforeach ?>
            <br>
        <?php endif; ?>

        <?php if (count($uv['esai']) > 0) : ?>
            <h3 class="panel-title">
                <b><?= $v['index']['text'][$v['index']['num']++] ?>. Soal Esai</b>
            </h3>
            <?php foreach ($uv['esai'] as $sek => $sev) : ?>
                <table width="100%" border="0">
                    <tbody>
                        <tr>
                            <td width="30px" valign="top">
                                <p><?= $sek + 1 ?></p>
                            </td>
                            <td valign="top">
                                <?= str_replace("../../../", "../../../../", $sev['question']) ?>
                            </td>
                        </tr>
                        <tr>
                            <td width="30px">&nbsp;</td>
                            <td>JAWABAN : <?= str_replace("../assets/img/jawaban", "../../../../assets/img/jawaban", $sev['esai'] ?? '') ?></td>
                        </tr>
                    </tbody>
                </table>
            <?php endforeach ?>
            <br>
        <?php endif; ?>


    <?php endforeach ?>

</body>

</html>