
<?php $__env->startSection('title'); ?> প্রশ্ন <?php $__env->stopSection(); ?>
<?php $__env->startSection('question'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('question.index'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('styles'); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('admin_content'); ?>
    <!-- BEGIN: Content-->
    <div class="app-content content ">
        <div class="card">



            <div class="card-header p-1">
                <div class="head-label">
                    <h4>প্রশ্ন এডিট</h4>
                </div>
            </div>

            <?php if($data->chapter_id != null): ?>

            <div class="card-body">
                <form action="<?php echo e(route('question.update', $data->id)); ?>" method="post" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('put'); ?>
                    <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
                        <div class="">
                            <div class="row border rounded">
            
                                <div class="col-md-6 col-12 p-1">
                                    <div class="row">
            
                                        <div class="col-md-6 col-12 mb-2">
                                            <div class="form-group">
                                                <label for="name">শ্রেণীর নাম <span class=" text-danger">(required)</span> </label>
                                                <select id="classname_id" name="classname_id" class="form-select select2">
                                                    <option selected disabled> শ্রেণী সিলেক্ট করুন </option>
                                                    <?php $__currentLoopData = $classes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $class): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <option value="<?php echo e($class->id); ?>"
                                                        <?php echo e($class->id == $data->classname_id ? "selected":""); ?>><?php echo e($class->class_name); ?>

                                                    </option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                            </div>
                                            <?php $__errorArgs = ['classname_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 col-12 mb-2">
                                            <div class="form-group">
                                                <label for="department_id">বিভাগের নাম <span class=" text-danger">(required)</span>
                                                </label>
                                                <select id="department_id" name="department_id" class="form-select select2">
                                                    <option disabled> বিভাগ সিলেক্ট করুন </option>
                                                    <option selected="" value="<?php echo e($data->department_id); ?>">
                                                        <?php echo e($data->departmentData->department_name); ?></option>
                                                </select>
                                            </div>
                                            <?php $__errorArgs = ['department_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 col-12 mb-2">
                                            <div class="form-group">
                                                <label for="subject_id">বিষয়ের নাম <span class=" text-danger">(required)</span>
                                                </label>
                                                <select id="subject_id" name="subject_id" class="form-select select2">
                                                    <option disabled> বিষয় সিলেক্ট করুন </option>
            
                                                    <option selected="" value="<?php echo e($data->subject_id); ?>">
                                                        <?php echo e($data->subjectData->subject_name); ?></option>
            
                                                </select>
                                            </div>
                                            <?php $__errorArgs = ['subject_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 col-12 mb-2">
                                            <div class="form-group">
                                                <label for="chapter_id">অধ্যায়ের নাম <span class=" text-danger">(required)</span>
                                                </label>
                                                <select id="chapter_id" name="chapter_id" class="form-select select2">
                                                    <option selected disabled> অধ্যায় সিলেক্ট করুন </option>
            
                                                    <option selected="" value="<?php echo e($data->chapter_id); ?>">
                                                        <?php echo e($data->chapterData->chapter_name); ?></option>
            
                                                </select>
                                            </div>
                                            <?php $__errorArgs = ['chapter_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 class="col-md-6 col-12 p-1" style="border-left: 1px solid #EBE9F1">
                                    <div class="rounded p-2">
                                        <div class="media flex-column flex-md-row custom-question-image-body" style="display: flex;">
                                    
                                            <?php if($data->image != null): ?>
                                            <img src="<?php echo e(asset('uploads/question/thumbnail/'.$data->image)); ?>" id="blog-feature-image"
                                                class="rounded mr-2 mb-1 mb-md-0 custom-question-image" width="170" height="110" alt="Blog Featured Image">
                                            <?php else: ?>
                                            <img src="<?php echo e(asset('backend/app-assets/images/subject_logo.JPG')); ?>" id="blog-feature-image"
                                                class="rounded mr-2 mb-1 mb-md-0 custom-question-image" width="170" height="110" alt="Blog Featured Image">
                                            <?php endif; ?>
                                            <div class="media-body" style="margin-left: 15px;">
                                                <p class="my-50">
                                    
                                                </p>
                                                <div class="d-inline-block custom-question-image-block">
                                                    <div class="form-group mb-0">
                                                        <div class="custom-file">
                                                            <input type="file" name="image" class="custom-file-input" id="blogCustomFile" accept="image/*">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
            
            
                        <div class="row">
            
                            <div class="form-group mt-2">
                                <label for="tag_id">ট্যাগের নাম <span class=" text-danger">(required)</span> </label>
                                <select id="tag_id" name="tag_id[]" class="form-control select2" multiple>
                                    <?php $__currentLoopData = $tags; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tag): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($tag->id); ?>" <?php echo e(in_array($tag->id,$tagIds) ? "selected":""); ?>><?php echo e($tag->tag_name); ?>

                                    </option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
            
            
                            <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 mt-2">
                                <div class="form-group">
                                    <label for="name">প্রশ্ন <span class=" text-danger">(required)</span> </label>
                                    <textarea class=" form-control" name="question" id="post_description" cols="20" rows="5"
                                        placeholder=" Post Description"><?php echo $data->question; ?></textarea>
                                </div>
            
                                <?php $__errorArgs = ['question'];
$__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-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 mt-2">
                                <div class="row">
                                    
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name">ক <span class=" text-danger">(required)</span> </label>
                                            <input class="form-control" name="question_answer1" id="question_answer1" required
                                                placeholder="ঊত্তর" onblur="questionAnswer1()" value="<?php echo e($data->question_answer1); ?>">
                                        </div>
                                    </div>
            
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name">খ <span class=" text-danger">(required)</span></label>
                                            <input class="form-control" name="question_answer2" id="question_answer2" required
                                                placeholder="ঊত্তর" onblur="questionAnswer2()" value="<?php echo e($data->question_answer2); ?>">
                                        </div>
                                    </div>
            
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name">গ <span class=" text-danger">(required)</span> </label>
                                            <input class="form-control" name="question_answer3" id="question_answer3" required
                                                placeholder="ঊত্তর" onblur="questionAnswer3()" value="<?php echo e($data->question_answer3); ?>">
                                        </div>
                                    </div>
            
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name">ঘ <span class=" text-danger">(required)</span></label>
                                            <input class="form-control" name="question_answer4" id="question_answer4" required
                                                placeholder="ঊত্তর" onblur="questionAnswer4()" value="<?php echo e($data->question_answer4); ?>">
                                        </div>
                                    </div>
                                    
                                </div>
            
                                <div class="row align-items-center" style="margin-top:20px">
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name"> সঠিক উত্তর <span class=" text-danger">(required)</span></label>
                                            <select class="form-control" name="right_answer" id="right_answer">
                                                <option value="">Select Answer</option>
                                                <?php $__currentLoopData = $rightAnswerData; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if($item != null): ?>
                                                        <option selected value="<?php echo e($item); ?>" <?php echo e($data->right_answer == $item ? 'selected' : ''); ?>><?php echo e($item); ?></option>
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                        </div>
                                    </div>
            
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name" style="margin-top: 10px">সঠিক ঊত্তরঃ <span
                                                    id="rightAnswerShow"><?php echo e($data->right_answer); ?></span> </label>
                                        </div>
                                    </div>
                                </div>
            
            
                                <?php $__errorArgs = ['post_description'];
$__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-12 col-sm-12 col-md-2 col-lg-2 col-xl-2 d-flex align-items-center"
                                style="margin-top: 35px;">
                                <input type="submit" name="submit" class="btn btn btn-success" value="Update">
                            </div>
            
                        </div>
            
                    </div>
                </form>
            </div>

            <?php else: ?>

            <div class="card-body">
                <form action="<?php echo e(route('question.update', $data->id)); ?>" method="post" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('put'); ?>
                    <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
            
            
                        <div class="row">
            
                            <div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 mt-2">
                                <div class="form-group">
                                    <label for="name">প্রশ্ন <span class=" text-danger">(required)</span> </label>
                                    <textarea class=" form-control" name="question" id="post_description" cols="20" rows="5"
                                        placeholder=" Post Description"><?php echo $data->question; ?></textarea>
                                </div>
            
                                <?php $__errorArgs = ['question'];
$__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-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 mt-2">
                                <div class="row">
                                    
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name">ক <span class=" text-danger">(required)</span> </label>
                                            <input class="form-control" name="question_answer1" id="question_answer1" required
                                                placeholder="ঊত্তর" onblur="questionAnswer1()" value="<?php echo e($data->question_answer1); ?>">
                                        </div>
                                    </div>
            
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name">খ <span class=" text-danger">(required)</span></label>
                                            <input class="form-control" name="question_answer2" id="question_answer2" required
                                                placeholder="ঊত্তর" onblur="questionAnswer2()" value="<?php echo e($data->question_answer2); ?>">
                                        </div>
                                    </div>
            
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name">গ <span class=" text-danger">(required)</span> </label>
                                            <input class="form-control" name="question_answer3" id="question_answer3" required
                                                placeholder="ঊত্তর" onblur="questionAnswer3()" value="<?php echo e($data->question_answer3); ?>">
                                        </div>
                                    </div>
            
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name">ঘ <span class=" text-danger">(required)</span></label>
                                            <input class="form-control" name="question_answer4" id="question_answer4" required
                                                placeholder="ঊত্তর" onblur="questionAnswer4()" value="<?php echo e($data->question_answer4); ?>">
                                        </div>
                                    </div>
                                    
                                </div>
            
                                <div class="row align-items-center" style="margin-top:20px">
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name"> সঠিক উত্তর <span class=" text-danger">(required)</span></label>
                                            <select class="form-control" name="right_answer" id="right_answer">
                                                <option value="">Select Answer</option>
                                                <option selected value="<?php echo e($data->right_answer); ?>"><?php echo e($data->right_answer); ?></option>
                                            </select>
                                        </div>
                                    </div>
            
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label for="name" style="margin-top: 10px">সঠিক ঊত্তরঃ <span
                                                    id="rightAnswerShow"></span> </label>
                                        </div>
                                    </div>
                                </div>
            
            
                                <?php $__errorArgs = ['post_description'];
$__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-12 col-sm-12 col-md-2 col-lg-2 col-xl-2 d-flex align-items-center"
                                style="margin-top: 35px;">
                                <input type="submit" name="submit" class="btn btn btn-success" value="Save">
                            </div>
            
                        </div>
            
                    </div>
                </form>
            </div>

            <?php endif; ?>

        </div>

    </div>
    <!-- END: Content-->
    <script type="text/javascript">
      
      function questionAnswer1() {
            var question_answer1 = $("#question_answer1").val();
            var question_answer2 = $("#question_answer2").val();
            var question_answer3 = $("#question_answer3").val();
            var question_answer4 = $("#question_answer4").val();
            
            var rightAnswer = [];
            //To check...
            if(question_answer1 != ''){
                rightAnswer = [
                    question_answer1
                ];
            }
            if(question_answer2 != ''){
                rightAnswer = [
                    question_answer1, question_answer2
                ];
            }
            
            if(question_answer3 != ''){
                rightAnswer = [
                    question_answer1, question_answer2, question_answer3
                ];
            }
            
            if(question_answer4 != ''){
                rightAnswer = [
                    question_answer1, question_answer2, question_answer3, question_answer4
                ];
            }
            
            
            $("#right_answer").empty();
            $("#right_answer").append('<option value="" selected disabled>সঠিক ঊত্তর সিলেক্ট করুন</option>');
            $.each(rightAnswer, function(key, value) {
                $('select[id="right_answer"]').append('<option value="' + value + '">' + value + '</option>');
            });
        }
        
        function questionAnswer2() {
            var question_answer1 = $("#question_answer1").val();
            var question_answer2 = $("#question_answer2").val();
            var question_answer3 = $("#question_answer3").val();
            var question_answer4 = $("#question_answer4").val();
            
            var rightAnswer = [];
            //To check...
            if(question_answer1 == ''){
                alert('Right answer 1 fillup at first.!');
                $("#question_answer2").val('');
            }else{
                if(question_answer1 != ''){
                    rightAnswer = [
                        question_answer1
                    ];
                }
                if(question_answer2 != ''){
                    rightAnswer = [
                        question_answer1, question_answer2
                    ];
                }
                
                if(question_answer3 != ''){
                    rightAnswer = [
                        question_answer1, question_answer2, question_answer3
                    ];
                }
                
                if(question_answer4 != ''){
                    rightAnswer = [
                        question_answer1, question_answer2, question_answer3, question_answer4
                    ];
                }
                
                $("#right_answer").empty();
                $("#right_answer").append('<option value="" selected disabled>সঠিক ঊত্তর সিলেক্ট করুন</option>');
                $.each(rightAnswer, function(key, value) {
                    $('select[id="right_answer"]').append('<option value="' + value + '">' + value + '</option>');
                });
            }
        }
       
        function questionAnswer3() {
            var question_answer1 = $("#question_answer1").val();
            var question_answer2 = $("#question_answer2").val();
            var question_answer3 = $("#question_answer3").val();
            var question_answer4 = $("#question_answer4").val();
            
            var rightAnswer = [];
            //To check...
            if(question_answer1 == ''){
                alert('Right answer 1 fillup at first.!');
            }
            
            if(question_answer2 == ''){
                alert('Right answer 2 fillup at first.!');
                $("#question_answer3").val('');
            }else{
                if(question_answer1 != ''){
                    rightAnswer = [
                        question_answer1
                    ];
                }
                if(question_answer2 != ''){
                    rightAnswer = [
                        question_answer1, question_answer2
                    ];
                }
                
                if(question_answer3 != ''){
                    rightAnswer = [
                        question_answer1, question_answer2, question_answer3
                    ];
                }
                
                if(question_answer4 != ''){
                    rightAnswer = [
                        question_answer1, question_answer2, question_answer3, question_answer4
                    ];
                }
                
                $("#right_answer").empty();
                $("#right_answer").append('<option value="" selected disabled>সঠিক ঊত্তর সিলেক্ট করুন</option>');
                $.each(rightAnswer, function(key, value) {
                    $('select[id="right_answer"]').append('<option value="' + value + '">' + value + '</option>');
                });
            }
        }
        
        function questionAnswer4() {
            var question_answer1 = $("#question_answer1").val();
            var question_answer2 = $("#question_answer2").val();
            var question_answer3 = $("#question_answer3").val();
            var question_answer4 = $("#question_answer4").val();
            
            var rightAnswer = [];
            //To check...
            if(question_answer1 == ''){
                alert('Right answer 1 fillup at first.!');
            }
            
            if(question_answer2 == ''){
                alert('Right answer 2 fillup at first.!');
            }
            
            if(question_answer3 == ''){
                alert('Right answer 3 fillup at first.!');
                $("#question_answer4").val('');
            }else{
                if(question_answer1 != ''){
                    rightAnswer = [
                        question_answer1
                    ];
                }
                if(question_answer2 != ''){
                    rightAnswer = [
                        question_answer1, question_answer2
                    ];
                }
                
                if(question_answer3 != ''){
                    rightAnswer = [
                        question_answer1, question_answer2, question_answer3
                    ];
                }
                
                if(question_answer4 != ''){
                    rightAnswer = [
                        question_answer1, question_answer2, question_answer3, question_answer4
                    ];
                }
                
                $("#right_answer").empty();
                $("#right_answer").append('<option value="" selected disabled>সঠিক ঊত্তর সিলেক্ট করুন</option>');
                $.each(rightAnswer, function(key, value) {
                    $('select[id="right_answer"]').append('<option value="' + value + '">' + value + '</option>');
                });
                $("#right_answer").select2();
            }
        }

        function rightAnswerSelect() {
            var right_answer = $("#right_answer").val();
            
            if (right_answer != "") {
                $("#rightAnswerShow").empty();
                $("#rightAnswerShow").text(right_answer);
            }
        }

      // function right_answer
      // -------------------
      $('select[name="right_answer"]').on('change', function(){
          var right_answer = $(this).text();
          alert(right_answer);
          if(right_answer!=""){
            $("#rightAnswerShow").empty();
            $("#rightAnswerShow").text(right_answer);
          }

      });
      // -------------------

    </script>

    <?php echo $__env->make('admin.post.partial.script', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<?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\testpaper-final\resources\views/admin/question/edit.blade.php ENDPATH**/ ?>