<?php include "header.php";?>
<body>
  <main id="main">
    <!-- ======= About Lists Section ======= -->
    <section id="situasi" class="about-lists">
      <div class="container">
        <?php include "kop.php";?>
        <div class="row">
          <div class="col-lg-12 col-md-12 content-item" data-aos="fade-up">
            <span class="alert alert-success text-center" style="color: black;">Data nama ujian anda</span>
            <br>
            <div class="row">
              <div class="col-lg-12">
                <table class="table">
                  <tr>
                    <td>Nama</td>
                    <td>: <?php echo $this->session->userdata('peserta')['nama']?></td>
                  </tr>
                 
                </table>
                <br>
                <div class="alert alert-warning text-center">
                  <blockquote> klik mulai ujian. </blockquote>
                </div>
              </div>

            </div>
          </div>
        <div class="col-lg-12 col-md-12 content-item text-center" data-aos="fade-up" data-aos-delay="300">
          <div class="row">
            <div class="col-md-6"><!-- 
              <div class="card border-danger">
                Ujian Mulai dalam
                <div id="clock"></div>
                <div id="mulai"></div>
              </div> -->
              <button class="btn btn-flat btn-sm btn-primary" onclick="mulai()">Mulai Ujian</button>
            </div>
            <div class="col-md-6">
              <button class="btn btn-flat btn-sm btn-danger" onclick="batal_ujian()">Batal Ujian</button>
            </div>
          </div>
        </div>

      </div>

    </div>
      
  </section><!-- End About Lists Section -->

  </main><!-- End #main -->

  <?php include "footer.php";?>
  <script type="text/javascript">
    
    function batal_ujian(){
      if(confirm("Batalkan ujian?")){
        $.ajax({
          url :'<?php echo base_url();?>cat/batal_ujian',
          type : 'get',
          success:function(){
            location.replace('<?php echo base_url();?>');
          }
        })
      }
      return false;
    }

    mulaiUjian = function(){
      $("#mulai").html('<button class="btn btn-flat btn-sm btn-primary" onclick="mulai()">Mulai Ujian</button>');
    }

    function mulai(){
      location.replace("<?php echo base_url('ujian')?>");
    }

    $("#clock").countdowntimer({
          startDate : '<?php echo date('Y-m-d H:i:s'); ?>',
          dateAndTime : '<?php echo $this->session->userdata("peserta")["jam_mulai"]; ?>',
          size : "lg",
          displayFormat: "HMS",
          timeUp : mulaiUjian,
      });

    

  </script>