Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1. <?php
  2. include("config.php");
  3.  
  4. $currentRowCount = 5;
  5. echo $nik;
  6. //function random
  7. function randomArrayIndex($startIndex, $endIndex, $howMany){
  8. $allocated = array();
  9. $result = array();
  10. for($i=$startIndex; $i<=$endIndex; $i++){
  11. array_push($allocated, $i);
  12. }
  13. for($i=0; $i<$howMany; $i++){
  14. $randIndex = rand(0, count($allocated)-1);
  15. array_push($result, $allocated[$randIndex]);
  16. array_splice($allocated, $randIndex, 1);
  17. //echo $result[$i];
  18. //echo "<br>";
  19. }
  20. return $result;
  21. }
  22.  
  23. ?>
  24. <html>
  25.  
  26. <head>
  27.  
  28. <script language="JavaScript">
  29. var TimeOver = false;
  30. function getJam(Tanggal)
  31. {
  32. Jam = (Tanggal.getHours() < 10) ? "0" + Tanggal.getHours() + ":" : Tanggal.getHours() + ":"
  33. Jam += (Tanggal.getMinutes() < 10) ? "0" + Tanggal.getMinutes() + ":" : Tanggal.getMinutes() + ":"
  34. Jam += (Tanggal.getSeconds() < 10) ? "0" + Tanggal.getSeconds() : Tanggal.getSeconds()
  35. return Jam
  36. }
  37.  
  38. function dispJam()
  39. {
  40. TglCur = new Date()
  41. document.User.Watch.value = getJam(TglCur)
  42. if (Difference <= 0)
  43. {
  44. TimeOverWarn()
  45. document.User.TimeLeft.value = "Habis2"
  46. } else
  47. document.User.TimeLeft.value = getWaktu()
  48. setTimeout("dispJam()",1000)
  49. }
  50.  
  51. function getWaktu()
  52. {
  53. Difference = Difference - 1000
  54. TmLfHours = Math.floor(Difference/3600000)
  55. TmLfMinutes = Math.floor((Difference%3600000)/60000)
  56. TmLfSeconds = Math.round((Difference%60000)/1000)
  57. TmLfStr = (TmLfHours < 10) ? "0" + TmLfHours + ":" : TmLfHours + ":"
  58. TmLfStr += (TmLfMinutes < 10) ? "0" + TmLfMinutes + ":" : TmLfMinutes + ":"
  59. TmLfStr += (TmLfSeconds < 10) ? "0" + TmLfSeconds : TmLfSeconds
  60. return TmLfStr
  61. }
  62. function goSubmit(){
  63. //document.f1.submit();
  64. }
  65. function TimeOverWarn()
  66. {
  67. window.alert("\nWaktu Anda habis!!")
  68. //document.CheckQuestions.submit()
  69. TimeOver = true;
  70. //goSubmit();
  71. return true;
  72. }
  73.  
  74.  
  75.  
  76. Tanggal = new Date()
  77. Tgl= new Date()
  78. TglStart = new Date()
  79. Tgl.setTime(Tgl.getTime() + 1 * 60 * 1000)
  80. var Difference=Tgl.getTime() - TglStart.getTime()
  81. ArrayBulan = new Array("Januari","Pebruari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","Nopember","Desember")
  82. Tahun = (Tanggal.getYear() <= 99) ? "19" + Tanggal.getYear() : Tanggal.getYear()+1900
  83. TglStr = Tanggal.getDate() + " " + ArrayBulan[Tanggal.getMonth()] + " " + Tahun
  84.  
  85. </SCRIPT>
  86.  
  87. </head>
  88.  
  89. <?php
  90.  
  91.  
  92. if(isset($_POST['btn'])){
  93.  
  94. echo "Hasil :<br>";
  95.  
  96. //$currentNik = 40;
  97.  
  98.  
  99.  
  100. for($i=0;$i<$currentRowCount; $i++){
  101. //echo $_POST[lvl][$i];
  102. if($_POST[lvl][$i]==$_POST[jawab][$i]){
  103. $b1 = 'Benar';
  104. //echo $i;
  105. //echo $b1;
  106. }else{
  107. $b1='Salah';
  108. //echo $i;
  109. //echo $b1;
  110.  
  111. }
  112.  
  113. $id_soal = $_POST[id_soal][$i];
  114. //echo $id_soal;
  115. $user_jawab = $_POST[lvl][$i];
  116. $q="Insert into jawab (nik,id_soal,jawab_user,status_jawab,jawab_esai,periode) values ('$nik', '$id_soal', '$user_jawab','$b1', '$tx','1')";
  117. mysql_query($q) or die(mysql_error());
  118. echo $q ;
  119. //echo "<br>";
  120.  
  121.  
  122. }
  123.  
  124. }else{
  125.  
  126.  
  127.  
  128.  
  129. ?>
  130.  
  131.  
  132. <body onload=dispJam()>
  133. <p align=center>Kuisioner</p>
  134.  
  135. <form name=User><p align="center"><input size=8 name=Watch type="text"></p>
  136. <TABLE width="27%" align=center border=0>
  137. <tr><td width="21%">Tanggal</td><td width="3%">:</td><td width="33%"><SCRIPT>document.write(TglStr)</SCRIPT></td></tr>
  138. <tr><td width="21%">Mulai</td><td width="3%">:</td><td width="33%"><SCRIPT>document.write(getJam(TglStart))</SCRIPT></td></tr>
  139.  
  140. <tr><td width="21%">Selesai</td><td width="3%">:</td><td width="33%"><SCRIPT>document.write(getJam(Tgl))</SCRIPT></TD></tr>
  141. <tr><td width="21%">Waktu</td><td width="3%">:</td><td width="33%">10 menit</td></tr>
  142. <tr><td width="21%">Sisa</td><td width="3%">:</td><td width="33%"><input size=8 name=TimeLeft class="textbox" type="text"></tr>
  143. </table>
  144. </form>
  145.  
  146. <a href="javascript:TimeOverWarn()">TESTESTES</a>
  147. <form name="f1" method="POST" action="q_index6.php">
  148.  
  149. <table border="0" width="548" height="94" align=center>
  150. <?php
  151.  
  152. $realRowCount = mysql_num_rows(mysql_query("select * from tanya"));
  153.  
  154. for($i=0;$i<$currentRowCount; $i++){
  155.  
  156. php?>
  157.  
  158. <?php
  159. $distance = floor($realRowCount/$currentRowCount);
  160.  
  161. if(!isset($_POST[lvl][$i])){
  162.  
  163. $randomedIndex = randomArrayIndex($distance*$i + 1, $distance*($i+1), 1 );
  164. /*echo "Random antara ";
  165. echo $distance*$i + 1;
  166. echo "-";
  167. echo $distance*($i+1) ;
  168. echo "<br>";*/
  169.  
  170. $varRand=$randomedIndex[0];
  171.  
  172. $query1 = "select * from tanya where ID_SOAL=$varRand";
  173. $result1 = mysql_query($query1);
  174. //echo $query;
  175.  
  176. while($row = mysql_fetch_array($result1)){
  177. $id1=$row['ID_SOAL'];
  178. $soal1=$row['SOAL'];
  179. $kunci=$row['jawaban'];
  180.  
  181. ?>
  182.  
  183. <tr>
  184. <td height="26" colspan="2"><?php echo ($i+1);?>. <?php echo $soal1;?></td>
  185. </tr>
  186. <tr>
  187. <td height="28" width="269">
  188. <input type="radio" value="op1" name="lvl[<?php echo$i;?>]"> <?php echo $row['OP1'];?></td>
  189. <td height="28" width="269">
  190. <input type="radio" value="op3" name="lvl[<?php echo$i;?>]"> <?php echo $row['OP2'];?></td>
  191. </tr>
  192. <tr>
  193. <td height="29" width="269">
  194. <input type="radio" value="op2" name="lvl[<?php echo$i;?>]"> <?php echo $row['OP3'];?></td>
  195. <td height="29" width="269">
  196. <input type="radio" value="op4" name="lvl[<?php echo$i;?>]"> <?php echo $row['OP4'];?></td>
  197. <input type="hidden" value="<?php echo $kunci; ?>" name="jawab[<?php echo$i;?>]"> </td>
  198. <input type="hidden" value="<?php echo $row['ID_SOAL']; ?>" name="id_soal[<?php echo$i;?>]"> </td>
  199.  
  200. <?php
  201. }
  202.  
  203. }
  204.  
  205. ?>
  206. </tr>
  207.  
  208.  
  209.  
  210. <?php
  211. }
  212.  
  213. ?>
  214. </table>
  215.  
  216.  
  217. <table width="561" height="103" align="center">
  218.  
  219.  
  220. <tr>
  221. <td width="553" height="38">6.<?php echo $row['SOAL'];?></td>
  222. </tr>
  223. <tr>
  224. <td height="57"><label for="tx"></label>
  225. <textarea name="tx" id="tx" cols="60" rows="5"></textarea></td>
  226. </tr>
  227.  
  228. </table>
  229.  
  230.  
  231.  
  232. <table border="0" width="153" height="37" align=center>
  233.  
  234.  
  235. <tr>
  236. <td height="33" width="147" align=center>
  237. <input type="submit" name="btn" value="Submit" onClick="goSubmit()">
  238. </td>
  239.  
  240. </tr>
  241. </table>
  242. <p>&nbsp;</p>
  243.  
  244. </form>
  245. </body>
  246. <?php };?>
  247. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement