SOURCE CODE
<?php // ปรับปรุง : 2560-01-19 (เริ่มพัฒนา : 2558-01-22 ปรับจาก test10.php) // ============================= // ลักษณะของโปรแกรม (Program Specification) // - สุ่มทั้ง คำถาม และคำตอบ // - จำนวนแบบทดสอบมีเท่าใดก็ได้ ขึ้นกับแฟ้มแบบทดสอบ โดยไม่ต้องแก้ไขโปรแกรม // - ตัวเลือกมีสูงสุดได้ 7 ตัวเลือก เพราะตัวแปร $c[ ] กำหนดไว้อย่างนั้น // - ฟังก์ชัน session_save_path() ถูกอธิบายใน Short 12 ของ http://www.thaiall.com/php/indexo.html // ============================= if ($_SERVER["SERVER_NAME"] == "www.thaiall.com") session_save_path("/home/users/web/b352/hy.thaiwebsearch/cgi-bin/tmp"); session_start(); // ============================= // Variables 1 $bgcolor = "#ddffdd"; if (isset($_GET["subj"])) $subj = "subj=".$_GET["subj"]; else $subj = ""; if (isset($_SESSION['name'])) $name = $_SESSION['name']; else $name = ""; if (isset($_SESSION['surname'])) $surname = $_SESSION['surname']; else $surname = ""; if (isset($_POST["name"])) { $name = $_POST["name"]; $_SESSION['name'] = $name; } if (isset($_POST["surname"])) { $surname = $_POST["surname"]; $_SESSION['surname'] = $surname; } // ============================= // Variable 2 $version = "1.600119"; $program_name = "test10.php"; $data_name_prefix = "test10"; $directory = "http://www.thaiall.com/quiz/"; $data_name = "computer1"; $score_name = "test10score.txt"; $background = "test10bg.gif"; $t_now = date("M j,y g:i:s"); $total_user = 100; // เก็บข้อมูลสมาชิกเพียง 100 ระเบียนเท่านั้น // ============================= // Variable 3 $google300 = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- 43 quiztest 300 --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-3309619467978767" data-ad-slot="2527426157"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>'; $google728 = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- 43 quiztest 728 --> <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-3309619467978767" data-ad-slot="1050692957"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>'; $google160 = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- 43 quiztest 160 --> <ins class="adsbygoogle" style="display:inline-block;width:160px;height:600px" data-ad-client="ca-pub-3309619467978767" data-ad-slot="4004159354"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>'; // ============================= // Default Variable 3 if (isset($_GET["subj"])) $data_name = $_GET["subj"]; if (isset($_GET["action"])) $data_name = $_GET["action"]; // http://www.firstimpressionsimprinting.com/gpage11.html (tense10.gif = boy) $header = "<html><head><title>แบบทดสอบ ชุด ". $data_name ."</title> <meta http-equiv=content-type content='text/html; charset=windows-874'> <meta name='keywords' content='tense,present,past,future' /> <meta name='description' content='tense is a verb-based method used to indicate the time' /> <link type='text/css' rel='stylesheet' href='rsp62.css'><link rel='icon' type='image/x-icon' href='rsp.ico' /><style type='text/css'> textarea{font-family:microsoft sans serif;font-size:14px;color:blue;background:white;} td{font-family:THChakraPetch,microsoft sans serif;font-size:25px;} body{font-family:THChakraPetch,microsoft sans serif;font-size:30px;} </style></head><body bgcolor=$bgcolor topmargin='0' leftmargin='0' style='background-image:url(" . $background . ")'> <table width=760 align=center cellspacing=1 border=1 bordercolor=black bgcolor=black><td><center>" . $google728 . "</td></table>"; $footer = "<table width=760 align=center cellspacing=1 bgcolor=white><tr><td style='font-size:20px'><center> <a href=". $directory . $program_name ."?action=report>สถิติ 100 รายการ</a> : <a href=". $directory . $program_name ."?$subj>เริ่มใหม่</a> : <a href=test10.gif>ภาพเตรียมข้อสอบ</a> : <a href=?action=source>รหัสต้นฉบับ</a> : รุ่น $version : เวลา : $t_now <table cellspacing=5 cellpadding=0 bgcolor=white> <td valign=top style='font-size:14px;font-family:microsoft sans serif;' width=120px> <b>คอมพิวเตอร์</b><br/> <a href=http://www.thaiall.com/quiz/test10.php?subj=vbnet01>vb.net 1</a><br/> <a href=http://www.thaiall.com/quiz/test10.php?subj=keyapp01>คีย์แอพพลิเคชั่น 1*</a><br/> <a href=http://www.thaiall.com/quiz/test10.php?subj=javaloop1>จาวาทำซ้ำ 1</a><br/> <a href=http://www.thaiall.com/quiz/test10.php?subj=computer1>คอมพิวเตอร์ 1</a><br/> <a href=http://www.thainame.net/quiz/test3.php?subj=burin_computer2>คอมพิวเตอร์ 2</a><br/> </td><td bgcolor=gray width=1px> </td><td valign=top style='font-size:14px;font-family:microsoft sans serif;' width=120px> <b>คณิต</b><br/> <a href=http://www.thaiall.com/quiz/test10.php?subj=math01>บวกเลข 1</a><br/> <a href=http://www.thaiall.com/quiz/test10.php?subj=math02>บวกเลข 2</a><br/> <a href=http://www.thaiall.com/quiz/test10.php?subj=gm101>อนุกรม (ก.พ.)</a><br/> <a href=http://www.thaiall.com/cgi/quiz.pl?math&5>เตรียมสอบ (ก.พ.)</a><br/> <a href=http://www.thainame.net/quiz/test3.php?subj=pepe_math_001>คณิต 1</a><br/> </td><td bgcolor=gray width=1px> </td><td valign=top style='font-size:14px;font-family:microsoft sans serif;' width=120px> <b>อังกฤษ</b><br/> <a href=http://www.thaiall.com/quiz/test10.php?subj=engl101>ถาม - ตอบ</a><br/> <a href=http://www.thaiall.com/quiz/tense10.php?subj=present1>present 1</a><br/> <a href=http://www.thaiall.com/quiz/tense10.php?subj=presentper1>present perfect 1</a><br/> <a href=http://www.thaiall.com/cgi/quiz.pl?operatingsystem&5>อังกฤษเบื้องต้น</a><br/> <a href=http://www.thainame.net/quiz/test3.php?subj=fondao_engl_001>อังกฤษ 1</a><br/> </td><td bgcolor=gray width=1px> </td><td valign=top style='font-size:14px;font-family:microsoft sans serif;' width=120px> <b>ไทย สังคม</b><br/> <a href=http://www.thaiall.com/cgi/quiz.pl?social&5>สังคมศึกษา</a><br/> <a href=http://www.thaiall.com/cgi/quiz.pl?rung&5>ความรู้ทั่วไป</a><br/> <a href=http://www.thainame.net/quiz/test3.php?subj=fondao_thai_001>ไทย f.1</a><br/> <a href=http://www.thainame.net/quiz/test3.php?subj=pepe_thai_001>ไทย p.1</a><br/> <a href=http://www.thainame.net/quiz/test3.php?subj=maya_thai_001>ไทย m.1</a> </td><td bgcolor=gray width=1px> </td><td valign=top style='font-size:14px;font-family:microsoft sans serif;' width=120px> <b>เกี่ยวกับเรา</b><br/> <a href=http://www.thaiall.com/>หน้าหลัก</a><br/> <a href=http://www.thaiall.com/me>ทีมงาน</a><br/> <a href=http://www.thaiall.com/quiz>ศูนย์สอบออนไลน์</a><br/> <a href=http://www.thaiall.com/sponsor>สนับสนุน</a><br/> <a href=http://www.facebook.com/thaiall>facebook page</a> </td></table> <script language=javascript>page='quiz_tense10'</script><script language='javascript1.1' src='http://hits1.truehits.net/data/c0001941.js'></script></td></tr></table> </body></html>"; $error_name = "<table align=center><td bgcolor=white><font color=red size=6>กรอกชื่อ หรือนามสกุล ไม่ครบ<br/>ต้องอ่านคำชี้แจงนะครับ ตอนนี้กลับไป [เริ่มใหม่] ได้เลย</td></table>"; $error_subj = "<table align=center><td bgcolor=white><font color=red size=6>ไม่พบแฟ้มวิชาที่ท่านต้องการสอบ<br/>ต้องกลับไปเลือกวิชาให้ถูกต้อง</td></table>"; $remark = "<tr><td bgcolor=#660000 colspan=2><font color=white> - ถ้าไม่กรอกทั้งชื่อ และสกุล ระบบจะไม่ตรวจให้ <br/>- ถ้าทำแบบทดสอบไม่ครบทุกข้อ จะไม่ตรวจให้ <br/>- ระบบเก็บผลสอบเพียง 100 ระเบียนล่าสุด <br/>- ผลการตรวจจะเผยแพร่ทั้ง ชื่อ สกุล คะแนน และเวลา </td></tr>"; $remark_send = "<font color=red>ต้องกรอกทั้งชื่อ และสกุล และต้องทำทุกข้อ"; // ============================= // View Source Code if (isset($_GET["action"])) { echo $header; if ($_GET["action"] == "source") { $ar = file($program_name); echo "<table align=center width=760><td bgcolor=#dddddd><center><font size=6>SOURCE CODE</font><br/><textarea cols=120 rows=25 wrap=off>"; foreach ($ar as $k=>$v) echo htmlspecialchars($v); echo "</textarea></td></table>"; } if ($_GET["action"] == "report") { $ar = file($score_name); ?> <table width="760" align="center" cellspacing="1" bgcolor="white"><tr><td> <b>ความหมายของการทดสอบ</b> <br/>การทดสอบ (Testing) หรือ การประเมิน (Evaluation) เป็นกลไกสำคัญของการประกันคุณภาพการศึกษา เป็นตัวบ่งชี้ระดับความสามารถของผู้เรียน ซึ่งมี 2 แบบ คือ แบบทดสอบแบบปรนัย เป็นแบบที่เหมาะสำหรับวัดผลการเรียน ของผู้เข้าสอบจำนวนมาก มีความเที่ยงตรง และเกณฑ์การให้คะแนนที่เชื่อถือได้ แบบทดสอบแบบอัตนัย เป็นแบบที่เหมาะกับการวัดความคิดริเริ่มสร้างสรรค์ โดยเปิดให้แสดงความคิดเห็นสำหรับแบบทดสอบที่มีโอกาสถูกได้หลายแบบ แต่ไม่เหมาะกับผู้เข้าสอบจำนวนมาก </td><td width="300"> <center> <?php echo $google300; ?> </center> </td></tr></table> <?php echo "<table width=760 align=center cellspacing=1 bgcolor=#f9f9f9> <tr bgcolor=black align=center><td align=center colspan=7><font color=white size=6>สถิติผู้ทำแบบทดสอบ</td></tr> <tr bgcolor=#dddddd align=center><td>ลำดับ</td><td>ชื่อ-สกุล</td><td>รหัสวิชา</td><td>ถูก</td> <td>ทั้งหมด</td><td>เวลาเริ่ม</td><td>เวลาเสร็จ</td></tr>"; $i=0; $bg = ""; foreach ($ar as $k=>$v) { $i++; if (!isset($_GET["top"]) || $i <= 10) { $ar = split("\t",$v); if (strlen($bg) == 0) $bg = " bgcolor=#ddffff"; else $bg = ""; if ($ar[3] == $ar[4]) $bg = " bgcolor=#ffdddd"; echo "<tr $bg><td>$i</td><td><b>$ar[0] $ar[1]</b></td><td><a href=?subj=$ar[2]>$ar[2]</a></td> <td align=center>$ar[3]</td><td align=center>$ar[4]</td><td>$ar[5]</td><td>$ar[6]</td></tr>"; } } echo "</table>"; } echo $footer; exit; } // ============================= // Get Random value and Read file $cnt_quiz = 0; $data_namef = $data_name_prefix . $data_name . ".php"; if (!file_exists($data_namef)) { echo $error_subj.$footer; exit; } $ar = file($data_namef); foreach ($ar as $v) { $q = split("\t",$v); if (strlen($q[2]) > 0) { // ตรวจว่ามีเฉลยหรือไม่ $qok{$cnt_quiz} = $v; $rnd{$cnt_quiz} = rand(); $cnt_quiz = $cnt_quiz + 1; } } // ============================= // General Variable $c[1] = array(1,2,3,4,7,5,6); $c[2] = array(5,7,2,3,4,1,6); $c[3] = array(4,1,2,5,7,3,6); $c[4] = array(2,3,5,4,1,6,7); $c[5] = array(4,6,7,3,1,2,5); $c[6] = array(7,6,5,2,4,1,3); $c[7] = array(2,4,1,3,7,6,5); // ============================= // Check Answer if (isset($_POST["action"]) && isset($_SESSION['start'])) { echo $header; if ($_POST["action"] == "check") { if (strlen($_POST["name"]) == 0 || strlen($_POST["surname"]) == 0) { echo $error_name.$footer; unset($_SESSION["start"]); exit; } $right = 0; $wrong = 0; $qok{$cnt_quiz} = $v; foreach ($qok as $k=>$v) { $q = split("\t",$v); $qans{$q[0]} = $q[2]; } foreach ($_POST as $k=>$v) { if ($k != "action" && $k != "name" && $k != "surname" && $k != "total" && $k != "subject") { if (strlen($v) > 0) if ($qans{$k} == $v) $right++; else $wrong++; } } $total = $_POST["total"]; if ($total <= ($right + $wrong)) { $wrong = $total - $right; echo "<table width=760 align=center cellspacing=1 bgcolor=white>"; echo "<td><center><font size=6>ผลการสอบ ของ<br/>". $_POST["name"] . " " . $_POST["surname"]; echo "</center><b>ทำถูก</b> = $right"; echo "<br/><b>ทำผิด</b> = $wrong"; echo "<br/><b>ได้ทำ</b> = ". $total; echo "<br/><b>จำนวนข้อ</b> = ". $total; echo "<br/><b>เริ่มทำเวลา</b> = ". $_SESSION['start']; echo "<br/><b>แล้วเสร็จเวลา</b> = ". $t_now; echo "</td></table>"; $data = $_POST["name"]."\t".$_POST["surname"]."\t".$_POST["subject"]."\t"; $data = $data . $right."\t".$total."\t".$_SESSION['start']."\t".$t_now."\n"; $fr = array(); if (file_exists($score_name)) $fr = file($score_name); $limit = count($fr); if ($total_user <= $limit) $limit = $total_user - 1; $fw=fopen ($score_name,"w"); fputs ($fw,$data); for ($i=0;$i<$limit;$i++) fputs ($fw,$fr[$i]); fclose ($fw); echo "<meta http-equiv=refresh content='10;url=". $program_name . "?action=report&top=10'>"; unset($_SESSION["start"]); // session_unset(); } else { echo "<table align=center><td bgcolor=white><center><font color=red size=6>ท่านทำข้อสอบเพียง : " . ($right + $wrong) ." ข้อ<br/>"; echo "ไม่ครบ ". $total . " ข้อ<br/>จึงไม่ตรวจให้ .. ท่านต้องกลับไปทำให้ครบ</td></tr></table>"; } } } else { // ============================= // Show Question $ar = file($data_namef); $q = split("\t",$ar[0]); echo $header; $_SESSION['start'] = $t_now; echo "<form action='$directory". "$program_name' method=post> <table width='760' align='center' border='1' bordercolor='black' cellspacing='0'> <tr><td bgcolor=#dddddd><center><b>Quiz ID : $data_name</b></center>"; asort($rnd); // ทำให้ array จัดเรียงตามค่าสุ่ม $total_question = 0; echo "<table width='600' align='center' style='background-color:#f2f2f2;'>"; $bg = ""; foreach ($rnd as $k=>$v) { $total_question++; $q = split("\t",$qok{$k}); if (strlen($bg) == 0) $bg = " bgcolor='#ffffdd'"; else $bg = ""; echo "<tr $bg><td style='font-size:40px'>"; echo $total_question.". ".$q[1]; $cok = rand(1,7); for($i=3;$i<10;$i++) { if (isset($q[$c[$cok][$i - 3] + 2])) { if (strlen($q[$c[$cok][$i - 3] + 2]) > 0 && $q[$c[$cok][$i - 3] + 2] != "\r\n" && $q[$c[$cok][$i - 3] + 2] != "\n") echo "<dd><input type='radio' name=$q[0] value='". ($c[$cok][$i - 3]) ."'>". $q[$c[$cok][$i - 3] + 2]."</dd>"; } } echo "</td>"; if ($total_question == 1) { echo "<td width=160 valign=top rowspan=10 bgcolor=gray>$google160</td>"; } echo "</tr>"; } echo "<tr><td align='center' bgcolor='" . $bgcolor . "' colspan=2><table bgcolor=white><tr><td>"; if ($_SERVER["SERVER_NAME"] == "www.thaiabc.com") echo "ไม่มีบริการใน thaiabc.com"; else echo "<table width='400' align='center' bgcolor='#dddddd'> <tr><td bgcolor='black' colspan=2><font size='6' color='white'>คำชี้แจง</td></tr> $remark <tr><td align='right'>ชื่อ :</td><td><input name='name' type=textbox size='20' value='$name'> เช่น บุรินทร์</td></tr> <tr><td align='right'>สกุล :</td><td><input name='surname' type=textbox size='20' value='$surname'> เช่น รุจจนพันธุ์</td></tr> </table><center><input type='submit' value='ส่งคำตอบ' style='width:250px;font-size:30px;height:50px;background-color:#ffff00'> <br/>$remark_send <input type='hidden' value='check' name='action'> <input type='hidden' value=$total_question name='total'> <input type='hidden' value=$data_name name='subject'> </form>"; echo "</td><td>" . $google300 . "</td></tr></table></td></table><br/>"; } echo $footer; ?>
สถิติ 100 รายการ
:
เริ่มใหม่
:
ภาพเตรียมข้อสอบ
:
รหัสต้นฉบับ
: รุ่น 1.600119 : เวลา : Dec 5,19 7:03:27
คอมพิวเตอร์
vb.net 1
คีย์แอพพลิเคชั่น 1*
จาวาทำซ้ำ 1
คอมพิวเตอร์ 1
คอมพิวเตอร์ 2
คณิต
บวกเลข 1
บวกเลข 2
อนุกรม (ก.พ.)
เตรียมสอบ (ก.พ.)
คณิต 1
อังกฤษ
ถาม - ตอบ
present 1
present perfect 1
อังกฤษเบื้องต้น
อังกฤษ 1
ไทย สังคม
สังคมศึกษา
ความรู้ทั่วไป
ไทย f.1
ไทย p.1
ไทย m.1
เกี่ยวกับเรา
หน้าหลัก
ทีมงาน
ศูนย์สอบออนไลน์
สนับสนุน
facebook page