
<?php $__env->startSection('title'); ?> Exam Page List <?php $__env->stopSection(); ?>
<?php $__env->startSection('styles'); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('frontend_content'); ?>

<div class="container h-100 mt-2">
    <div class="nav custom-transfer-acccount-tab gap-2 btn-no-color nav-tabs mb-3" id="nav-tab" role="tablist">
        <button class="primary_btn nav-link active w-100 d-flex"type="button" role="tab">
            <span class="custom-exam-heading-title-left">পরীক্ষার প্রশ্ন পত্র</span>
            <span id="countdown" class="custom-question-heading-time">সময়: <span id="timer" class="text-warning fw-bolder"></span></span>
        </button>
    </div>

    <form method="POST" action="<?php echo e(route('webuser.add-exam-paper')); ?>" class="d-inline">
        <?php echo csrf_field(); ?>

        <?php $__currentLoopData = $examSheetData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php if(isset($item) && $item != null): ?>
                <div class="card p-2 custom-post-list-card mb-3 book">
                    <input type="hidden" name="user_id" value="<?php echo e(Auth::user()->id); ?>">
                    <input type="hidden" name="exam_id" value="<?php echo e($singleExamData->id); ?>">
                    <input type="hidden" name="exam_question_id[]" value="<?php echo e($item->question_id); ?>">

                    <?php
                        // For question title...
                        $tagRemovalQuestionTitle = strip_tags($item->questionData->question);
                        $originalQuestionTitle = preg_replace("/\s|&nbsp;/"," ",$tagRemovalQuestionTitle);   
                    ?>
                    <p class="custom-question-title"><strong class="d-flex"> <?php echo e($key+1); ?>) <?php echo e($originalQuestionTitle); ?></strong></p>
                    <div class="options">
                        <div class="d-flex align-items-center gap-2">
                            <input type="radio" name="right_answer[<?php echo e($item->question_id); ?>]" id="question_answer1<?php echo e($item->question_id); ?>" value="<?php echo e($item->questionData->question_answer1); ?>"> 
                            <label for="question_answer1<?php echo e($item->question_id); ?>">a) <?php echo e($item->questionData->question_answer1); ?></label>
                        </div>
                        <div class="d-flex align-items-center gap-2">
                            <input type="radio" name="right_answer[<?php echo e($item->question_id); ?>]" id="question_answer2<?php echo e($item->question_id); ?>" value="<?php echo e($item->questionData->question_answer2); ?>"> 
                            <label for="question_answer2<?php echo e($item->question_id); ?>">b) <?php echo e($item->questionData->question_answer2); ?></label>
                        </div>
                        <div class="d-flex align-items-center gap-2">
                            <input type="radio" name="right_answer[<?php echo e($item->question_id); ?>]" id="question_answer3<?php echo e($item->question_id); ?>" value="<?php echo e($item->questionData->question_answer3); ?>"> 
                            <label for="question_answer3<?php echo e($item->question_id); ?>">c) <?php echo e($item->questionData->question_answer3); ?></label>
                        </div>
                        <div class="d-flex align-items-center gap-2">
                            <input type="radio" name="right_answer[<?php echo e($item->question_id); ?>]" id="question_answer4<?php echo e($item->question_id); ?>" value="<?php echo e($item->questionData->question_answer4); ?>"> 
                            <label for="question_answer4<?php echo e($item->question_id); ?>">d) <?php echo e($item->questionData->question_answer4); ?></label>
                        </div>
                    </div>
                </div>
            <?php endif; ?>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

        <div class="condition mt-3">
            <button type="submit" class="primary_btn mb-0">Submit Exam Paper</button>
        </div>

        
        <div class="modal fade" id="submitExamPaper" tabindex="-1" aria-hidden="true" data-backdrop="static" data-keyboard="false">
            <div class="modal-dialog modal-dialog-centered mw-850px alert-modal">
                <div class="modal-content rounded">
        
                    <div class="modal-body scroll-y pt-0 pb-15">
                        <div class="text-center mb-4 pt-2">
                            <h3 class="text-danger">Time Up!</h3>
                            <hr>
                            <p>Sorry, Your exam duration time already over please submit your exam paper to get result. Thanks</h4>
                        </div>
                        <div class="text-center">
                            <button type="submit" class="btn btn-primary mb-0">Submit Exam Paper</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </form>

</div>

<div class="action d-flex flex-column gap-2">
    <span class="material-symbols-outlined">
        download
    </span>
    <span class="material-symbols-outlined">
        done_all
    </span>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

    

    <script>
        const startTimeStr = '<?php echo e($singleExamData->end_time); ?>'; // Parse the start time from the Blade variable
        const startTime = new Date();
        const [hours, minutes, seconds] = startTimeStr.split(':');
        startTime.setHours(parseInt(hours), parseInt(minutes), parseInt(seconds), 0);
        const examDuration = <?php echo e($singleExamData->exam_duration); ?> * 1000;

        function updateTimer() {
            const currentTime = new Date();
            const elapsedTime = currentTime - startTime;
            const remainingTime = Math.max(examDuration - elapsedTime, 0);

            const hours = Math.floor(remainingTime / 3600000);
            const minutes = Math.floor((remainingTime % 3600000) / 60000);
            const seconds = Math.floor((remainingTime % 60000) / 1000)

            if (remainingTime <= 0) {
                document.getElementById('timer').textContent = 'Time is up!';
                clearInterval(timerInterval);
                toastr.error('Sorry, Your exam time is over!');
                //To shown the times up modal...
                $("#submitExamPaper").modal({
                    backdrop: 'static',
                    keyboard: false
                });
                
                $('#submitExamPaper').modal('show');
            } else {
                document.getElementById('timer').textContent = `${hours}:${minutes}:${seconds.toString().padStart(2, '0')}`;
            }
        }

        // Update timer initially and then every second
        updateTimer();
        const timerInterval = setInterval(updateTimer, 1000);
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('frontend.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH E:\Project\Personal-Project\Office-Project\update\test-paper-final\resources\views/frontend/exam/getExamSheetDataForSWE.blade.php ENDPATH**/ ?>