
<?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" id="nav-tab" role="tablist">
        <button class="primary_btn nav-link w-50 active" id="nav-home-tab" data-bs-toggle="tab"
            data-bs-target="#nav-home" type="button" role="tab" aria-controls="nav-home" aria-selected="true">পেনডিং
            পরীক্ষা</button>
        <button class="primary_btn nav-link w-50 " id="nav-profile-tab" data-bs-toggle="tab"
            data-bs-target="#nav-profile" type="button" role="tab" aria-controls="nav-profile"
            aria-selected="false">কমপ্লিট পরীক্ষা</button>
    </div>

    <div class="tab-content mt-3" id="nav-tabContent">
        <div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">
            <div class=" bg-white mb-2">
                <?php $__currentLoopData = $pendingExamData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if(isset($item) && $item != null): ?>
                    <?php
                        //To check user already participated or not in this exam...
                        $checkStatusForExamParticipate = App\Models\Exam::checkStatusForExamParticipate($item->id,
                        Auth::user()->id);
                    ?>
                    <?php if($checkStatusForExamParticipate == 0): ?>
                        <div class="card custom-post-list-card mb-3">
                            <div class="p-2 d-flex">
                                <div class="text-dark custom-exam-card-center">
                                    <h6>পরীক্ষা: <span class="text-primary"><?php echo e($item->exam_name); ?></span></h6>
                                    <p class="mb-0">প্রশ্ন: <span class="text-primary"><?php echo e($item->question_qty); ?> টি</span></p>
                                    <p class="mb-0">সর্বমোট: <span class="text-primary"><?php echo e($item->total_mark); ?> মার্ক</span></p>
                                    <p class="mb-0">পাস: <span class="text-primary"><?php echo e($item->pass_mark); ?> মার্ক</span></p>
                                    <p class="mb-0">সময়:
                                        <span class="text-primary">
                                            <?php echo e(Carbon\Carbon::create($item->start_time)->format('h:i')); ?> থেকে
                                            <?php echo e(Carbon\Carbon::create($item->end_time)->format('h:i')); ?> পর্যন্ত
                                        </span>
                                    </p>
                                </div>

                                <div class="d-flex text-dark custom-exam-card-right">
                                    <div class="my-auto">
                                        <?php if($item->start_date == Carbon\Carbon::now()->today()->toDateString()): ?>

                                            <h6>
                                                <span id="remainIngStart<?php echo e($item->id); ?>" class="">
                                                    পরীক্ষা: <span class="text-danger">আজকে</span> <br>
                                                    [<span class="text-dark custom-remaining-date">
                                                        শুরু: <span class="text-success fw-bolder"> <span id="timer<?php echo e($item->id); ?>">
                                                            </span></span> মিনিট পরে
                                                    </span>]
                                                </span>

                                                <a id="startExamButton<?php echo e($item->id); ?>" style="display: none;"
                                                    href="<?php echo e(route('webuser.get-exam-sheet-for-CWE', $item->id)); ?>"
                                                    class="custom-exam-start-button bg-primary">

                                                    <span class="material-symbols-outlined">
                                                        start
                                                    </span>

                                                    <span class="custom-result-shown">
                                                        শুরু করুন
                                                    </span>
                                                </a>
                                            </h6>


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

                                                function updateTimer<?php echo e($item->id); ?>() {
                                                    const currentTime<?php echo e($item->id); ?> = new Date();
                                                    const elapsedTime<?php echo e($item->id); ?> = currentTime<?php echo e($item->id); ?> - startTime<?php echo e($item->id); ?>;
                                                    const remainingTime<?php echo e($item->id); ?> = Math.max(examDuration<?php echo e($item->id); ?> - elapsedTime<?php echo e($item->id); ?>, 0);
                                                    
                                                    const hours<?php echo e($item->id); ?> = Math.floor(remainingTime<?php echo e($item->id); ?> / 3600000);
                                                    const minutes<?php echo e($item->id); ?> = Math.floor((remainingTime<?php echo e($item->id); ?> % 3600000) / 60000);
                                                    const seconds<?php echo e($item->id); ?> = Math.floor((remainingTime<?php echo e($item->id); ?> % 60000) / 1000)
                                                
                                                    if (remainingTime<?php echo e($item->id); ?> <= 0) {
                                                        document.getElementById('remainIngStart'+<?php echo e($item->id); ?>).style.display = 'none';
                                                        document.getElementById('startExamButton'+<?php echo e($item->id); ?>).style.display = 'flex';
                                                        // document.getElementById('startExamButton'+<?php echo e($item->id); ?>).textContent = 'Time is up!';
                                                        clearInterval(timerInterval<?php echo e($item->id); ?>);
                                                    } else {
                                                        document.getElementById('timer'+<?php echo e($item->id); ?>).textContent = `${hours<?php echo e($item->id); ?>}:${minutes<?php echo e($item->id); ?>}:${seconds<?php echo e($item->id); ?>.toString().padStart(2, '0')}`;
                                                    }
                                                }
                                                
                                                // Update timer initially and then every second
                                                updateTimer<?php echo e($item->id); ?>();
                                                const timerInterval<?php echo e($item->id); ?> = setInterval(updateTimer<?php echo e($item->id); ?>, 1000);
                                            </script>

                                        <?php else: ?>
                                            <h6>
                                                <?php
                                                $startDate = Carbon\Carbon::createFromFormat('Y-m-d', $item->start_date);
                                                $currentDate = Carbon\Carbon::now();
                                                $daysDifference = $currentDate->diffInDays($startDate);
                                                ?>
                                                তারিখ: <span
                                                    class="text-danger"><?php echo e(Carbon\Carbon::createFromFormat('Y-m-d', $item->start_date)->format('d-m-Y')); ?></span>
                                                <br>
                                                [<span class="text-dark custom-remaining-date">পরীক্ষা শুরুর <span
                                                        class="text-success fw-bolder"><?php echo e($daysDifference+1); ?></span> দিন বাকি</span>]

                                            </h6>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endif; ?>
                <?php endif; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>

        <div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">
            <div class=" bg-white mb-2">
                <?php $__currentLoopData = $completedExamData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if(isset($item) && $item != null): ?>
                <div class="card custom-post-list-card mb-3">
                    <div class="p-2 d-flex">
                        <div class="text-dark custom-exam-card-center">
                            <h6>পরীক্ষা: <span class="text-primary"><?php echo e($item->exam_name); ?></span></h6>
                            <p class="mb-0">প্রশ্ন: <span class="text-primary"><?php echo e($item->question_qty); ?> টি</span></p>
                            <p class="mb-0">সর্বমোট: <span class="text-primary"><?php echo e($item->total_mark); ?> মার্ক</span></p>
                            <p class="mb-0">পাস: <span class="text-primary"><?php echo e($item->pass_mark); ?> মার্ক</span></p>
                            <p class="mb-0">সময়: 
                                <span class="text-primary">
                                    <?php echo e(Carbon\Carbon::create($item->start_time)->format('h:i')); ?> থেকে
                                    <?php echo e(Carbon\Carbon::create($item->end_time)->format('h:i')); ?> পর্যন্ত
                                </span></p>
                        </div>

                        <div class="d-flex text-dark custom-exam-card-right">
                            <div class="my-auto">

                                <h6>
                                    <a href="#" class="custom-exam-start-button bg-primary d-flex">
                                        <span class="material-symbols-outlined">
                                            visibility
                                        </span>
                                        <span class="custom-result-shown">
                                            রেজাল্ট দেখুন
                                        </span>
                                    </a>
                                </h6>
                            </div>
                        </div>
                    </div>
                </div>
                <?php endif; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>

    </div>

</div>

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

<?php $__env->startSection('scripts'); ?>
<?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/chapterWiseExam/getExamTypeDataForCWE.blade.php ENDPATH**/ ?>