

                <div class="x_panel">
                   <div class="x_title">
                  <h2>
                    Test List
                  </h2> 
                  <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                  </ul>
                   <div class="clearfix"></div>
                   </div><!-- x_title -->
                    
                  <div class="x_content">

                   <div style="overflow-x:auto;">
					 <table id="datatable-buttons" class="table table-striped table-bordered  nowrap">
                      <thead class="center">
                        <tr>
                          <th style="width:50px;">#</th>
                          <th style="width:100px;">Subject</th>
                          <th style="width:150px;">Total Question</th>
                          <th style="width:100px;">Total Marks</th>
                          <th style="width:100px;">Total Time</th>
                          <th style="width:100px;">Test Date</th>
                          <th style="width:100px;">Action</th>
                        </tr>
                      </thead>
                      <tbody class="center">
                        <?php 
                           if (isset($test_list)) : 
                       		 $i=1; foreach ($test_list as $key => $value){
                       		 $t_id=$value['id'];
                       		 $c_id=$cadet_id;
                       		 $auto_checker=$this->db->select('id')
                       		                        ->from('test_log')
                       		                        ->where('test_id',$t_id)
                       		                        ->where('cadet_id',$c_id)
                       		                        ->where('is_delete',0)
                       		                        ->get()->row_array();
                       		 if(empty($auto_checker))   
                       		 {
                       	
                       		 ?>
                        <tr>
                          <td><?php echo $i++; ?></td>
                          <td><?php echo $value['name']; ?></td>
                          <td><?php echo $value['mcq']; ?></td>
                          <td><?php echo $value['totalmarks']; ?></td>
                          <td><?php echo $value['time']." minutes"; ?></td>
                          <td><?php echo date("d-m-Y",strtotime($value['dateofpaper'])); ?></td>
                          <td>
                              <?php
                               if($current_date==$value['dateofpaper'])
                               {
                                   
                               ?>
                                  <form method="post" id="test_form<?php echo $value['id'];?>" action="<?php echo base_url();?>Test/start_test">
                                      <input type="hidden" name="paper_id" id="paper_id" value="<?php echo $value['id'];?>">
                                      <input type="submit" id="start_test" class="btn btn-primary" value="Start Test">
                                  </form> 
                              <?php
                              }
                              ?>
                          </td>
                        </tr>
                        <?php }}  endif ?>
                      </tbody>
                    </table>
                   </div>
                  </div><!-- x_content -->
                </div><!-- x_panel -->
 <script>
    $(document).ready(function() {
            $('.table').DataTable();
        } );
    </script>

<script>
 $("form").submit(function(e){
        e.preventDefault();
         var $form = $(this);
         var id = $form.attr('id');
         var data = $form.serialize();
         var test_id=data.replace('paper_id=','');
         
         $.ajax({
          type: "POST",
          data:{test_id:test_id},
          url: "<?php echo base_url();?>Test/update_status",
          
          success: function(msg){
      
             if(msg==1)
             {
               $('#test_form'+test_id).submit(); 
             }
         }
        });
    });
</script>      