
<?php $__env->startSection('style'); ?>
    <style>
        .card {
            background: white;
            padding: 25px;
            border-radius: 10px;
            max-width: 700px;
            margin: auto;
        }

        .option {
            width: 100%;
            margin-top: 10px;
            padding: 14px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            background: #2563eb;
            color: white;
            text-align: left;
            font-size: 15px;
        }

        .option:hover {
            background: #1d4ed8;
        }
    </style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <?php if(session('error')): ?>

        <div class="alert alert-danger">

            <?php echo e(session('error')); ?>


        </div>

    <?php endif; ?>
    <!-- START SECTION TOP -->
    <section class="section-top"
        style="background-image: url(assets/img/bg/section-top.png);background-size:cover; background-position: center center;">
        <div class="container">
            <div class="row">
                <div class="col-lg-12 col-sm-12 col-xs-12 text-center">
                    <div class="section-top-title">
                        <h1>Bank Kasus</h1>
                    </div>
                </div><!--- END COL -->
            </div><!--- END ROW -->
        </div><!--- END CONTAINER -->
    </section>
    <!-- END SECTION TOP -->
    <section id="portfolio" class="portfolio_area section-padding">
        <div class="card">

            <h5>
                <?php echo e($case->title); ?>

            </h5>
            <hr>
            <h4>Data yang Terkumpul</h4>
            <?php echo e($alur); ?>

            <hr>
            <button class="option" onclick="jawab('A', <?php echo e($alternatif->score_a); ?> )">
                A.
                <?php echo e($alternatif->pertanyaan_a); ?>

            </button>

            <button class="option" onclick="jawab('B', <?php echo e($alternatif->score_b); ?> )">
                B.
                <?php echo e($alternatif->pertanyaan_b); ?>

            </button>

            <button class="option" onclick="jawab('C', <?php echo e($alternatif->score_c); ?> )">
                C.
                <?php echo e($alternatif->pertanyaan_c); ?>

            </button>

            <button class="option" onclick="jawab('D', <?php echo e($alternatif->score_d); ?> )">
                D.
                <?php echo e($alternatif->pertanyaan_d); ?>

            </button>
            <input type="hidden" id="caseId" value="<?php echo e($case->id); ?>">
            <input type="hidden" id="sesi" value="<?php echo e($sesi); ?>">

        </div>
    </section>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
    <script>

        function jawab(answer, score) {

            const caseId = document.getElementById('caseId').value;
            const sesi = document.getElementById('sesi').value;
            fetch('/quiz/alternatif-submit', {

                method: 'POST',

                headers: {

                    'Content-Type': 'application/json',

                    'X-CSRF-TOKEN':
                        '<?php echo e(csrf_token()); ?>'
                },

                body: JSON.stringify({
                    alternatif_id: <?php echo e($alternatif->id); ?>,
                    jawaban: answer,
                    score: score,
                    caseId: caseId,
                    sesi: sesi
                })

            })
                .then(res => res.json())
                .then(data => {

                    Swal.fire({
                        text: data.respon,
                        icon: data.icon,
                        confirmButtonText: "Lanjutkan",
                    }).then((result) => {
                        /* Read more about isConfirmed, isDenied below */
                        window.location.href = "/quiz/puzzle/" + caseId + "?sesi=" + sesi;
                    });

                });
        }

    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('user.layouts.v_template', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\Yudi\WEB\project\a\project_learning\resources\views/user/quiz/quiz2.blade.php ENDPATH**/ ?>