File : quizjava.pl. ID : 0502
Skin : Default | Sons-of-obsidian | Sunburst | Highlighter | Frame
#!/usr/bin/perl
print"Content-type:text/html\n\n"; 
$fname = "quizjava.txt";
open(fn, "<$fname" ); 
@bfn = <fn>;
close(fn);
$cntr = @bfn;
$rand = $^T;
$dif = ($rand % 99) + 13;
for $r (1..10) {
  $ind = (($rand / ($dif + $r)) + $r * 3) % $cntr;	
  push @keepar,$bfn[$ind];			  
}
print'<body>ข้อสอบกึ่งอัตโนมัติ แบบตอบแล้วเฉลยทีละข้อทันที';
print'<form method=post action=quizjava.pl>';
for $j (0..9) {	
  @recq = split (',',$keepar[$j]); 
  print $j+1,". $recq[1]<ul>";
  print "<input type=radio onclick=$recq[0](1) name=q$recq[0]>$recq[2]<br>";
  print "<input type=radio onclick=$recq[0](2) name=q$recq[0]>$recq[3]<br>";
  print "<input type=radio onclick=$recq[0](3) name=q$recq[0]>$recq[4]<br>";
  print "<input type=radio onclick=$recq[0](4) name=q$recq[0]>$recq[5]<br>";	
  print "<script language=JavaScript>\n";  
  print "function $recq[0](value) {\n";    
  print "if (value == ",substr($recq[6],0,1),") {alert('Right');}";
  print "else {alert('Wrong');}\n";
  print "}\n";
  print "</script>\n";
  print "</ul>";	
}
print'<hr><input type=submit name=submit value=New_quiz>';
print'</form></body></html>';