<!-- #include file="../include/skin.asp" -->  <!-- 调用skin皮肤系统设置页面 -->
<!-- #include file="include/config.asp" -->
<!-- #include file="ontest_data.asp"-->
<%
dim idd,tsql,tname,tips,tid,qname
idd=trim(request.querystring("id"))
if not(isnumeric(idd)) then
  call format_redirect("ontest_index.asp")
end if
tid=trim(request.querystring("type"))
%>
<!-- #include file="../include/jk_ubb.asp" -->
<!-- #include file="../include/jk_review.asp" -->
<!-- #include file="../include/jk_keyes.asp" -->
<!-- #include file="../include/jk_emoney.asp" -->
<%
web_width="777"           '设置页面宽度
tit="在线测试"            '页面名称
call web_head(0,0,2,0,0)  '设置页面头部信息及显示形式,浏览权限等
%>
<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td width="600" height="23" background="ontest/bg1.gif">
    <table border="0" cellspacing="0" width="600" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111">
      <tr>
        <td width="25">
        <img border="0" src="ontest/err1.gif" width="24" height="23"></td>
        <td width="536" align="left">
        <table border="0" cellspacing="0" width="40%" cellpadding="0" height="15">
          <tr>
            <td width="100%" valign="bottom" height="15">&nbsp;&nbsp;
            <font color="#FF0000">
			<%
			sql="select type_name from type where id="&tid
      set rs=testconn.execute(sql)
		  response.write rs("type_name")&"测试"
		  rs.close
      set rs=nothing 
			%>            
            </font></td>
          </tr>
        </table>
        </td>
        <td width="39" valign="bottom" style="border-right: 1px solid #000000">
        <a href="javascript:history.go(-1)">
        <img border="0" src="ontest/help.gif" start="fileopen" width="15" height="18" align="absbottom"></a>
        <img border="0" src="ontest/close.gif" align="absbottom"></td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td height="562" valign="top" style="border-left: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000">
    <div align="center">
      <center>
      <table border="1" cellspacing="1" height="560" style="border-collapse: collapse; border-left: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000" width="596" bgcolor="#ECEDEF">
        <tr>
          <td width="100%" background="ontest/bg2.gif"> 
          <div align="center">
            <center>
            <table border="0" cellspacing="0" width="90%" cellpadding="0" height="140">
              <tr>
                <td width="100%" height="513">
					 <table border="0" cellpadding="4" cellspacing="0" width="500" height="85">
  <tr>
    <td width="517" height="52" align="center"><span
    style="font-family: 宋体; font-size: 6pt">◆◇</span><font
    color="#0000FF"><strong><span style="font-family: 宋体; font-size: 12pt">
    <%
    tsql="select * from ontest where id="&idd
    set trs=testconn.execute(tsql)
    if trs("hidden")=false then
    	trs.close
    	response.write vbcrlf&"<script language=javascript>alert(""该测试设定为隐藏或未通过管理员审核！"");history.back();</script>"
    end if
    tname=trs("name")
    emoney=trs("emoney")
    counter=trs("counter")
    istop=trs("istop")
    tim=trs("tim")
    tips=trs("tips")
		trs.close
	  set trs=nothing 
tips=code_jk(tips)
tim=joekoe_cms.time_type(tim,1)
tname=joekoe_cms.code_html(tname,1,0)
    response.write tname
    %>
    	</span></strong></font><span style="font-family: 宋体; font-size: 6pt">◇◆</span></td>
  </tr>
  <tr>
  <td align=right>
  	<%
  	if istop=true then
  		response.write vbcrlf&"<font color=red>[推荐]</font>"
  	end if
  	response.write vbcrlf&"<font color=gray>发布日期："&tim&"</font> 测试："&counter&"人次"
  	%>
  	</td>
  </tr>
    <tr>
  <td align=center>&nbsp;
  	<%
  	if emoney<>0 and emoney<>"" then
  		response.write vbcrlf&"<font color=red>[注意]此测试为付费测试，点击测试将扣除您 <b>"&emoney&"</b> 元</font>"
  	end if
  	%>
  	&nbsp;</td>
  </tr>
  <tr>
    <td width="517" height="17"><span
    style="font-family: 宋体; font-size: 9pt; line-height: 15px"><%response.write tips%></span></td>
  </tr>
</table>
<%
action=trim(request.querystring("action"))

if action="chk" then
  call ontest_chk()
else
  call ontest_show()
end if
%>
                </td>
              </tr>
              <tr>
                <td width="100%" height="35" valign="bottom">
                <p align="center"><a href="javascript:history.go(-1)">
                <img border="0" src="ontest/goback.gif"></a></td>
              </tr>
            </table>
            </center>
          </div>
          </td>
        </tr>
      </table>
      </center>
    </div>
    </td>
  </tr>
</table>

<%
sub ontest_chk()
dim q_id,coins,result
call emoney_notes("",emoney,"在线测试",idd,1,"?type="&tid&"&id="&idd)
coins=0
for i=1 to trim(request.form("suma"))
	a_id=trim(request.form("p"&i&""))
	if a_id<>"" then
  dsql="select coin from answer where a_id="&a_id
  set drs=testconn.execute(dsql)
  coins=coins+drs("coin")
  drs.close
  set drs=nothing
end if
next

sql="select top 1 coin1,coin2,result from result where t_id="&idd&" and coin1<="&coins&" and coin2>"&coins
set rs=testconn.execute(sql)
result=rs("result")
rs.close
set rs=nothing
response.write vbcrlf&"<div align='left'><table border=0 cellpadding=10 cellspacing=0 width=517 height=388><tr><td width='517' height='1'>"&_
               vbcrlf&"<span style='font-family: 宋体; font-size: 9pt; line-height: 15px'>您的得分："&coins&"分<br>测试结果："&code_jk(result)&"<br>"&_
               vbcrlf&"</span></td></tr></table>" 
testconn.execute("update ontest set [counter]=[counter]+1 where id="&idd)
end sub

sub ontest_show()
%>
<form name="show_frm" action="?action=chk&type=<%response.write tid%>&id=<%response.write idd%>"  method=post>
  <div align="left"><table border="0" cellpadding="10" cellspacing="0" width="517" height="388">
  <%
  dim questions,sj,qid,aid
  sj=1
  suma=0
			sql="select q_id,question from question where t_id="&idd
				set rs=testconn.execute(sql)
				do while not rs.eof
				qid=rs("q_id")
				questions=rs("question")
			  response.write vbcrlf&"<tr><td width='517' height='1'>"&_
			                 vbcrlf&"<span style='font-family: 宋体; font-size: 9pt; line-height: 15px'>"&sj&"、"&code_jk(questions)&"<br>"
		    i=0
				dsql="select a_id,answer from answer where q_id="&qid
				set drs=testconn.execute(dsql)
				do while not drs.eof
				aid=drs("a_id")
				answer=drs("answer")
		    response.write vbcrlf&" "&Chr(i+65)&"<input name='p"&sj&"' type='radio' value="&aid&">"&answer&" "
						i=i+1
				drs.movenext
				loop
				drs.close
				set drs=nothing
				sj=sj+1
				rs.movenext
				loop
				rs.close
				set rs=nothing
						response.write vbcrlf&"<input type='hidden' name=suma value='"&sj&"'></span></td></tr>"
  %>
    <tr>
      <td width="517" height="25" align="center">
      	<span style="font-family: 宋体; font-size: 9pt; line-height: 15px"><input type="submit" class="btn"
      value="都选择完了，结果怎样?" style="font-size: 9pt; font-family: 宋体"></span>
      </td>
    </tr>
  </table>
  </div>
</form>
<%
end sub
'----------------------------结束 自定义页面结束----------------------------
call web_end(0,0)    '调用页面底部信息
%>