
<?php $__env->startSection('title'); ?> পরীক্ষার শিট | TESTPAPER <?php $__env->stopSection(); ?>
<?php $__env->startSection('exam-sheet'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('exam-sheet.index'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('styles'); ?>
<style>
    ul li {
        list-style: none;
    }

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


<?php $__env->startSection('main_content_section'); ?>
<div class="row py-3 ps-2">
    <div class="heading d-flex justify-content-start align-items-center">
        <h3 class="mb-0"><span> সম্পাদন পরীক্ষার শিট</span></h3>
    </div>
</div>

<!-- BEGIN: Content-->
<div class="app-content content ">
    <form action="<?php echo e(route('exam-sheet.update',$singleExamSheetData->id)); ?>" method="post" enctype="multipart/form-data">
        <?php echo csrf_field(); ?>
        <div class="card">
            <div class="card-body">
                <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
                    <div class="row">

                        <div class="col-md-6 mb-3">
                            <div class="form-group custom-select2-form">
                                <label for="name">পরীক্ষা <span class=" text-danger">(required)</span> </label>
                                <select id="examId" name="exam_id" class="form-select select2">
                                    <option value="" selected disabled> পরীক্ষা সিলেক্ট করুন </option>
                                    <?php if($exams != null): ?>
                                    <?php $__currentLoopData = $exams; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$exam): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    
                                    <option value="<?php echo e($exam->id); ?>" <?php echo e($exam->id == $singleExamSheetData->exam_id ? "selected":""); ?>>
                                        <?php echo e($exam->exam_name); ?></option>
                                    
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php endif; ?>
                                </select>
                            </div>

                            <?php $__errorArgs = ['exam_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class=text-danger><?php echo e($message); ?></span>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="col-md-6 mb-3">
                            <div class="form-group custom-select2-form">
                                <label for="name">প্রশ্ন <span class=" text-danger">(required)</span> </label>
                                <select id="questionsId" name="question_id" class="form-select select2"
                                    onchange="addQuestion()">
                                    <option value="" selected disabled> প্রশ্ন সিলেক্ট করুন </option>

                                    <?php $__currentLoopData = $questions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$question): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($question->id); ?>"><?php echo $question->question; ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>

                            <?php $__errorArgs = ['question_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <span class=text-danger><?php echo e($message); ?></span>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                    </div>

                </div>
            </div>
        </div>

        <div class="card">
            <div class="row">
                <div class="content-area-wrapper">
                    <div class="content-right w-100">
                        <div class="content-wrapper">
                            <div class="content-header row">
                            </div>
                            <div class="content-body">
                                <div class="body-content-overlay"></div>
                                <!-- Email list Area -->
                                <div class="email-app-list">

                                    <!-- Email actions starts -->
                                    <div class="app-action">
                                    </div>
                                    <!-- Email actions ends -->

                                    <!-- Email list starts -->
                                    <div class="email-user-list">
                                        <ul class="email-media-list mt-3" id="updateExanSheetQuestion">

                                            <?php $__currentLoopData = $examSheetData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php if(isset($item) && $item != null): ?>
                                            <li class="media p-2">
                                                <div class="row">
                                                    <div class="col-md-6 my-auto">
                                                        <div class="media-left custom-media-left">
                                                            <h4 class="mb-25 ">
                                                                #Id:<?php echo e($item->questionData->question_unique_id); ?></h4>
                                                            <h4 class="mb-25 d-flex">Question : <?php echo $item->questionData->question; ?></h4>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6 my-auto">
                                                        <div class="media-body text-left">
                                                            <div class="mail-details custom-mail-details">
                                                                <div class="mail-items">
                                                                    <p class="fw-bold mb-1">Options:</p>
                                                                    <span class="text-truncate pl-5"
                                                                        style="padding-right: 20px;">1.
                                                                        <?php echo e($item->questionData->question_answer1); ?>

                                                                    </span>
                                                                    <span class="text-truncate pl-5"
                                                                        style="padding-right: 20px;">2.
                                                                        <?php echo e($item->questionData->question_answer2); ?>

                                                                    </span><br>
                                                                    <span class="text-truncate pl-5"
                                                                        style="padding-right: 20px;">3.
                                                                        <?php echo e($item->questionData->question_answer3); ?>

                                                                    </span>
                                                                    <span class="text-truncate pl-5"
                                                                        style="padding-right: 20px;">4.
                                                                        <?php echo e($item->questionData->question_answer4); ?>

                                                                    </span>
                                                                </div>
                                                                <span
                                                                    class="mail-date action-icon my-auto text-end custom-remove-icon">
                                                                    <a href="#"
                                                                        onclick="questionRemove(<?php echo e($item->question_id); ?>)">
                                                                        <i
                                                                            class="material-symbols-outlined text-danger">delete</i>
                                                                    </a>
                                                                </span>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>
                                            <?php endif; ?>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                        </ul>
                                    </div>
                                    <!-- Email list ends -->
                                </div>
                                <!--/ Email list Area -->


                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-12 pb-3 pr-3">
                    <button type="submit" class="btn btn btn-success m-0 py-2 custom-float-right">সম্পাদন</button>
                </div>
            </div>
        </div>
    </form>

</div>
<!-- END: Content-->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>

<script>
    $(document).ready(function(){
        $("#examId").select2();
        $("#questionsId").select2();
    });

    //To add questions in exam sheet...
    function addQuestion() {

        var examId = $("#examId").val();
        var questionId = $("#questionsId").val();

        var url = "<?php echo e(route('add-exam-sheet-question-for-update')); ?>";
        if (examId != null) {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({
                type: 'post',
                url: url,
                data: {
                    examId: examId,
                    questionId: questionId,
                },
                success: function (data) {
                    if (data.error) {
                        alert(data.error);
                        toastr.error(data.error);
                    } else {
                        $("#updateExanSheetQuestion").html(data);
                    }
                }
            });
        }
    }


    //remove question exam id wise....
    function questionRemove(id) {

        var questionId = id;
        var examId = $("#examId").val();

        var url = "<?php echo e(route('remove-question-data-exam-wise')); ?>";
        if (questionId != null) {
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $.ajax({
                type: 'post',
                url: url,
                data: {
                    examId: examId,
                    questionId: questionId,
                },
                success: function (data) {
                    if (data.error) {
                        alert(data.error);
                        toastr.error(data.error);
                    } else {
                        $("#updateExanSheetQuestion").html(data);
                    }
                }
            });
        }
    }
</script>


<script>
    $(document).ready(function () {
        //To get all the questions with examId...
        $("#examId").change(function () {
            var examId = $(this).val();
            var url = "<?php echo e(route('get-questions-with-examId')); ?>";
            if (examId != '') {
                $.ajaxSetup({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                });
                $.ajax({
                    type: 'post',
                    url: url,
                    data: {
                        examId: examId
                    },
                    success: function (data) {
                        $("#questionsId").empty();
                        $("#questionsId").html(data);
                    }

                });
            }
        });


    });

</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.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/admin/examSheet/edit.blade.php ENDPATH**/ ?>