
<?php $__env->startSection('content'); ?>

<form action="<?php echo e(route('admin.exams.create')); ?>" method="post" enctype="multipart/form-data">
    <?php echo csrf_field(); ?>
    <div class="card">
        <div class="border-bottom card-header">
            <h4 class="card-title"><?php echo e(trans('general.create_exam')); ?></h4>
        </div>
        <div class="card-body">
            <div class="row pt-2">
                <div class=" col-md-6 col-12">
                    <div class="row">
                        <div class="col-12">
                            <div class="mb-1">
                                <label class="form-label" for="title"><?php echo e(trans('general.title')); ?></label>
                                <input required type="text" name="title" class="form-control" id="title" value="<?php echo e(old('title')? old('title') : ''); ?>">
                            </div>
                        </div>
                          <div class="col-12">
                            <div class="mb-1">
                                <label class="form-label" for="quiz_mark"><?php echo e(trans('general.quiz_mark')); ?></label>
                                <input required type="int" name="quiz_mark" class="form-control" id="quiz_mark" value="<?php echo e(old('quiz_mark')? old('quiz_mark') : ''); ?>">
                            </div>
                        </div>
                        <div class=" col-12">
                            <div class="mb-1">
                                <label class="form-label" for="divisionSelect"><?php echo e(trans('general.division')); ?></label>
                                <select required name="division_id" onchange="getDivisionLevelMaterials(this.value)" class="form-select" id="divisionSelect">
                                    <option value="">--</option>
                                    <?php $__currentLoopData = $divisions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $division): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($division->id); ?>" <?php echo e(old('division_id')? ($division->id == old('division_id')? 'selected':'') : ''); ?>>

                                        <?php echo e($division->stage); ?> |
                                        <?php echo e($division->level); ?> |
                                        <?php echo e($division->title); ?> |

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



                    </div>
                </div>
                <div class=" col-md-6 col-12">
                    <div class="mb-1">
                        <label class="form-label" for="description"><?php echo e(trans('general.description')); ?></label>
                        <textarea  name="description" class="form-control" id="description" rows="8"><?php echo e(old('description')? old('description') : ''); ?></textarea>
                    </div>
                </div>
                
                <div class=" col-md-6 col-12">
                    <div class="mb-1">
                        <label class="form-label" for="description"><?php echo e(trans('general.quiz_type')); ?></label>
                        <select required name="quiz_type" class="form-select" id="quiz_type">
                            <?php for($i = 0; $i < 5; $i++): ?>
                                <option value="<?php echo e(trans('general.quiz_type'.$i)); ?>"><?php echo e(trans('general.quiz_type'.$i)); ?></option>
                            <?php endfor; ?>
                         </select>
                    </div>
                </div>

                <div class=" col-md-6 col-12">
                    <div class="mb-1">
                        <label class="form-label" for="studyMaterialSelect"><?php echo e(trans('general.studyMaterial')); ?></label>
                        <select required name="study_material_id" class="form-select" id="studyMaterialSelect">
                            <option value="">--</option>
                            
                        </select>
                    </div>
                </div>
                <div class=" col-md-6  col-12">
                    <div class="mb-1">
                        <label class="form-label" for="date"><?php echo e(trans('general.date')); ?></label>
                        <input type="text" name="date" id="date" class="form-control flatpickr-basic" value="<?php echo e(old('date')? old('date') : ''); ?>" placeholder="YYYY-MM-DD" />
                    </div>
                </div>
            </div>
        </div>

        <div class="card-footer">
            <button type="submit" class="btn btn-primary waves-effect waves-float waves-light"><?php echo e(trans('general.save')); ?></button>
            <button type="reset" class="btn btn-outline-secondary waves-effect"><?php echo e(trans('general.reset')); ?></button>
        </div>
    </div>

</form>

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

<script src="<?php echo e(url('design')); ?>/app-assets/vendors/js/pickers/flatpickr/flatpickr.min.js"></script>
<script>
    (function(window, document, $) {
        'use strict';
        $('.flatpickr-basic').flatpickr();
    })(window, document, jQuery);



    function getDivisionLevelMaterials(division_id) {
        var jqxhr = $.ajax({
                url: "<?php echo e(route('admin.division.level.materials')); ?>",
                method: "GET",
                timeout: 0,
                data: {
                    division_id: division_id
                }
            })
            .done(function(response) {
                setMaterialsOptions(response.data);
                console.log(response);
            })
            .fail(function(response) {
                console.log(response);
                setMaterialsOptions([]);
                toastr.error(response.responseJSON.msg, '<?php echo e(trans("general.error")); ?>');
            });
    }

    function setMaterialsOptions(data) {
        var studyMaterialSelect = $('#studyMaterialSelect');
        studyMaterialSelect.html('');
        studyMaterialSelect.append($('<option>', {
            value: '',
            text: '--'
        }));
        $.each(data, function(index, val) {
            studyMaterialSelect.append($('<option>', {
                value: val.id,
                text: val.title + ' | ' + val.level
            }));
        });
    }
</script>

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

<?php $__env->startPush('header'); ?>
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/vendors/css/pickers/flatpickr/flatpickr.min.css">


<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.index', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Users\nobalaa-dev\Desktop\New folde2r\portal\resources\views/admin/exams/exams-create.blade.php ENDPATH**/ ?>