<?php  
if($latest_session) 
{ ?>
<div class="panel panel-default">
   <div class="clearfix"></div>
   
   <table id="table" class="display table table-striped table-bordered" cellspacing="0" width="100%">
      <thead>
         <tr>
            <th><?php echo 'Session'; ?> </th>
            <th><?php echo 'Topic'; ?></th>
          <?php if($loginUserType ==  2 ) { ?>   <th><?php echo 'Duration'; ?></th>
            <th><?php echo 'Video Link'; ?></th> <?php } ?>
            <th><?php echo 'Test Link'; ?></th>
            <th><?php echo 'Status'; ?></th>
            
         </tr>
      </thead>
      <tbody>
      <?php
     // print_r($latest_session);
      $index = 1;
       foreach($latest_session as $session) {  ?>
      <tr>
      <td> <?php echo $session->Session_Order; ?>  </td>
      <td> <?php echo $session->name; ?>  </td>
   <?php if($loginUserType  == 2 ) { ?>   <td> <?php  echo  $session->duration_min.' minutes'; ?>   </td> 
        <td> <?php  if($session->video_link and trim($session->video_link) != '-') { ?> <input type="hidden" id="VideoLink<?php echo $index ?>" value = "<?php echo $session->video_link; ?>"> 
      <a href="javascript:void(0)" name ="videoicon<?php echo $index ?>"  onclick="videoPlay(<?php echo $index ?>)" data-toggle="tooltip"  title="play video" class="btn btn-success btn-action mr-1 play_video"><i class="fas fa-play"></i></a>
      <?php  } else echo '-'; ?> </td>  <?php } ?>

      <td> <?php if($session->testId) { ?> 
        <a href="<?php echo base_url().'instruction/'.$session->testId; ?> "  data-toggle="tooltip"  title="Start test" class="btn btn-primary btn-action mr-1"><i class="fas fa-pencil-alt"></i> </a>
      <?php } else echo '-'; ?> </td>

      <td>  <?php if($session->total_attemp and $session->testId ) { ?>
        <h5>  <span class="label label-success">Completed</span> </h5>
          <?php } else if ($session->testId)  { ?>
            <h5>   <span class="label label-warning">Pending</span> </h5>
        <?php  } else  { ?>
            <h5>   <span class="label label-warning"> - </span> </h5>
        <?php  }  ?>  </td>
      </tr>   
      <?php $index++;
    } ?>
      </tbody>
   </table>
</div>
<?php   }else{
                ?>
                <div class="col-12 text-center text-danger"> <?php echo lang('no_quiz_found'); ?></div>
                <?php } ?> 

                <div id="session_video" class="modal fade"  role="dialog">
                    <div class="modal-dialog modal-lg">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h5 class="modal-title" id="exampleModalCenterTitle">Session Video</h5>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span class="d-none" aria-hidden="true">×</span>
                                </button>
                            </div>
                            <div class="modal-body">
                                <div class="center_content text-center">
                                    <!--  <iframe width="700" height="345" src="<?php 'https://www.youtube.com/watch?v=EngW7tLk6R8'; ?>"  allowfullscreen></iframe>-->
                                   <video controls width="700">

                                    <source  class="link" src=""
                                            type="video/webm">
                                    <source  class="link" src=""
                                            type="video/mp4">

                                    Sorry, your browser doesn't support embedded videos.
                                </video> 
                                        
                                </div>
                                <div class="modal-footer">
                                <button type="button" class="btn btn-secondary closeModal" onclick="closevideo()" data-dismiss="modal">Close</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div> 





<script>
function videoPlay(i)
{
//alert(i);
 //var str = $("#VideoLink.'i'").val();
 var str = document.getElementById("VideoLink"+i).value; 
// alert(str);
   $(".link").attr('src',str);
   $("#session_video video")[0].load();
   $('#session_video').modal('toggle');
        $('.modal').modal('show');
    
}

function closevideo()
{
    $("video").each(function () { this.pause() });
}
window.addEventListener('load', function () {




})

</script>



                
