
<?php $__env->startPush('style'); ?>
 

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<?php $__env->stopPush(); ?>
<?php $__env->startSection('content'); ?>
<style>
   .form-group input[type=file] {
    opacity: 1;
    position: unset;
    margin-bottom: 0px !important;
    height: 46px;
}  
 .questionlist {
                margin:4px, 4px;
                padding:4px;
                /*background-color: green;*/
                /*width: 500px;*/
                height: 140px;
                overflow-x: hidden;
                overflow-y: auto;
                text-align:justify;
            }
</style>
<?php //echo "<pre>";
// print_r($question);
  $optionslist=json_decode($question->options,true);
  $optionno=count($optionslist);
   $qtags=explode(',',$question->tags);
 ?>

<script type="text/javascript">
            jQuery(document).ready(function ()
            {
                    jQuery('select[name="category"]').on('change',function(){
                       var categoryID = jQuery(this).val();
                       if(categoryID)
                       {
                          jQuery.ajax({
                             url : "<?php echo e(url('gettagcategories')); ?>/"+categoryID,
                             type : "GET",
                             dataType : "json",
                             success:function(data)
                             {
                                console.log(data);
                                if(data.length == 0 ){

                                }
                                jQuery('#tags').empty();
                                 if(data.length == 0 ){
                                  $('#tags').append('<option value="">No data Found</option>');
                                }
                                jQuery.each(data, function(key,value){
                                   $('#tags').append('<option value="'+ key +'">'+ value +'</option>');
                                });
                             }
                          });
                       }
                       else
                       {
                          $('select[name="tags"]').empty();
                       }
                    });
            });
             function categorytagonchange(){
   

    var catid=$('select[name="category"]').val();
    var tagid=$('#tags').val();
    
    if(catid!=''){
      if(tagid==""){
        var tagid="0";
      }
       $.ajax
      ({
      type:'post',
      url:"<?php echo e(url('get_questionscount')); ?>",
      data:{
       "catid":catid,
       "tagid":tagid,
       "_token": "<?php echo e(csrf_token()); ?>",
      },
      dataType: "json",
      success:function(data) {
      
      $('.test').html(data.countques);
      $('.questionlist').html(data.avaques);
      }
      });
    }
     
    
  }
            </script>
<script type="text/javascript">
  //alert('srr');
  function generateoption($value){
    

   var inputoption =$('#question_type').find('option:selected').attr('inputoption');
  
   if(inputoption=="text"){
     var inp="textbox";
   }else{
    var inp=inputoption;
   }
  var text ="<input type='hidden' class='form-control' value='"+inp+"'; name='optiontype'>";
    if($value!='' && inputoption!=''){
     // <?php $optionno?>
     ans='';

     $s=1;

     for (i = $s; i <= $value; i++) {
       if(inputoption=="textbox"){

        text +='<div class="col-md-6"><div class="form-group"><label for="">Option '+i+'</label><input type="text" class="form-control" name="options[]" value="<?php echo e(old('A')); ?>" placeholder="Option '+i+'" required></div></div>';
       }else{
        text +='<div class="col-md-6"><div class="form-group"><label for="">Option '+i+'</label><input type="file" name="options[]"  placeholder="Option '+i+'" required></div></div>';
        
       }
     ans +='<option value="option'+i+'">option'+i+'</option>';
    console.log(ans);
    }
    $("#option").html(text);

    $('#ans').html(ans);
    }
  
  }
  
    
  
</script>
<div class="container">
    <div class="row">
        <div class="col-md-12">

          <?php if(session()->has('message')): ?>
            <p class="btn btn-success btn-block btn-sm custom_message text-left"><?php echo e(session()->get('message')); ?></p>
          <?php endif; ?>
        <div class="card">  
            <div class="card-header">
                    <h5 class="title">Edit Questions</h5>
                    
                </div>
            <div class="card-body">
            
     <form action="<?php echo e(route('updatequestion',$question->id)); ?>" method="post"  enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
            <?php echo method_field('patch'); ?>
            <div class="form-group">
              <label for="">Questions</label>
              <input type="text" class="form-control" name="question" value="<?php echo e($question->question); ?>" placeholder="Enter question" >
              <font style="color:red"> <?php echo e($errors->has('question') ?  $errors->first('question') : ''); ?> </font>
            </div>
            <div class="row">
            <div class="col-md-6">
             <div class="form-group">
              <label for="">Question Type</label>
              <select  class="form-control select2" name="question_type" id="question_type">
              <?php if(!empty($questions_categories)): ?>
                                    <?php $__empty_1 = true; $__currentLoopData = $questions_categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $questcat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <option value="<?php echo e($questcat->id); ?>" inputoption="<?php echo e($questcat->input_option); ?>" <?php echo e(($question->question_type==$questcat->id) ? 'selected' : ''); ?>><?php echo e($questcat->question_category); ?></option>
                                    

                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <option value="">No data found</option>
                                    <?php endif; ?>
                                <?php endif; ?>
                
              </select>
              <font style="color:red"> <?php echo e($errors->has('question_type') ?  $errors->first('question_type') : ''); ?> </font>
            </div>
            </div>
             <div class="col-md-6">
             <div class="form-group">
              <label for="">Weightage Type</label>
              <select  class="form-control select2" name="weightage_type">
              <option value="">Select</option>
                <?php if(!empty($weightages)): ?>
                                    <?php $__empty_1 = true; $__currentLoopData = $weightages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $weightage): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <option value="<?php echo e($weightage->id); ?>" <?php echo e(($question->weightage_type==$weightage->id) ? 'selected' : ''); ?>><?php echo e($weightage->weightage_title); ?></option>
                                    

                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <option value="">No data found</option>
                                    <?php endif; ?>
                                <?php endif; ?>
              </select>
              <font style="color:red"> <?php echo e($errors->has('weightage_type') ?  $errors->first('weightage_type') : ''); ?> </font>
            </div>
            </div>
           
            
            </div>
            <div class="row">
             <div class="col-md-6">
             <div class="form-group">
              <label for="">Category</label>
              <select  class="form-control select2" name="category"  onchange="categorytagonchange()">
              <option value="">Select</option>
              <?php if(!empty($categories)): ?>
                                    <?php $__empty_1 = true; $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <option value="<?php echo e($category->id); ?>" <?php echo e(($question->category==$category->id) ? 'selected' : ''); ?>><?php echo e($category->category_name); ?></option>
                                    

                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <option value="">No data found</option>
                                    <?php endif; ?>
                                <?php endif; ?>
                
              </select>
              <font style="color:red"> <?php echo e($errors->has('category') ?  $errors->first('category') : ''); ?> </font>
            </div>
            <div class="test" style="color:green;"></div>
            </div>
            <div class="col-md-6">
             <div class="form-group">
              <label for="">Tags</label>
              <select  class="form-control select2" name="tags[]"  id="tags" multiple=""  onchange="categorytagonchange()">
              <option value="">Select Category first</option>
             
                <?php if(!empty($tagcategories)): ?>
                                    <?php $__empty_1 = true; $__currentLoopData = $tagcategories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tag): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <option value="<?php echo e($tag->id); ?>" <?php if (in_array($tag->id, $qtags)) {
   echo "selected";
} ?>><?php echo e($tag->name); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <option value="">No data found</option>
                                    <?php endif; ?>
                                <?php endif; ?>                    
              </select>
              <font style="color:red"> <?php echo e($errors->has('tags') ?  $errors->first('tags') : ''); ?> </font>
            </div>
            </div>
             <div class="col-md-12">
             <div class="questionlist"></div>
            </div>
            <div class="col-md-6">
             <div class="form-group">
              <label for="">No of Option </label>
                <!--    <?php echo e($editoption=json_decode($question->option_no,'true')); ?> --> 
                 
               <input type="number" class="form-control" name="" id="option_no"  onchange="generateoption(this.value)"  min="1" placeholder="No of Option" required value="<?php echo e($optionno); ?>">
               
              
            </div>
            </div>
            </div>
            <!-- <div id="divoptionedit">
            <div class="row">
             <div class="col-md-4">
              <label><b>Updated Options</b></label>
              </div>
              </div>
              
            </div> -->
            <div id="divoption">
             <!-- <div class="row">
             <div class="col-md-4">
              <label><b>New Options</b></label>
              </div>
              </div> -->
              <div class="row" id="option">
            <input type='hidden' class='form-control' value='<?php echo e($question->optiontype); ?>'; name='optiontype'>
           

      <input type="hidden" class="form-control" value="" name="oldoptions">
             
                 <?php if(!empty($optionslist)): ?>
                                    <?php $__empty_1 = true; $__currentLoopData = $optionslist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$op): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?> 

              <div class="col-md-6">

              <div class="form-group">
              <label for=""><?php echo e($key); ?></label><br>
              <?php if($question->optiontype=="text"){?>
              <br>
               <input type="text" class="form-control" name="options[]" value="<?php echo e($op); ?>" placeholder="<?php echo e($key); ?>" required>    
              <?php }else if($question->optiontype=="audio"){?>
                <br><audio controls>
  <source src="<?php echo e(url('/public/images/').'/'.$op); ?>" type="audio/ogg" >
  <source src="<?php echo e(url('/public/images/').'/'.$op); ?>" type="audio/mpeg" >
  Your browser does not support the audio tag.
</audio>
            <?php  }else{?>
              <img src="<?php echo e(url('/public/images/').'/'.$op); ?>" alt="image" width="200px" height="200px">
              <?php } ?>
              </div>
              </div>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <div class="no">No data found</div>
                                    <?php endif; ?>
                                <?php endif; ?>
            
              </div>
            </div>
            
              <div class="row">
            <div class="col-md-6">
             <div class="form-group">
              <label for="">Answer</label>
              <select class="form-control" name="ans" id="ans" value="" placeholder="Answer" >
              <?php if(!empty($optionslist)): ?>
                                    <?php $__empty_1 = true; $__currentLoopData = $optionslist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$op): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <option value="<?php echo e($key); ?>" <?php echo e(($question->ans==$key) ? 'selected' : ''); ?>><?php echo e($key); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                        <div class="no">No data found</div>
                                    <?php endif; ?>
                                <?php endif; ?>
              </select>
               
              <font style="color:red"> <?php echo e($errors->has('ans') ?  $errors->first('ans') : ''); ?> </font>
            </div>
            </div>
            <div class="col-md-6">
             <div class="form-group">
              <label for="">Notes</label>
              <textarea  class="form-control" name="notes" style="border: 1px solid #2825255e;border-color: #2b3553;
    border-radius: 0.4285rem;">
               <?php echo e($question->notes); ?>

              </textarea>
               
              <font style="color:red"> <?php echo e($errors->has('notes') ?  $errors->first('notes') : ''); ?> </font>
            </div>
            </div>
            <div class="col-md-6">
             <div class="form-group">
              <label for="">Explanation</label>
              <textarea  class="form-control" name="explanation" required="" id="explanation" style="border: 1px solid #2825255e;border-color: #2b3553;
    border-radius: 0.4285rem;
"><?php echo e($question->explanation); ?>

               
              </textarea>
               
              <font style="color:red"> <?php echo e($errors->has('explanation') ?  $errors->first('explanation') : ''); ?> </font>
            </div>
            </div>

            <div class="col-md-6">
            
            <div class="form-group">
              <label for="wrong answer audio">Audio(wrong answer audio)</label><br>
              <?php if(!empty($question->wrong_ans_audio)){
              $wop=$question->wrong_ans_audio;
               ?>
            <audio controls>
  <source src="<?php echo e(url('/public/questions_wrong_ans_audio/').'/'.$wop); ?>" type="audio/ogg" >
  <source src="<?php echo e(url('/public/questions_wrong_ans_audio/').'/'.$wop); ?>" type="audio/mpeg" >
  Your browser does not support the audio tag.
</audio>
<input type="hidden" name="oldwrong_ans_audio" value="<?php echo $wop?>">
 <?php } ?>
              <input type="file" name="wrong_ans_audio" class="form-control" accept="audio/*" placeholder="wrong answer audio">

              </div>
            </div>
            </div>
            <div class="form-group" style="margin-top: 24px;">
              <input type="submit" class="btn btn-primary" value="Submit">
            </div>

          </form>
          </div>
          </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', ['pageSlug' => 'weightage'], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/sibzsolu/public_html/training/stimclex/resources/views/questions/editquestions.blade.php ENDPATH**/ ?>