@extends('admin.admin-master')
@section('content')
<div>&nbsp; </div>
<div>&nbsp; </div>
<h3><i class="fa fa-question-circle"></i> Manage Quiz Questions </h3>
<div>&nbsp; </div>
<div class="col-md-12">
    <div class="col-md-6">
        <!--- Form started ---->
        {{Form::open(array('url'=>'/admin/save-quiz',
                    'class'=>'form-horizontal',
                    'id'=>'add_quiz_form',
                    'method'=>'POST'
                    ))}}
        <fieldset>
            <!-- Form Name -->
            <legend>Add new question</legend>
            <!-- Text input-->
            <div class="control-group">
                <label class="control-label" for="textinput"> Quiz :</label>
                <div class="controls">
                    {{Form::text('quiz','',array('id'=>'textinput','class'=>'form-control input-sm','placeholder'=>'Quiz text'))}}
                </div>
            </div>
            <div class="clearfix">&nbsp;</div>
            <div class="row">
                <div class="col-lg-9">
                    <?php
                    $listOfValue = array();
                    $listOfValue[0] = 'Select group';
                    ?>
                    @foreach($quiz_group as $op)
                    <?php

                    $listOfValue[$op->group_id] = $op->group_name;
                    ?>
                    @endforeach
                    {{Form::select('quiz_group',$listOfValue,'',array('id'=>'quiz_group','class'=>'form-control input-sm'))}}
                </div>
                <div class="visible-sm visible-md">&nbsp; &nbsp;</div>
                <div class="col-lg-3">
                    <div class="control-group">
                        <div class="controls">
                            {{Form::button('<i class="fa fa-edit"></i> Add Option',array('class'=>'btn btn-warning btn-sm btn-block','id'=>'add_quiz_opt','type'=>'button'))}}
                        </div>
                    </div>
                </div>
            </div>

            <div class="clearfix optn-rmv">&nbsp;</div>
            <div class="input-group optn-rmv">
                <span class="input-group-addon">
                    {{Form::radio('addoptn',0)}}
                </span>
                {{Form::text('option_text[]','',array('class'=>'form-control input-sm opt','placeholder'=>'Quiz Option'))}}
                <span class="input-group-addon btn" onclick="removeOpt($(this))">
                    <i class="fa fa-times"></i>
                </span>
            </div><!-- /input-group -->
            <div class="clearfix optn-rmv">&nbsp;</div>
            <div class="input-group optn-rmv">
                <span class="input-group-addon">
                    {{Form::radio('addoptn',1)}}
                </span>
                {{Form::text('option_text[]','',array('class'=>'form-control input-sm opt','placeholder'=>'Quiz Option'))}}
                <span class="input-group-addon btn" onclick="removeOpt($(this))">
                    <i class="fa fa-times"></i>
                </span>
            </div><!-- /input-group -->

            <div class="clearfix quiz-append">&nbsp;</div>
            <!-- Button -->
            <div class="control-group">
                <label class="control-label" for="singlebutton"></label>
                <div class="controls">
                    {{Form::button('Reset',array('class'=>'btn btn-default btn-sm','type'=>'reset','id'=>'reset_quiz_form'))}}
                    {{Form::button('<i class="fa fa-save"></i> Save quiz',array('name'=>'save_quiz','id'=>'save_quiz','class'=>'btn btn-info btn-sm','type'=>'button' ))}}
                    <span class="quiz-loader"></span>
                </div>
            </div>
        </fieldset>
        {{Form::close()}}
        <!--- // End Form started ---->
    </div>
    <div class="col-md-6">
        <fieldset>
            <!-- Form Name -->
            <div class="row">
                <div class="col-md-5"></div>
                <div class="col-md-2 text-right"><b>Filter:</b></div>
                <div class="col-md-5 text-right">
                    {{Form::select('quiz_group',$listOfValue, (Input::get('group_id')!='')?Input::get('group_id'):0,array('id'=>'quiz_group_filter','class'=>'form-control input-sm'))}}
                    <br>
                    <script>
                        $('#quiz_group_filter').change(function() {
                            filter_group_id = $(this).val();
                            window.location = '/admin/manage-quiz?group_id='+filter_group_id;
                        });
                    </script>
                </div>

            </div>

            <legend> Question List </legend>
            <table class="table table-hover table-condensed">
                <tr><th>Quiz </th><th> Group </th> <th> <center> Action </center> </th></tr>
                @foreach($quiz_list as $q)
                <tr id="{{$q->id}}">
                    <td>{{$q->text}} </td>
                    <td> {{$q->group_name}} </td>
                    <td nowrap>
                <center>
                    {{Form::button('<span class="tip" data-toggle="tooltip" data-placement="bottom" title="Edit quiz"><i class="fa fa-edit"></i></span>',array('class'=>'btn btn-info btn-sm edit_quiz','data-toggle'=>'modal','data-target'=>'#myModal','href'=>'#', 'data-quiz-id'=>$q->id, 'path'=>'/admin/edit-quiz/'.$q->id))}}
                    &nbsp;
                    {{Form::button('<span class=""><i class="fa fa-times"></i></span>',array('class'=>'btn btn-danger btn-sm delete_quiz', 'href'=>'#', 'path'=>'' ,'data-quiz-id'=>$q->id, 'data-toggle'=>'tooltip', 'data-placement'=>'bottom', 'title'=>'Delete quiz'))}}
                </center>
                </td>
                </tr>
                @endforeach
            </table>
            <center>{{$quiz_list->appends(Input::all())->links()}}</center>
        </fieldset>
    </div>
</div>
<!-- Modal --->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Update new quiz</h4>
            </div>
            <div class="modal-body quiz-form">
            </div>
            <p class="">&nbsp;</p>
        </div>
    </div>
</div>

<!---// Modal -->
@stop
