|
<% dim connect, rs, sql, scolor, i, qchoose, qprocess, chk qchoose = request.form("subj") + request.querystring("subj") qprocess = request.form("process") + request.querystring("process") if len(qchoose) < 2 then qchoose = "math01" if len(qprocess) < 2 then qprocess = "show" set connect = server.createobject("ADODB.Connection") connect.open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &_ Server.MapPath("\perlphpasp\db\quiz.mdb")) sql = "select * from " + qchoose set rs = connect.execute(sql) %> <html><head><title>Automatic checking</title></head> <body bgcolor="#ffffdd"><font face="microsoft sans serif" size=0><ul> <% if qprocess = "show" then response.write(request.form("subj")) response.write("<form method=post action=quizauto.asp>") response.write("<input name=subj type=hidden value=" & qchoose &">") response.write("<input name=process type=hidden value=check>") i = 1 if Not rs.eof then rs.MoveFirst do while Not rs.eof and i <= 10 response.write("<hr><b>"&i& "." &rs("question")&"</b> "&rs("qid")&_ "<br><input type=hidden name=gqid" & i & " value=" &rs("qid") &">"&_ "<input type=hidden name=gans" & i & " value=" &rs("ans") &">"&_ "<input type=radio name=c"&i&" value=1>a. "&rs("choice1")&"<br>"&_ "<input type=radio name=c"&i&" value=2>b. "&rs("choice2")&"<br>"&_ "<input type=radio name=c"&i&" value=3>c. "&rs("choice3")&"<br>"&_ "<input type=radio name=c"&i&" value=4>d. "&rs("choice4")&"<br>") rs.MoveNext i = i + 1 loop response.write( "<input type=submit name=submit value=SendAns>" ) response.write( "<input type=reset name=reset value=Reset></form>" ) else i = 1 if Not rs.eof then rs.MoveFirst do while Not rs.eof and i <= 10 g_qid = request.form("gqid" & i) g_ans = request.form("gans" & i) g_c = request.form("c" & i) response.write( "<hr>"& i & "." & rs("question") & rs("qid") &"<br>") if g_qid = rs("qid") then if g_ans = 1 then chk="/" else chk="X" end if response.write(chk & "a. "& rs("choice1") &"<br>") if g_ans = 2 then chk="/" else chk="X" end if response.write(chk & "b. "& rs("choice2") &"<br>") if g_ans = 3 then chk="/" else chk="X" end if response.write(chk & "c. "& rs("choice3") &"<br>") if g_ans = 4 then chk="/" else chk="X" end if response.write(chk & "d. "& rs("choice4") &"<br>") if g_ans = g_c then response.write("Right.") else response.write("Wrong. Try again. [" & g_c & "]") end if end if rs.MoveNext i = i + 1 loop end if connect.close set rs = nothing set connect = nothing %> </ul></body></html> |