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


<!-- Responsive Datatable -->
<section id="responsive-datatable">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <form action="<?php echo e(route('admin.exams.grades.set')); ?>" method="post">
                    <?php echo csrf_field(); ?>
                    <input type="hidden" id="examId" value="<?php echo e($exam->id); ?>" name="exam_id">
                    <div class="card-header border-bottom">
                        <h4 class="card-title"><?php echo e(trans("general.exams_grades", ['exam' => $exam->title])); ?></h4>
                        <button type="submit" class="btn btn-outline-primary waves-effect">
                            <?php echo e(trans("general.save_grades")); ?>

                        </button>
                    </div>
                    <div class="card-datatable">
                        <?php echo e($dataTable->table([
                        "class" => "dt-responsive table",
                        "style" => ""
                            ])); ?>

                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<!--/ Responsive Datatable -->



<!-- Vertical modal -->
<div class="vertical-modal-ex">
    <button style="display: none;" type="button" id="addGradeModalButton" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#addGradeModal">
    </button>
    <!-- Modal -->
    <div class="modal fade" id="addGradeModal" tabindex="-1" aria-labelledby="addGradeModalTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <form onsubmit="addGrade(this); return false;">
                    <?php echo csrf_field(); ?>
                    <input type="hidden" id="gradeStudentId" name="student_id">
                    <input type="hidden" id="examId" value="<?php echo e($exam->id); ?>" name="exam_id">
                    <div class="modal-header">
                        <h5 class="modal-title" id="addGradeModalTitle"></h5>
                        <button type="button" id="dismissModalButton" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <div class="col-12">
                            <div class="mb-1">
                                <label class="form-label" for="grade"><?php echo e(trans('general.grade')); ?></label>
                                <input type="number" class="form-control" name="grade" id="grade" autofocus>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-primary" data-bs-dismiss="modal"><?php echo e(trans('general.save')); ?></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- Vertical modal end-->



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

<script src="<?php echo e(url('design')); ?>/app-assets/vendors/js/tables/datatable/jquery.dataTables.min.js"></script>
<script src="<?php echo e(url('design')); ?>/app-assets/vendors/js/tables/datatable/dataTables.bootstrap5.min.js"></script>
<script src="<?php echo e(url('design')); ?>/app-assets/vendors/js/tables/datatable/dataTables.responsive.min.js"></script>
<script src="<?php echo e(url('design')); ?>/app-assets/vendors/js/tables/datatable/responsive.bootstrap5.js"></script>
<?php echo $dataTable->scripts(); ?>


<script>
    function showAddGradeModal(student_id, student_name, grade) {
        $('#gradeStudentId').val(student_id);
        $('#addGradeModalTitle').html(student_name);
        $('#addGradeModalButton').click();
        $('#grade').val(grade);
    }

    function addGrade(element) {


        formData = $(element).serializeArray().reduce(function(obj, item) {
            obj[item.name] = item.value;
            return obj;
        }, {});

        var jqxhr = $.ajax({
                url: "<?php echo e(route('admin.exams.grades.set')); ?>",
                method: "POST",
                timeout: 0,
                data: formData
            })
            .done(function(response) {
                console.log(response);
                $('#dismissModalButton').click();
                $('#examgrades-table').DataTable().ajax.reload();
                toastr.success(response.msg);
            })
            .fail(function(response) {
                console.log(response);
                toastr.error(response.responseJSON.msg, '<?php echo e(trans("general.error")); ?>');
            });

    }
</script>
<?php $__env->stopPush(); ?>

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


<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/vendors/css/vendors-rtl.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/vendors/css/tables/datatable/dataTables.bootstrap5.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/vendors/css/tables/datatable/responsive.bootstrap5.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/vendors/css/pickers/flatpickr/flatpickr.min.css">



<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/bootstrap.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/bootstrap-extended.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/colors.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/components.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/themes/dark-layout.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/themes/bordered-layout.css">
<link rel="stylesheet" type="text/css" href="<?php echo e(url('design')); ?>/app-assets/css-rtl/themes/semi-dark-layout.css">


<style>
    table.dataTable>thead .sorting:before,
    table.dataTable>thead .sorting_asc:before,
    table.dataTable>thead .sorting_desc:before,
    table.dataTable>thead .sorting_asc_disabled:before,
    table.dataTable>thead .sorting_desc_disabled:before {
        right: 0.45rem;
    }
</style>
<?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/grades/exam-grades.blade.php ENDPATH**/ ?>