
<?php $__env->startSection('title'); ?> প্রশ্ন | TESTPAPER <?php $__env->stopSection(); ?>
<?php $__env->startSection('question.create'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('question.create'); ?> active <?php $__env->stopSection(); ?>
<?php $__env->startSection('styles'); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('main_content_section'); ?>

<!-- BEGIN: Content-->
<div class="main-content overflow-x-hidden">
                    
    <div class="row py-3 ps-2">
        <div class="heading d-flex justify-content-start heading-margin-bottom-minus">
          <h3 class="mb-0 pb-0"><span>সম্পাদন প্রশ্ন</span><span> <a class="heading-font" href="<?php echo e(route('admin.dashboard')); ?>"> । এডমিন</a></span></h3> 
        </div>
      </div>


    <!-- form start -->
    <div class="form min-vh-100">
        <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="row row-gap-2">
                <div class="col-xl-7 ">
                    <div class="card shadow h-100">
                                <div class="tinymce_text_editor p-3">
                                    <div class="form_add_new_post"> 
                                        <label for="post_title" class="form-label fs-4">প্রশ্ন <span class="fs-5 text-danger">(আবশ্যক)</span></label>
                                        <textarea name="question" id="post_title" cols="30" rows="5" class="form-control"><?php echo $data->question; ?></textarea>
                                        <span id="warnTextDesc1" class="text-danger warn d-none">Heading is required</span>
                                    </div>

                                    
                                </div>
                                <div class="text_input p-3">

                                  <div class="row mt-3 row-gap-3">
                                      <div class="col-md-6">
                                      <span>ক <span class="text-danger">(আবশ্যক)</span></span>
                                      <input onblur="questionAnswer1()" type="text" class="form-control mt-2" id="question_answer1" name="question_answer1" value="<?php echo e($data->question_answer1); ?>" required>
                                      <span id="question_answer1" class="d-none"><small class=" text-danger">Require This Filed</small></span>
                                      </div>
                                      <div class="col-md-6">
                                      <span>খ <span class="text-danger">(আবশ্যক)</span></span> 
                                      <input onblur="questionAnswer2()" type="text" class="form-control mt-2" id="question_answer2" name="question_answer2" value="<?php echo e($data->question_answer2); ?>" required>
                                      <span id="question_answer2" class="d-none"><small class=" text-danger">Require This Filed</small></span>
                                      </div>
                                      <div class="col-md-6">
                                      <span>গ <span class="text-danger">(আবশ্যক)</span></span>
                                      <input onblur="questionAnswer3()" type="text" class="form-control mt-2" id="question_answer3" name="question_answer3" value="<?php echo e($data->question_answer3); ?>" required>
                                      <span id="question_answer3" class="d-none"><small class=" text-danger">Require This Filed</small></span>
                                      </div>
                                      <div class="col-md-6">
                                      <span>ঘ <span class="text-danger">(আবশ্যক)</span></span>
                                      <input onblur="questionAnswer4()" type="text" class="form-control mt-2" id="question_answer4" name="question_answer4" value="<?php echo e($data->question_answer4); ?>" required>
                                      <span id="question_answer4" class="d-none"><small class=" text-danger">Require This Filed</small></span>
                                      </div>
                                  </div>

                                  <div class="row align-items-center" style="margin-top:20px">
                                    <div class="col-md-6"> 
                                        <div class="form-group">
                                            <label for="name"> সঠিক উত্তর <span class=" text-danger">(আবশ্যক)</span>
                                            </label>
                                            <select class="form-control" name="right_answer" id="right_answer"
                                                onchange="rightAnswerSelect()" required>
                                                <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-6">
                                        <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>
                                </div>
                    </div>
                </div>

                

                <div class="col-xl-5">
                    <div class="card shadow p-4  h-100">
                        <div class="card">
                            <div class="card-header">
                              <div class="d-flex align-items-center justify-content-between card_header_1">
                                <h4 class="dash-title fw-normal">প্রাতিষ্ঠানিক অংশ</h4>
                                <span class="dropdown-toggle"></span>
                              </div>
                            </div>
            
                            <div id="card_body_2" class="" >
                                <div class="row card-body row-cols-lg-2 row-gap-2">
                                        <div class="col-md-6 filter_options mb-2">
                                            <div id="warperSelect_3" class="search_wrapper">
                                                <div class="title">
                                                <p class="mb-0">শ্রেণির নাম <span class="text-danger">(আবশ্যক)</span></p>
                                                </div>
                                                <select class="form-control js-example-tags" name="classname_id" onchange="classWiseDeptForCreate()" required id="classname_id">
                                                  <option value="" selected disabled> শ্রেণি সিলেক্ট করুন </option>
                                                  <?php $__currentLoopData = $classes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                  <option value="<?php echo e($item->id); ?>"
                                                      <?php echo e($item->id == $data->classname_id ? "selected":""); ?>>
                                                      <?php echo e($item->class_name); ?>

                                                  </option>
                                                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                            </div>
                                        </div>
            
                                        <div class="col-md-6 filter_options mb-2">
                                            <div id="warperSelect" class="search_wrapper">
                                                <div class="title">
                                                    <p class="mb-0">বিভাগের নাম  <span class="text-danger">(আবশ্যক)</span></p>
                                                </div>
                                                <select class="form-control js-example-tags" name="department_id" id="department_id"  onchange="deptWiseSubForCreate()" required>
                                                  <option value="" selected disabled> বিভাগ সিলেক্ট করুন </option>
                                                  <option selected="" value="<?php echo e($data->department_id); ?>">
                                                    <?php echo e($data->departmentData->department_name); ?></option>
                                                </select>
                                            </div>
                                        </div>                                            
                                        <div class="col-md-6 filter_options">
                                            <div id="warperSelect_4" class="search_wrapper">
                                                    <div class="title">
                                                    <p class="mb-0">বিষয়ের নাম  <span class="text-danger">(আবশ্যক)</span></p>
                                                    </div>
                                                    <select class="form-control js-example-tags" name="subject_id" id="subject_id" onchange="subWiseSubForCreate()" required>
                                                      <option value="" selected disabled> বিষয় সিলেক্ট করুন </option>
                                                      <option selected="" value="<?php echo e($data->subject_id); ?>">
                                                        <?php echo e($data->subjectData->subject_name); ?></option>
                                                    </select>
                                            </div>
                                        </div>
                
                                        <div class="col-md-6 filter_options">
                                            <div id="warperSelect_9" class="search_wrapper">
                                                <div class="title">
                                                <p class="mb-0">অধ্যায়ের নাম   <span class="text-danger">(আবশ্যক)</span></p>
                                                </div>
                                                <select class="form-control js-example-tags" name="chapter_id" id="chapter_id"  required>
                                                  <option value="" selected disabled> অধ্যায় সিলেক্ট করুন </option>
                                                  <option selected="" value="<?php echo e($data->chapter_id); ?>">
                                                    <?php echo e($data->chapterData->chapter_name); ?></option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                            </div>
                        </div>

                        <div class="card mt-3">
                            <div onclick="" class="card-header">
                                <div class="d-flex align-items-center justify-content-between">
                                <h4 class="dash-title fw-normal">ট্যাগ</h4>
                                <span class="dropdown-toggle"></span>
                                </div>
                            </div>
                            <div id="card_body_7" class="card-body py-2">
                                <select class="form-control js-example-tags" name="tag_id[]" multiple required> 
                                    <option value="" disabled> ট্যাগ সিলেক্ট করুন </option>
                                    <?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>

                        <div class="card mt-3">
                            <div onclick="" class="card-header">
                                <div class="d-flex align-items-center justify-content-between">
                                <h4 class="dash-title fw-normal">সাল</h4>
                                <span class="dropdown-toggle"></span>
                                </div>
                            </div>
                            <div id="card_body_7" class="card-body py-2">
                                <select class="form-control js-example-tags" name="question_session[]" multiple required>
                                    <option value="" disabled> সাল সিলেক্ট করুন </option>
                                    <?php $__currentLoopData = $questionSession; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($item->id); ?>" <?php echo e(in_array($item->id,$questionIds) ? "selected":""); ?>>
                                        <?php echo e($item->session_name); ?>

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

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


                        <div class="row mt-4">
                            <div class="col-sm-6">
                              <div class="card h-100">
                                <div  class="card-header">
                                  <div class="d-flex align-items-center justify-content-between">
                                    <h4 class="dash-title fw-normal">ছবি</h4>
                                    <span class="dropdown-toggle"></span>
                                  </div>
                                </div>
                                <div id="card_body_5" class="card-body my-2 mb-3 position-relative">
                                  <div class="select_imgWith_preview" >
                                    <?php if(isset($data->image) && $data->image != null): ?>
                                    <img id="uploadPreview" src="<?php echo e(asset('uploads/question/thumbnail/'.$data->image)); ?>">
                                    <?php else: ?>
                                    <img id="uploadPreview" src="<?php echo e(asset('backend/template-assets/images/img_preview.png')); ?>">
                                    <?php endif; ?>
                                    <input id="uploadImage" type="file" name="image" onchange="PreviewImage('uploadImage','uploadPreview')"/>
                                    <span onclick="cancelPreview('uploadImage','uploadPreview')" class="material-symbols-outlined" id="image_remove_buttton"> close </span>
                                  </div>
                                  <!-- <button class="btn table_button py-2 mt-2">Publish</button> -->
                                </div>
                              </div> 
                            </div>
                            <div class="col-sm-6 publish_section">
                              <div class="card h-100">
                                <div  class="card-header">
                                  <div class="d-flex align-items-center justify-content-between">
                                    <h4 class="dash-title fw-normal">প্রকাশ</h4>
                                     <span class="dropdown-toggle"></span>
                                  </div>
                                </div>
                
                                <div id="card_body_x" class="card-body">
                                    
                                    <div class="my-2">
                                      <p class="fs-7"><span class="material-symbols-outlined"> key </span>Status: <strong>Draft</strong> <a   href="javascript:void(0)" class="text-primary" onclick="slideToggleControl('edit_content')">Edit</a></p>
                                      <div  id="edit_content" class="d-none-content">
                                        <div class= gap-1 align-items-center">
                                          <select name="edit" id="edit" class="ms-2">
                                                <option value="pending">Pending Review</option>
                                                <option value="draft">Draft</option>
                                          </select>
                                          <div class="d-flex mt-2 ">
                                            
                                          </div>
                                        </div>
                                      </div>
                                      <p class="fs-7"><span class="material-symbols-outlined"> visibility </span> Visibility: <strong>Public</strong> <a onclick="slideToggleControl('vis_content')" href="javascript:void(0)" class="text-primary">Edit</a></p>
                                      <div id="vis_content" class="d-none-content">
                                        <div class="radio_option ms-2">
                                              <label class="option_input">
                                                <input type="radio" name="screen_columns" value="public">
                                               Public	
                                              </label>
                                              <br>
                                            <label class="option_input">
                                              <input type="radio" name="screen_columns" value="pass">
                                              Password protected	
                                            </label>
                                            <br>
                                            <label class="option_input">
                                              <input type="radio" name="screen_columns" value="private">
                                              Private	
                                            </label>
                                        </div>
                                        <div class="d-flex gap-1 align-items-center mt-2">
                                          
                                        </div>
                                      </div>
                
                                      <p class="fs-7"><span class="material-symbols-outlined"> calendar_month </span> Publish : <strong>immediately </strong> <a  onclick="slideToggleControl('publish')" href="javascript:void(0)" class="text-primary">Edit</a></p>
                
                                      <div id="publish" class="d-none-content" >
                                        <div class="d-flex gap-2 ms-2">
                                          <input type="date" placeholder="YYYY-MM-DD" name="date" id="date" class="form-control">
                                          <input type="time" placeholder="01:12 PM" class="form-control">
                                        </div>
                                        <div class="d-flex gap-1 align-items-center my-2">
                                          
                                        </div>
                                      </div>
                
                                      <div class="card-footer p-0 d-flex justify-content-center border-0">
                                        <button  type="submit" class="btn table_button py-2 m-0 btn-outline-primary w-100" onclick="return validate()">প্রকাশ</button> 
                                      </div>
                                    </div>
                                </div>
                              </div> 
                            </div>
                          </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <!-- form end  -->
</div>
<!-- END: Content-->

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

<?php $__env->startSection('scripts'); ?>
     <!-- tinymce text editor -->
     <script src="<?php echo e(asset('backend/template-assets/js/tinymce.min.js')); ?>"></script>
     <script src="<?php echo e(asset('backend/template-assets/js/custom_tinymce.js')); ?>"></script>


     <script>
        function validate(){
            if ((tinymce.EditorManager.get('post_title').getContent()) == ''){
              document.getElementById('warnTextDesc1').classList.add('active')
              return false;
          }
          //   if ((tinymce.EditorManager.get('post_description').getContent()) == '') {
          //     document.getElementById('warnTextDesc2').classList.add('active')
          //     return false;
          // }
        };

        // function answerShow(){
        //   $value = $('#answer_option_text_x').val();
        //   $('#answer_option_text_x_show').text($value);
        // }


    //To get class wise depertment...

    function classWiseDeptForCreate(){
    var classname_id = $("#classname_id").val();
    // alert(classname_id);
    if(classname_id){
      $.ajax({
        url: "<?php echo e(url('/get_department/')); ?>/" + classname_id,
        type:"GET",
        dataType:"json",
        success:function(data){
          $("#department_id").empty();
          $("#department_id").append('<option value="" selected disabled>বিভাগ সিলেক্ট করুন</option>');
          $.each(data,function(key,value){
            $("#department_id").append('<option value="'+value.id+'">'+value.department_name+'</option>');
          });
        },
      });
    }  
  };


  //To get depertment wise subject...

    function deptWiseSubForCreate(){
      var department_id = $("#department_id").val();
      if(department_id){
        $.ajax({
        url: "<?php echo e(url('/get_subject/')); ?>/" + department_id,
        type:"GET",
        dataType:"json",
        success:function(data){
            $("#subject_id").empty();
            $("#subject_id").append('<option value="" selected disabled>বিষয় সিলেক্ট করুন</option>');
            $.each(data,function(key,value){
                
                $("#subject_id").append('<option value="'+value.id+'">'+value.subject_name+'</option>');
            });
          },
        });
      }  
    };


  //To get Chapter, Subject wise.

    function subWiseSubForCreate(){
      var subject_id = $("#subject_id").val();
      if(subject_id){
        $.ajax({
        url: "<?php echo e(url('/get_chapter/')); ?>/" + subject_id,
        type:"GET",
        dataType:"json",
        success:function(data){
            $("#chapter_id").empty();
            $("#chapter_id").append('<option value="" selected disabled>অধ্যায় সিলেক্ট করুন</option>');
            $.each(data,function(key,value){                
                $("#chapter_id").append('<option value="'+value.id+'">'+value.chapter_name+'</option>');
            });
          },
        });
      }  
    };



     </script>


<script>
  

  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>');
            });
            $("#right_answer").select2();
        }
        
        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 == ''){
                toastr.error('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>');
                });
                $("#right_answer").select2();
            }
        }
       
        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 == ''){
                toastr.error('Right answer 1 fillup at first.!');
            }
            
            if(question_answer2 == ''){
                toastr.error('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>');
                });
                $("#right_answer").select2();
            }
        }
        
        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 == ''){
                toastr.error('Right answer 1 fillup at first.!');
            }
            
            if(question_answer2 == ''){
                toastr.error('Right answer 2 fillup at first.!');
            }
            
            if(question_answer3 == ''){
                toastr.error('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);
            }
        }
        

</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/question/edit.blade.php ENDPATH**/ ?>