001.
<?php
002.
require
(
"connect_inc.php"
);
003.
session_start();
004.
$_SESSION
[sess_userstudent];
005.
$User
=
$_SESSION
[sess_userstudent];
006.
$_SESSION
[sess_surname];
007.
$surname
=
$_SESSION
[sess_surname];
008.
$_SESSION
[sess_ID];
009.
$ID
=
$_SESSION
[sess_ID];
010.
$_SESSION
[IDtest];
011.
$IDtest
=
$_GET
[
'id'
];
012.
$_SESSION
[IDtest]=
$IDtest
;
013.
$score
=0;
014.
$addscore
=
"INSERT INTO t_score (IDtest,IDstudent,score) VALUE ('"
.
$IDtest
.
"','"
.
$ID
.
"', '"
.
$score
.
"')"
;
015.
$rescore
=mysql_db_query (
"onlinetest"
,
$addscore
);
016.
$sql
=
"select * from test WHERE IDtest='$IDtest'"
;
017.
$result
= mysql_db_query(
"onlinetest"
,
$sql
);
018.
while
(
$rows
= mysql_fetch_array(
$result
) )
019.
{
020.
$testQ
=
$rows
[
'testQ'
];
021.
$time
=
$rows
[
'limittime'
];
022.
$a
=
substr
(
$time
,6,2);
023.
$b
=
substr
(
$time
,3,2);
024.
$c
=
substr
(
$time
,0,2);
025.
$timem
=
$a
.
":"
.
$b
.
":"
.
$c
;
026.
}
027.
?>
030.
<head>
031.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=windows-874"
/>
032.
<title></title>
033.
<meta name=
"keywords"
content=
"Business Website, free templates, website templates, 3-column layout, CSS, XHTML"
/>
034.
<meta name=
"description"
content=
"Business Website, 3-column layout, free CSS template from templatemo.com"
/>
035.
<link href=
"templatemo_style.css"
rel=
"stylesheet"
type=
"text/css"
/>
036.
037.
<style type=
"text/css"
>
038.
<!--
039.
.style1 {color: #000000}
040.
-->
041.
</style>
042.
</head>
043.
044.
<body>
045.
<div id=
"templatemo_container"
>
046.
047.
<div id=
"templatemo_header"
>
048.
<div id=
"logosection"
>
049.
<div
class
=
"sitelogo"
></div>
050.
<div
class
=
"sitename"
>
051.
Online<span></span> </div>
052.
</div>
053.
<div id=
"header"
>
054.
<div
class
=
"title"
>
055.
Online<br />
056.
<span
class
=
"bigtext"
>Test Management</span><br />
057.
System.</div>
058.
059.
</div>
060.
</div>
061.
062.
<div id=
"templatemo_menu"
>
063.
<div id=
"search"
>
064.
065.
</div>
066.
<div id=
"menu"
>
067.
<ul>
068.
<li><a href=
"course_student.php"
class
=
"current"
>รายวิชาที่เรียน</a></li>
069.
<li><a href=
"edit_student.php"
>แก้ไขข้อมูลส่วนตัว</a> </li></ul>
070.
</div>
071.
</div>
072.
073.
<!-- start of content -->
074.
075.
<div id=
"templatemo_content"
>
076.
077.
<!-- start of left column -->
078.
079.
<div id=
"templatemo_left_column"
>
080.
081.
<div id=
"leftcolumn_box01"
>
082.
<div
class
=
"leftcolumn_box01_top"
>
083.
<h2 >ยินดีต้อนรับ</h2>
084.
<h2>คุณ<?php
echo
"$User"
; ?> <?php
echo
"$surname"
;?></h2>
085.
</div>
086.
<div
class
=
"leftcolumn_box01_bottom"
></div>
087.
</div>
088.
<div>
089.
<a href=
"logout.php"
>Logout</a>
090.
</div>
091.
<div id=
"leftcolumn_box02"
>
092.
<h2>คณะ</h2>
093.
<ul>
095.
<li><a href=
"http://ict.up.ac.th"
target=
"_parent"
>คณะเทคโนโลยีสารสนเทศและการสื่อสาร</a></li>
105.
<li><a href=
""
>คณะสถาปัตยกรรมศาสตร์และศิลปกรรมศาสตร์</a></li>
108.
109.
</ul>
110.
</div>
111.
<div id=
"imagebutton"
>
112.
114.
</div>
115.
116.
</div>
117.
118.
<!--
end
of left column -->
119.
120.
<!-- start of middle column -->
121.
122.
<div id=
"templatemo_middle_column"
>
123.
<body onLoad=
"begintimer()"
>
124.
<script language=
""
>
125.
var
limit=
"<?=$timem?>"
126.
if
(document.images){
127.
var
parselimit=limit.split(
":"
)
128.
parselimit=parselimit[0]*3600+parselimit[1]*60+parselimit[2]*1
129.
}
130.
function
begintimer(){
131.
if
(!document.images)
132.
return
133.
if
(parselimit==1)
134.
135.
136.
frmTest.submit();
137.
else
{
138.
parselimit-=1
139.
curmin=Math.
floor
(parselimit/60)
140.
cursec=parselimit%60
141.
if
(curmin!=0)
142.
curtime=
"เวลาที่เหลือ<font color=red> "
+curmin+
" </font>นาที กับ <font color=red>"
+cursec+
" </font>วินาที "
143.
144.
else
145.
if
(cursec==0)
146.
{
147.
alert(
'หมดเวลาแล้ว'
);
148.
}
149.
else
150.
{
151.
curtime=
"เวลาที่เหลือ <font color=red>"
+cursec+
" </font>วินาที "
152.
}
153.
document.getElementById(
'dplay'
).innerHTML = curtime;
154.
setTimeout(
"begintimer()"
,1000)
155.
}
156.
}
157.
158.
</script>
159.
<div id=dplay ></div>
160.
<form name=
"frmTest"
action=
"check_online.php"
method=
"post"
>
161.
<?
162.
$link
= mysql_connect(
"localhost"
,
"root"
,
"root"
);
163.
mysql_query(
"SET NAMES TIS620"
);
164.
if
(!
$link
)
165.
{
166.
print
"Error connecting"
;
167.
}
168.
else
169.
{
170.
171.
mysql_select_db(
"onlinetest"
,
$link
);
172.
$sqlnow_test
=
""
;
173.
$now_test
= mysql_query(
$sql1
,
$link
);
174.
echo
"<table>"
;
175.
echo
"<tr>"
;
176.
echo
"<td align='left'>"
;
177.
$sql1
=
"select IDquestion from testquestion WHERE testquestion.IDtest='$IDtest' AND IDquestion LIKE 'C%' ORDER BY rand()"
;
178.
179.
$IDQ
[test] = mysql_query(
$sql1
,
$link
);
180.
$Num_Rows
= mysql_num_rows(
$IDQ
[test] );
181.
$Per_Page
= 1;
182.
183.
$Page
=
$_GET
[
"Page"
];
184.
if
(!
$_GET
[
"Page"
])
185.
{
186.
$Page
=1;
187.
}
188.
189.
$Prev_Page
=
$Page
-1;
190.
$Next_Page
=
$Page
+1;
191.
192.
$Page_Start
= ((
$Per_Page
*
$Page
)-
$Per_Page
);
193.
if
(
$Num_Rows
<=
$Per_Page
)
194.
{
195.
$Num_Pages
=1;
196.
}
197.
else
if
((
$Num_Rows
%
$Per_Page
)==0)
198.
{
199.
$Num_Pages
=(
$Num_Rows
/
$Per_Page
) ;
200.
}
201.
else
202.
{
203.
$Num_Pages
=(
$Num_Rows
/
$Per_Page
)+1;
204.
$Num_Pages
= (int)
$Num_Pages
;
205.
}
206.
207.
$sql1
.=
" LIMIT $Page_Start , $Per_Page"
;
208.
$IDQ
[test] = mysql_query(
$sql1
,
$link
);
209.
210.
211.
212.
213.
214.
215.
216.
217.
$i
=0;
218.
$c
=0;
219.
$b
=0;
220.
while
(
$IDquestion
[test] = mysql_fetch_array(
$IDQ
[test] ) )
221.
{
222.
$i
++;
223.
$IDC
=0;
224.
$sql2
=
"SELECT * FROM choice WHERE IDquestion='"
.
$IDquestion
[test][IDquestion].
"'"
;
225.
226.
$IDchoice
[question]= mysql_query(
$sql2
,
$link
);
227.
while
(
$choice
[q]=mysql_fetch_array(
$IDchoice
[question] ) )
228.
{
$IDC
++;
229.
$IDQ
[
$IDC
]=
$choice
[q][IDquestion];
230.
echo
$i
.
" "
.
$choice
[q][question];
231.
$w
=
$choice
[q] [answer];
232.
$x
=
$choice
[q] [choice1];
233.
$y
=
$choice
[q] [choice2];
234.
$z
=
$choice
[q] [choice3];
235.
$pic
=
$choice
[q] [pic_c];
236.
$arr
=
array
(
$w
,
$x
,
$y
,
$z
);
237.
shuffle(
$arr
);
238.
echo
"$IDQ[6]<br>\n"
;
239.
$Url2
=
"imageupload/"
;
240.
if
(
$pic
!=
""
){
241.
?>
242.
<div style=
"width:560px; overflow:auto;"
><img src=
"imageupload/<?=$pic?>"
/></div>
243.
<?php
244.
}
245.
echo
"<input type=radio name='choice[$c]' value='$IDQ[$IDC]$arr[0]' > $arr[0]<br>\n"
;
246.
echo
"<input type=radio name='choice[$c]' value='$IDQ[$IDC]$arr[1]' > $arr[1]<br>\n"
;
247.
echo
"<input type=radio name='choice[$c]' value='$IDQ[$IDC]$arr[2]'> $arr[2]<br>\n"
;
248.
echo
"<input type=radio name='choice[$c]' value='$IDQ[$IDC]$arr[3]'> $arr[3]<br>\n\n"
;
249.
$c
++;
250.
echo
"<br>\n"
;
251.
}
252.
}
253.
echo
"</td>"
;
254.
echo
"</tr>"
;
255.
echo
"</table>"
;
256.
echo
"<table>"
;
257.
echo
"<tr>"
;
258.
echo
"<td align='left'>"
;
259.
$_SESSION
[countC]=
$c
;
260.
261.
262.
263.
?>
264.
Total <?=
$Num_Rows
;?> Record : <?=
$Num_Pages
;?> Page :
265.
<?
266.
if
(
$Prev_Page
)
267.
{
268.
echo
" <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> "
;
269.
}
270.
271.
for
(
$i
=1;
$i
<=
$Num_Pages
;
$i
++){
272.
if
(
$i
!=
$Page
)
273.
{
274.
echo
"[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]"
;
275.
}
276.
else
277.
{
278.
echo
"<b> $i </b>"
;
279.
}
280.
}
281.
if
(
$Page
!=
$Num_Pages
)
282.
{
283.
echo
" <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> "
;
284.
}
285.
mysql_close(
$link
);
286.
287.
echo
"</tr>"
;
288.
echo
"</table>"
;
289.
}
290.
print
"<input type=submit align='left' value='ตรวจ'>"
;
291.
print
"</form>"
;
292.
293.
?>
294.
</form>
295.
</div>
296.
<div id=
"templatemo_footer"
>
297.
Phayao University . All rights reserved
298.
Tumbol Maeka Muang Phayao 56000
299.
Tel : (054) 466666 Fax : (054) 466690
300.
</div>
301.
302.
</div>
303.
</body>
304.
</html>