Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //.......
- if(empty($nomor))
- {
- $nomor=1;
- $sql_soal2 = mysql_query("SELECT waktu,jmlsoal FROM t_set_ujian");
- $hsl_soal2 = mysql_num_rows($sql_soal2);
- if($hsl_soal2 > 0)
- {
- $dt_soal2=mysql_fetch_array($sql_soal2);
- $waktusoal=$dt_soal2['waktu'];
- $_SESSION['jml_soal']=$dt_soal2['jmlsoal'];
- }
- else
- {
- $waktusoal=10;
- $_SESSION['jml_soal']=10;
- }
- $sql_ak=mysql_query("SELECT no,RAND() FROM t_soal WHERE status='1' ORDER BY RAND() LIMIT 0,".$_SESSION['jml_soal']);
- $hsl_ak = mysql_num_rows($sql_ak);
- if($hsl_ak > 0){
- $no_soal=array();
- $i=0;
- while($data=mysql_fetch_object($sql_ak)){
- $no_soal[$i]=$data->no;
- $i++;
- }
- $_SESSION['no_soal']=$no_soal;
- }
- }
- if($nomor>$_SESSION['jml_soal'])
- {
- echo "<script>alert('SELAMAT ANDA TELAH MENYELESAIKAN UJIAN INI..')</script>";
- echo "<meta http-equiv='refresh' content='0;url=?m=home'>";
- }
- else
- {
- $sql_soal = mysql_query("SELECT DISTINCT * FROM t_soal WHERE no='".$_SESSION['no_soal'][$nomor-1]."'");
- $hsl_soal = mysql_num_rows($sql_soal);
- if($hsl_soal > 0 )
- {
- $dt_soal=mysql_fetch_array($sql_soal);
- $no_soal1=$dt_soal[0];
- $soal1=$dt_soal[1];
- $jnssoal1=$dt_soal[2];
- $pilihan_a=$dt_soal['pilihan_a'];
- $pilihan_b=$dt_soal['pilihan_b'];
- $pilihan_c=$dt_soal['pilihan_c'];
- $pilihan_d=$dt_soal['pilihan_d'];
- $jawaban1=$dt_soal['jawaban'];
- $sql_jawab = mysql_query("SELECT * FROM t_jawaban WHERE no_peserta='$nopeserta' AND no='$nomor'");
- $hsl_jawab = mysql_num_rows($sql_jawab);
- if($hsl_jawab <= 0 and ($nomor<=$_SESSION['jml_soal']))
- {
- //ini untuk apa ya? kok jawaban user tidak dimasukkan? apa hanya untuk inisialisasi saja?
- $sql_save1="INSERT INTO t_jawaban (no,no_peserta,no_soal,jenis_soal,jawaban) VALUES ('$nomor','$nopeserta','$no_soal1','$jnssoal1','-')";
- $jln_save1=mysql_query($sql_save1);//menjalankan perintah
- }
- }//if($hsl_soal > 0)
- }//if($nomor>$jmlsoal)
- //......
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement