<div class="container-fluid mt-3 mb-3 bg-white">
    <div class="row">
        <div class="col-sm-12 pt-3 pb-3">
            <ul class="breadcrumb">
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Welcome">Home</a></li>
                <li class="breadcrumb-item"><a href="<?php echo base_url(); ?>Examination">Exam</a></li>
                <li class="breadcrumb-item">All Courses</li>
            </ul>
            
            <ul class="nav nav-tabs tab-item-1">
                <li class="nav-item">
                    <a class="nav-link active" href="#">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-list-ol" viewBox="0 0 16 16">
                            <path fill-rule="evenodd" d="M5 11.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5z"/>
                            <path d="M1.713 11.865v-.474H2c.217 0 .363-.137.363-.317 0-.185-.158-.31-.361-.31-.223 0-.367.152-.373.31h-.59c.016-.467.373-.787.986-.787.588-.002.954.291.957.703a.595.595 0 0 1-.492.594v.033a.615.615 0 0 1 .569.631c.003.533-.502.8-1.051.8-.656 0-1-.37-1.008-.794h.582c.008.178.186.306.422.309.254 0 .424-.145.422-.35-.002-.195-.155-.348-.414-.348h-.3zm-.004-4.699h-.604v-.035c0-.408.295-.844.958-.844.583 0 .96.326.96.756 0 .389-.257.617-.476.848l-.537.572v.03h1.054V9H1.143v-.395l.957-.99c.138-.142.293-.304.293-.508 0-.18-.147-.32-.342-.32a.33.33 0 0 0-.342.338v.041zM2.564 5h-.635V2.924h-.031l-.598.42v-.567l.629-.443h.635V5z"/>
                        </svg>
                        All Courses</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="<?php echo base_url();?>Examination/add_subject">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-node-plus-fill" viewBox="0 0 16 16">
                            <path d="M11 13a5 5 0 1 0-4.975-5.5H4A1.5 1.5 0 0 0 2.5 6h-1A1.5 1.5 0 0 0 0 7.5v1A1.5 1.5 0 0 0 1.5 10h1A1.5 1.5 0 0 0 4 8.5h2.025A5 5 0 0 0 11 13zm.5-7.5v2h2a.5.5 0 0 1 0 1h-2v2a.5.5 0 0 1-1 0v-2h-2a.5.5 0 0 1 0-1h2v-2a.5.5 0 0 1 1 0z"/>
                        </svg>  Add New Subject
                    </a>
                </li>
                
                <li class="nav-item">
                    <a class="nav-link" href="<?php echo base_url();?>Examination/add_exam_head">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-node-plus-fill" viewBox="0 0 16 16">
                            <path d="M11 13a5 5 0 1 0-4.975-5.5H4A1.5 1.5 0 0 0 2.5 6h-1A1.5 1.5 0 0 0 0 7.5v1A1.5 1.5 0 0 0 1.5 10h1A1.5 1.5 0 0 0 4 8.5h2.025A5 5 0 0 0 11 13zm.5-7.5v2h2a.5.5 0 0 1 0 1h-2v2a.5.5 0 0 1-1 0v-2h-2a.5.5 0 0 1 0-1h2v-2a.5.5 0 0 1 1 0z"/>
                        </svg>  Add New Exam Head
                    </a>
                </li>
                
                <li class="nav-item">
                    <a class="nav-link" href="<?php echo base_url();?>Examination/remarks">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-node-plus-fill" viewBox="0 0 16 16">
                            <path d="M11 13a5 5 0 1 0-4.975-5.5H4A1.5 1.5 0 0 0 2.5 6h-1A1.5 1.5 0 0 0 0 7.5v1A1.5 1.5 0 0 0 1.5 10h1A1.5 1.5 0 0 0 4 8.5h2.025A5 5 0 0 0 11 13zm.5-7.5v2h2a.5.5 0 0 1 0 1h-2v2a.5.5 0 0 1-1 0v-2h-2a.5.5 0 0 1 0-1h2v-2a.5.5 0 0 1 1 0z"/>
                        </svg>  Remarks
                    </a>
                </li>
                
                <li class="nav-item">
                    <a class="nav-link" href="<?php echo base_url();?>Examination/add_working_days">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-node-plus-fill" viewBox="0 0 16 16">
                            <path d="M11 13a5 5 0 1 0-4.975-5.5H4A1.5 1.5 0 0 0 2.5 6h-1A1.5 1.5 0 0 0 0 7.5v1A1.5 1.5 0 0 0 1.5 10h1A1.5 1.5 0 0 0 4 8.5h2.025A5 5 0 0 0 11 13zm.5-7.5v2h2a.5.5 0 0 1 0 1h-2v2a.5.5 0 0 1-1 0v-2h-2a.5.5 0 0 1 0-1h2v-2a.5.5 0 0 1 1 0z"/>
                        </svg> Add Working Days
                    </a>
                </li>
                
            </ul>
            
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>Course</th>
                            <th>Subjects</th>
                            <th>Exam Heads</th>
                            <th>View</th>
                            <th>Result</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $courses_table='courses';
                        $all_courses=$this->NewExamModel->get_data($courses_table);
                        if($all_courses){
                            foreach($all_courses as $courses){
                                $course_id=$courses['id'];
                        ?>
                        <tr>
                            <td><?php echo $courses['course']; echo " "; echo $courses['subject_stream'];?></td>
                            <td><a href="<?php echo base_url();?>Examination/course_subjects/<?php echo $course_id;?>" target="_blank">View</a></td>
                            <td><a href="<?php echo base_url();?>Examination/course_exam_heads/<?php echo $course_id;?>" target="_blank">View</a></td>
                            <td><a href="<?php echo base_url();?>Examination/course_students/<?php echo $course_id;?>" class="btn btn-sm btn-info" target="_blank">View</a></td>
                            <td>
                                <!--<button class="btn btn-sm btn-success generate-result" type="button" course_id="<?php echo $courses['id']; ?>" exam_id="3" acedemic_session="3">Generate Resut</button>-->
                            </td>
                        </tr>
                        <?php
                            }
                        }
                        ?>
                    </tbody>
                </table>
            </div>
            
            
        </div>
    </div>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title text-warning" id="exampleModalLabel" style="text-align:center;width:100%;"></h5>
        <button type="button" class="btn-close btn btn-sm btn-rounded" data-bs-dismiss="modal" aria-label="Close"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/></svg></button>
      </div>
      <div class="modal-body success-response" style="text-align:center;">
            <h5 class="text-warning"><b>Generting Result. Keep Your Screen On. Don't Close and Change Your Screen</b></h5>
            <div class="spinner-border text-primary" role="status">
                <span class="visually-hidden">...</span>
            </div>
            <div class="spinner-border text-secondary" role="status">
                <span class="visually-hidden">...</span>
            </div>
            <div class="spinner-border text-success" role="status">
                <span class="visually-hidden">...</span>
            </div>
            <div class="spinner-border text-danger" role="status">
                <span class="visually-hidden">...</span>
            </div>
            <div class="spinner-border text-warning" role="status">
                <span class="visually-hidden">...</span>
            </div>
            <div class="spinner-border text-info" role="status">
                <span class="visually-hidden">...</span>
            </div>
            <div class="spinner-border text-light" role="status">
                <span class="visually-hidden">...</span>
            </div>
            <div class="spinner-border text-dark" role="status">
                <span class="visually-hidden">...</span>
            </div>
          
      </div>
      <div class="modal-footer">
        <!--<a href="<?php echo base_url(); ?>Register" class="btn btn-primary">Register Now</a>-->
        <!--<a class="btn btn-success"  href="<?php echo base_url(); ?>Login">Login</a>-->
        <!--<button type="button" class="btn btn-primary">Save changes</button>-->
      </div>
    </div>
  </div>
</div>
<script>
    $(document).ready(function(){
        $(document).on("click",".generate-result",function(){
            var course_id=$(this).attr("course_id");
            var exam_id=$(this).attr("exam_id");
            var acedemic_session=$(this).attr("acedemic_session");
            $('#exampleModal').modal({
                backdrop: 'static',
                // keyboard: false,
                // mouse:false
            });
            
            
            $('#exampleModal').modal('show');
            $.ajax({
                url: '<?php echo base_url();?>ExamResult/generate_result',
                type: 'POST',
                data: {course_id:course_id,exam_id:exam_id,acedemic_session:acedemic_session},
                success: function(data){
                    // alert(data);
                    if(data == "success"){
                        $(".btn-close").css("display","block");
                        $(".success-response").html("<span class='text-success text-center'>Result Generated Successfully</span>");
                    }
            
                }
            });    
        });    
        
        
        $(".btn-close").click(function(){
            $('#exampleModal').modal('hide');
        })
    });
</script>