<?php
	include "php_class/class_mysql.php";
	include "php_class/class_mahasiswa.php";
	$DataMahasiswa = new DataMahasiswa;
?>


<link href="<?php echo $base?>plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/iCheck/all.css" rel="stylesheet" type="text/css" />
<link href="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet"/>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/timepicker/bootstrap-timepicker.min.js" type="text/javascript"></script>
<script src="<?php echo $base?>plugins/iCheck/icheck.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $base?>plugins/autocomplete/shieldui-all.css" />
<link href="<?php echo $base?>bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>bootstrap/js/locales/bootstrap-datetimepicker.id.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?php echo $base?>plugins/autocomplete/shieldui-all.min.js"></script>
<script type="text/javascript">
    var countries = <?php echo json_encode($item);?>;
		
		jQuery(function ($) {
        $("#NPM").shieldAutoComplete({
            dataSource: {
                data: countries
            },
            minLength: 1
        });
        
    });
</script>
<script type="text/javascript">
            $(document).ready(function() {
                  var detik = 0;
                  var menit = 10;
                  var jam = 0;
                function hitung() {
                    setTimeout(hitung,1000);
                   if(menit == 5 && jam == 0 && detik >45){
						var peringatan = 'style="color:black"';
						$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Waktu anda tinggal 5 menit!</div></div>')			
                   }else if (menit == 5 && jam == 0 ){
						$('.peringatan').html('<div id="warning"></div>')			
				   }else if (menit == 0 && jam == 0 ){
						$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Ujian akan ditutup secara otomatis apabila waktu telah habis!</div></div>')			
				   };
				   
				   if(menit > 0){
                   $('#timer').html(
                          '<h2 align="right"'+peringatan+'>Sisa waktu anda : &nbsp;&nbsp;&nbsp;' + menit + ' menit : ' + detik + ' detik</h2><hr>'
                    );
				   }else{
                   $('#timer').html(
                          '<h2 align="right"'+peringatan+'>Sisa waktu anda : &nbsp;&nbsp;&nbsp;' + detik + ' detik</h2><hr>'
                    );
					  }
                      detik --;
                     if(detik < 0) {
                            detik = 59;
                            menit --;
                          if(menit < 0) {
                                 menit = 59;
                                 jam --;
                              if(jam < 0) { clearInterval(); 
                                var frmsoal = document.getElementById("frmsoal"); 
                                frmsoal.submit(); 
                        } 
                    } 
                } 
            }           
            hitung();
      }); 
      // ]]>
    </script>
<script>
	$(document).ready(function(){
		$('#NP').keyup(function(e){
	  		if(e.keyCode == 13){
				var npm = $('#NP').val();
				var action = '3';
				if (npm==''){
					$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Nomer Pendaftaran Masih Kosong!</div></div>')			
				}else{
					$.ajax({
						type:"POST",
						data: "index=" + npm + "&action=" + action,
						url:"<?php echo $base?>cek-pendaftaran.php",     
						success: function(data){
							var tampung = data;
							
							if(tampung==404){
								$('.peringatan').html('<div id="warning"><div class="alert alert-warning" role="alert">Nomer Pendaftaran tidak ditemukan !</div></div>')	
							}else{
								var pecah=tampung.split(":");
								$('.peringatan').html('<div id="warning"><div role="alert"></div></div>')
								$('#NoPendaftaran').val(pecah[3]);
								$('#Nama').val(pecah[0]);
								$('#Jurusan').val(pecah[1]);
								$('#Email').val(pecah[2]);
								$('.form-group').show()
								$('#frmsoal').show();
            hitung();
								}
						}
					});
				}
			} 
		});
	});
</script>
<section class="content-header">
  <h1>
   Tes / ujian masuk
  </h1>
  <ol class="breadcrumb">
    <li><a href="<?php echo $base?>"><i class="fa fa-dashboard"></i> Home</a></li>
  </ol>
</section>
<section class="content">
 	<div class="row">
    	<div class="row">
        	<div class="col-md-12">
            </div>
        </div>
    	<div class="col-md-12">
        	 <div class="box box-info">
                <div class="box-header">
                 <h2><div id='timer'></div></h2>
                </div>

                <div class="box-body">
                <div class="peringatan">
                </div>
                	<form method="post" >
                        <div class="form-group">
                            <label class="control-label">No Pendaftaran</label>
                            <input type="text" class="form-control" placeholder="masukkan nomer pendaftaran kemudian tekan enter" id="NP" name="NP" required="required">
                         </div>
                         <div class="form-group" style="display:none">
                            <label class="control-label">Nama</label>
                            <input type="text" name="Nama" required="required" class="form-control" id="Nama" disabled >
                         </div>
                        <div class="form-group" style="display:none">
                            <label class="control-label">Jurusan</label>
                            <input type="text" name="Jurusan" required="required" class="form-control" id="Jurusan" disabled>
                         </div>
                        <div class="form-group" style="display:none">
                            <label class="control-label">Email</label>
                            <input type="text" name="Jurusan" required="required" class="form-control" id="Email" disabled>
                         </div>
					</form>
                	<form method="post" action="<?php echo $base?>query-add-hasil-ujian-ulang" id="frmsoal" style="display:none">
                        <div class="box-header">
                          <h3 class="box-title">Soal Ujian Masuk</h3>
                        </div>
                   		<input type="hidden" name="NoPendaftaran" id="NoPendaftaran">
                   		<?php 
							include "php_class/class_soal.php";
							$DataSoal = new DataSoal;

            				$JumlahData = $DataSoal->get_all_soal('',$a,'jumlah');
    						for ($a=1;$a<=$JumlahData;$a++){
								$id = $DataSoal->get_all_soal('id',$a,'');
								$soal = $DataSoal->get_all_soal('soal',$a,'');
								$pilihanA = $DataSoal->get_all_soal('pilihanA',$a,'');
								$pilihanB = $DataSoal->get_all_soal('pilihanB',$a,'');
								$pilihanC = $DataSoal->get_all_soal('pilihanC',$a,'');
								$pilihanD = $DataSoal->get_all_soal('pilihanD',$a,'');
								$pilihanE = $DataSoal->get_all_soal('pilihanE',$a,'');
								$kunci = $DataSoal->get_all_soal('kunci', $a, '');
						?>			

                        <div class="form-group" style="margin-bottom:25px; border-bottom:#999 solid thin">
                            <label class="control-label"><?php echo $a?> <?php echo $soal?></label>
                            <div class="radio">
                            	<label><input type="radio" value="<?php echo $kunci.'-A'?>" name="<?php echo 'soal'.$id?>">A. <?php echo $pilihanA ?></label>
                            </div>
                            <div class="radio">
                            	<label><input type="radio" value="<?php echo $kunci.'-B'?>" name="<?php echo 'soal'.$id?>">B. <?php echo $pilihanB ?></label>
                            </div>
                            <div class="radio">
                            	<label><input type="radio" value="<?php echo $kunci.'-C'?>" name="<?php echo 'soal'.$id?>">C. <?php echo $pilihanC ?></label>
                            </div>
                            <div class="radio">
                            	<label><input type="radio" value="<?php echo $kunci.'-D'?>" name="<?php echo 'soal'.$id?>">D. <?php echo $pilihanD ?></label>
                            </div>
                            <div class="radio">
                            	<label><input type="radio" value="<?php echo $kunci.'-E'?>" name="<?php echo 'soal'.$id?>">E. <?php echo $pilihanE ?></label>
                            </div>
                         </div>
						 <?php } ?>
                         <div class="form-group">
                            <label class="control-label">16. Saudara memilih kuliah di FE Unwar Non Reguler, Mengapa ? Berikan komentar saudara ! *</label>
                            <textarea class="form-control" placeholder="Wajib diisi!" id="soal16" required="required" name="soal16"></textarea>
                          </div>
                         <div class="form-group">
                            <button type="submit" class="btn btn-default"><i class='glyphicon glyphicon-ok'></i> Simpan</button>
                          </div>
                    </form>
                </div>
               </div>
         </div>
    </div>
</section>

    	
    	
   