@extends('admin.layouts.app')

@section('header-script')
@include('admin.layouts.datatable-header')
@endsection


@section('content')
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.20/js/dataTables.bootstrap.min.js"></script>


<!-- Page-Title -->
<div class="col-md-12">
    <div class="col-md-12 pd-0">
        <div class="u-shadow-v21 nbr g-bg-white rounded notice-board  mg-0 wow slideInUp" data-wow-duration="3s">
            <div class="media g-mb-15">
                <div>
                    <div class="bar-title" style="text-align:center">
                        <h1><a href=""><span> প্রশ্ন ব্যাংক
                                </span></a></h1>
                    </div>
                    <h1><a href="{{url('admin/quistionsprint')}}"><span> Question Print</span></a></h1>
                    <table id="example" class="table table-dark">
                        <thead>
                            <tr>
                                <th scope="col">SL</th>
                                <th scope="col"> Round</th>
                                <th scope="col"> Question Type</th>
                                <th scope="col"> Episode Name</th>
                                <th scope="col"> Question Name</th>
                                <th scope="col"> Link</th>
                                <th scope="col"> Time</th>
                                <th scope="col"> Right Answer</th>
                                <th scope="col"> Points</th>
                                <th scope="col">Image</th>
                                <th scope="col">Edit</th>
                                <th scope="col">Delete</th>
                                <th scope="col">Available</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $i = 0; ?>
                            @if(count($quistions) > 0)

                            @foreach($quistions as $quistion)
                            <tr>
                                <?php $i+=1; ?>
                                <th scope="row">{{$i}}</th>
                                <td>{{$quistion->round_id}}</td>
                                <td> @if($quistion->question_type == 1)
                                    ট্রেক্সট
                                    @elseif($quistion->question_type == 2)
                                    ছবি
                                    @elseif($quistion->question_type == 3)
                                    অডিও
                                    @else
                                    ভিডিও
                                    @endif

                                </td>
                                <td>{{$quistion->episode_name}}</td>
                                <td>{{$quistion->question_name}}</td>
                                <td>
                                    @if($quistion->link == '')
                                    No Media File in this Question
                                    @else
                                    <iframe width="100" height="60" src="{{ $quistion->link }}}" frameborder="0"
                                        allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
                                        allowfullscreen></iframe>

                                    @endif

                                </td>
                                <td>{{$quistion->time}} Sec</td>
                                <td>
                                    <?php
                                         if($quistion->option_num==0){
                                             echo $quistion->na_answer;
                                         }else{
                                         
                                         ?>
                                         
                                         @if($quistion->right_answer == 'op_1') {{$quistion->op_1 }}
                                         @elseif($quistion->right_answer == 'op_2') {{$quistion->op_2 }}
                                         @elseif($quistion->right_answer == 'op_3') {{$quistion->op_3 }}
                                         @else($quistion->right_answer == 'op_4') {{$quistion->op_4 }}
                                         @endif
                                         <?php } ?>
                                </td>
                                <td>{{$quistion->points}}</td>
                                <td>
                                    <div>
                                        <img src="{{ URL::to('public/images/' . $quistion->qus_media)}}" width="100"
                                            height="60" alt="image not found" />
                                        </a>

                                    </div>
                                </td>
                                <td>
                                    <a href="{{url('admin/quistion')}}/{{$quistion->id}}/edit"
                                        class="btn btn-danger btn-sm">
                                        <span class="glyphicon glyphicon-edit"> </span> Edit
                                    </a>
                                </td>
                                <td>
                                    <form class="form-horizontal" enctype="multipart/form-data" method="POST"
                                        action="{{action('AdminController@quistiondelete', $quistion->id)}}">
                                        {{ csrf_field() }}
                                        <a href="{{url('admin/quistion')}}/{{$quistion->id}}/delete"
                                            class="btn btn-danger btn-sm">
                                            <span class="glyphicon glyphicon-trash"> </span>
                                        </a>
                                    </form>
                                </td>
                                <td>

                                    {!! Form::open(['action' => ['AdminController@statusupdate',
                                    $quistion->id],
                                    'method'=> 'POST']) !!}
                                    {!! Form::hidden('status', 1)!!}


                                    {!! Form::hidden('_method', 'POST') !!}
                                    @if($quistion->status == 0)
                                    <button class="btn btn-danger" type="submit"> unavailble
                                    </button>

                                    @else<button class="btn btn-success" type="submit">available
                                    </button>
                                    @endif

                                    {!! Form::close() !!}

                                </td>


                            </tr>
                            @endforeach
                            @else
                            <tr>
                                <td> No Data Found</td>
                            </tr>
                            @endif
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

    </div>
</div>
</div>
<script>
    $(document).ready(function() {
    $('#example').DataTable();
} );
    </script>

<!-- end row -->
@endsection

@section('footer-script')
@include('admin.layouts.datatable-footer-script')
@endsection