<?php
$benar = 0;
$qtbsoal=mysqli_query($connect,"select * from tb_pretest where id_unit='".$runit['id_unit']."'");
$jumlahsoal=mysqli_num_rows($qtbsoal);
while($rtbsoal=mysqli_fetch_array($qtbsoal)){

	$qjawaban=mysqli_query($connect,"select * from tb_jawaban_pretest where id_siswa='".$rsiswa_login['id_siswa']."' AND id_unit='".$runit['id_unit']."' AND id_pretest='".$rtbsoal['id_pretest']."'");
    $rjawaban=mysqli_fetch_array($qjawaban);

    if($rtbsoal['kunci']==$rjawaban['jawaban']){
    	$benar++;
    }else{
    	$benar = $benar;
    }

}

$skor = round($benar/$jumlahsoal*100,2);
?>
<b><?php echo $skor;?></b>