  <?php
  $kelas    = str_replace("'","`",(isset($_GET['kelas'])) ? $_GET['kelas'] : "");
  $qkelas=mysqli_query($connect,"select * from tb_kelas where id_kelas='".$kelas."'");
  $rkelas=mysqli_fetch_array($qkelas);
  ?>
  <div id="loader" class="loader" style="display:none;"></div>


    <br>
    <!--
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-12">
            <h5>Data Kategori Sentra</h5>
          </div>
        </div>
      </div>
    </div>
    -->
    

    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-12">
            <div class="card card-info">
              <div class="card-header" style="background:#eb5d99;color:white;">
                <form action="">
                <input type="hidden" name="prefix" value="pengayaan">
                <h3 class="card-title">Uji Konsep - Kelas 
                    
                    <select name="kelas" style="cursor:pointer;padding:3px;" onchange="this.form.submit()">
                        <?php 
                        $qk=mysqli_query($connect,"select * from tb_kelas order by nama_kelas asc");
                        while($rk=mysqli_fetch_array($qk)){
                        ?>
                        <option value="<?php echo $rk['id_kelas'];?>" <?php if($kelas==$rk['id_kelas']){echo"Selected";}?>><?php echo $rk['nama_kelas'];?></option>
                        <?php }?>
                      </select>
                    

                </h3>
                </form>
           

              </div>
              <!-- /.card-header -->
              <div class="card-body table-responsive p-0">
                
                <div class="col-md-12" style="text-align:right;padding:13px;">
                   Sudah dikerjakan <span class="badge bg-success"><i class="fa fa-check"></i></span>
                   &nbsp;&nbsp;&nbsp;&nbsp;
                   Belum dikerjakan <span class="badge bg-danger"><i class="fa fa-times-circle"></i></span>
                </div>


                <table class="table table-striped table projects">
                  <thead>                  
                    <tr>
                      <th width="5%" style="text-align:center;">No</th>
                      <th width="5%">Foto</th>
                      <th width="45%">Nama Siswa</th>
                      
                      <?php
                      $bilangan=1;
                      $qunit=mysqli_query($connect,"select * from tb_unit order by id_unit asc");
                      while($runit=mysqli_fetch_array($qunit)){
                      ?>
                      <th width="10%" style="text-align:center;">Pretest Unit-<?php echo $bilangan++;?></th>
                      <?php }?>
                      
                      <?php
                      $bilangan=1;
                      $qunit=mysqli_query($connect,"select * from tb_unit order by id_unit asc");
                      while($runit=mysqli_fetch_array($qunit)){
                      ?>
                      <th width="10%" style="text-align:center;">Post Test Unit-<?php echo $bilangan++;?></th>
                      <?php }?>
                    </tr>
                  </thead>
                  <tbody>
                  <?php
                  $bilangans=1;
                  $q=mysqli_query($connect,"select * from tb_siswa where id_kelas='".$kelas."'")or die(mysqli_error($connect));
                  while($r=mysqli_fetch_array($q)){

                  ?>
                    
                    <tr>
                      <td align="center"><?php echo $bilangans++;?></td>
                      <td>
                        <img onerror="this.src='assets/img/ava.png'" alt="Foto" class="table-avatar" src="../assets/foto/<?php echo md5($r['id_siswa']);?>.jpg?p=<?php echo date('s');?>">
                      </td>
                      <td>
                        <?php echo $r['nama_lengkap'];?>
                      </td>

                      <?php
                      $bilangan=1;
                      $qunit=mysqli_query($connect,"select * from tb_unit order by id_unit asc");
                      while($runit=mysqli_fetch_array($qunit)){
                      ?>
                      <td align="center">

                            <?php
                            $qcek=mysqli_query($connect,"select * from tb_jawaban_pretest where id_siswa='".$r['id_siswa']."' AND id_unit='".$runit['id_unit']."'");
                            $jumjawaban=mysqli_num_rows($qcek);
                            if($jumjawaban>0){
                            ?>
                            <a href="index.php?prefix=jawabanpretest&kelas=<?php echo $kelas;?>&unit=<?php echo $runit['id_unit'];?>&id=<?php echo $r['id_siswa'];?>"><span class="badge bg-success"><i class="fa fa-check"></i> <?php include"../inc/skor5.php";?></span></a>
                            
                            
                            
                            <?php }else{?>
                            <span class="badge bg-danger"><i class="fa fa-times-circle"></i></span>
                            <?php }?>


                      </td>
                      <?php }?>
                      
                      
                      
                      
                      
                      
                      <?php
                      $bilangan=1;
                      $qunit=mysqli_query($connect,"select * from tb_unit order by id_unit asc");
                      while($runit=mysqli_fetch_array($qunit)){
                      ?>
                      <td align="center">

                            <?php
                            $qcek=mysqli_query($connect,"select * from tb_jawaban where id_siswa='".$r['id_siswa']."' AND id_unit='".$runit['id_unit']."'");
                            $jumjawaban=mysqli_num_rows($qcek);
                            if($jumjawaban>0){
                            ?>
                            <a href="index.php?prefix=jawaban&kelas=<?php echo $kelas;?>&unit=<?php echo $runit['id_unit'];?>&id=<?php echo $r['id_siswa'];?>"><span class="badge bg-success"><i class="fa fa-check"></i> <?php include"../inc/skor4.php";?></span></a>
                            
                            
                            
                            <?php }else{?>
                            <span class="badge bg-danger"><i class="fa fa-times-circle"></i></span>
                            <?php }?>


                      </td>
                      <?php }?>
                      

                    </tr>

                    <?php }?>
                  </tbody>
                </table>


              </div>


            </div>
            <!-- /.card -->
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
      </div><!-- /.container-fluid -->
    </section>







          <style>
          .loader {
          position: fixed;
          left: 0px;
          top: 0px;
          width: 100%;
          height: 100%;
          z-index: 9999;
          background: url('assets/img/loading.gif') 50% 50%   no-repeat;    
          }
          </style>

         