<!----Edit Modal Quiz Form ------>
{{Form::open(array('url'=>'/admin/update-quiz',
            'method'=>'POST',
            'class'=>'form-horizontal',
            'id'=>'update_quiz_form'))}}
<!-- Form Name -->
<!-- Text input-->
<div class="control-group">
    <label class="control-label" for="textinput"> Quiz :</label>
    <div class="controls">
        {{Form::text('quiz',isset($quiz->text)?$quiz->text:'',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">
        @foreach($quiz_group as $op)
        <?php
        $listOfValue[0] = 'Select group';
        $listOfValue[$op->group_id] = $op->group_name;
        ?>
        @endforeach
        {{Form::select('quiz_group',$listOfValue,$quiz->group_id,array('id'=>'quiz_group','class'=>'form-control input-sm'))}}
    </div>
    <div class="col-lg-3">
        <input type="hidden" name="quiz_id" value="{{$quiz_id}}">
    </div>
</div>
<div class="clearfix optn-rmv">&nbsp;</div>
@foreach($quiz_option as $optn)
<div class="input-group optn-rmv">
    <span class="input-group-addon">
        {{Form::radio('addoptn', $optn->id , ($optn->id==$quiz->ans)?'checked':'');}}
    </span>
    {{Form::text('option_text['.$optn->id.']',$optn->qtext,array('id'=>'','class'=>'form-control input-sm opt','placeholder'=>'Quiz Option'))}}
</div><!-- /input-group -->
<div class="clearfix optn-rmv">&nbsp;</div>
@endforeach
<!-- Button -->
<div class="control-group text-right">
    <label class="control-label" for="singlebutton"></label>
    <div class="controls">
        <span class="update-loader"></span>
        {{Form::button('Close',array('class'=>'btn btn-default btn-sm','data-dismiss'=>'modal'))}}
        {{Form::button('<i class="fa fa-save"></i> Update',array('id'=>'update_quiz','class'=>'btn btn-info btn-sm','type'=>'button' ))}}
    </div>
</div>
{{Form::close()}}
<!---- // End Edit Modal Quiz Form ------>
<!--- JS for form submit  --->
<script>
    $('#update_quiz').click(function()
    {
        $('#update_quiz_form').submit();
        $('.update-loader').html('');
        $('.update-loader').removeClass('animated flash');
    });
    $('#update_quiz_form').submit(function(e)
    {
        $('.update-loader').html('<i class="fa fa-spinner fa-spin"></i>');
        var action = $(this).attr('action');
        var data = $(this).serializeArray();
        $.post(action, data, function(d) {
            if (d.success == 1)
            {
                $('.update-loader').html(d.msg);
                $('.update-loader').addClass('animated flash');
            } else
            {
                $('.update-loader').html(d.msg);
            }
        });
        e.preventDefault(); // Prevent default Form submit
    });
</script>
