Advertisement
cdsatrian

soal

Jul 29th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. //.......
  2. if(empty($nomor))
  3. {
  4.   $nomor=1;
  5.   $sql_soal2 = mysql_query("SELECT waktu,jmlsoal FROM t_set_ujian");
  6.   $hsl_soal2 = mysql_num_rows($sql_soal2);
  7.   if($hsl_soal2 > 0)
  8.   {
  9.     $dt_soal2=mysql_fetch_array($sql_soal2);
  10.     $waktusoal=$dt_soal2['waktu'];
  11.     $_SESSION['jml_soal']=$dt_soal2['jmlsoal'];
  12.   }
  13.   else
  14.   {
  15.     $waktusoal=10;
  16.     $_SESSION['jml_soal']=10;
  17.   }
  18.   $sql_ak=mysql_query("SELECT no,RAND() FROM t_soal WHERE status='1' ORDER BY RAND() LIMIT 0,".$_SESSION['jml_soal']);
  19.   $hsl_ak = mysql_num_rows($sql_ak);
  20.   if($hsl_ak > 0){
  21.     $no_soal=array();
  22.     $i=0;
  23.     while($data=mysql_fetch_object($sql_ak)){
  24.        $no_soal[$i]=$data->no;    
  25.        $i++;
  26.     }
  27.     $_SESSION['no_soal']=$no_soal;
  28.   }
  29. }  
  30.  
  31. if($nomor>$_SESSION['jml_soal'])
  32. {
  33.   echo "<script>alert('SELAMAT ANDA TELAH MENYELESAIKAN UJIAN INI..')</script>";
  34.   echo "<meta http-equiv='refresh' content='0;url=?m=home'>";
  35. }
  36. else
  37. {
  38.   $sql_soal = mysql_query("SELECT DISTINCT * FROM t_soal WHERE no='".$_SESSION['no_soal'][$nomor-1]."'");
  39.   $hsl_soal = mysql_num_rows($sql_soal);
  40.   if($hsl_soal > 0 )
  41.   {
  42.     $dt_soal=mysql_fetch_array($sql_soal);
  43.     $no_soal1=$dt_soal[0];
  44.     $soal1=$dt_soal[1];
  45.     $jnssoal1=$dt_soal[2];
  46.     $pilihan_a=$dt_soal['pilihan_a'];
  47.     $pilihan_b=$dt_soal['pilihan_b'];
  48.     $pilihan_c=$dt_soal['pilihan_c'];
  49.     $pilihan_d=$dt_soal['pilihan_d'];
  50.     $jawaban1=$dt_soal['jawaban'];
  51.     $sql_jawab = mysql_query("SELECT * FROM t_jawaban WHERE no_peserta='$nopeserta' AND no='$nomor'");
  52.     $hsl_jawab = mysql_num_rows($sql_jawab);
  53.     if($hsl_jawab <= 0 and ($nomor<=$_SESSION['jml_soal']))
  54.     {
  55.       //ini untuk apa ya? kok jawaban user tidak dimasukkan? apa hanya untuk inisialisasi saja?
  56.       $sql_save1="INSERT INTO t_jawaban (no,no_peserta,no_soal,jenis_soal,jawaban) VALUES ('$nomor','$nopeserta','$no_soal1','$jnssoal1','-')";
  57.       $jln_save1=mysql_query($sql_save1);//menjalankan perintah
  58.     }
  59.   }//if($hsl_soal > 0)
  60. }//if($nomor>$jmlsoal)
  61. //......
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement