
01/04/2009, 14:43
|
| | Fecha de Ingreso: enero-2009
Mensajes: 112
Antigüedad: 16 años, 3 meses Puntos: 0 | |
Respuesta: examen on line este es el codigo que estoy empleando:
<%set oConn=Server.CreateObject("ADODB.Connection")
oConn.Open (application("DBConn"))
set ra=createobject("ADODB.Recordset")
%>
<%if isarray(session("mytest"))=false then
idtest=request("idtest")
if idtest="" then response.redirect "default.asp"
dim pmytest(25,1)
sqltxt="select idpregunta from preguntas where idtest="&idtest
ra.open sqltxt,oconn
if ra.eof then
ra.close
set ra=nothing
oconn.close
set oconn=nothing
response.redirect "resettest.asp"
end if
i=0
do while not ra.eof 'se realiza el vector con los id de las preguntas
i=i+1
pmytest(i,0)=ra("idpregunta")
pmytest(i,1)=0
ra.movenext
loop
ra.close 'VERIFICAR LOS PARENTESIS
sqltxt="select titulo from test where idtest="&idtest
ra.open sqltxt,oconn
titulo=ra("titulo")
ra.close
session("npreguntas")=i
session("test")=idtest
session("titulo")=titulo
session("posicion")=1
posicion=1
session("mytest")=pmytest
session("nick")=trim(request.form("nick"))
else
pmytest=session("mytest")
posicion=session("posicion")
pmytest(posicion,1)=request.form("r1")
session("mytest")=pmytest
if posicion <= session("npreguntas") then
posicion=posicion+1
session("posicion")=posicion
end if
end if
if pmytest(posicion,0)<>"" then
%>
<html>
<head>
<title>Test </title>
</head>
<body>
</p>
<form method="POST" action="test.asp" id="form1" name="form1">
<div align="center">
<center>
<table border="1" width="90%">
<tr>
<td width="100%" bgcolor="#B12148" align="center">
<p align="center"><font color="#FFFFFF" face="Verdana" size="2"><b><%=session("titulo")%></b></font><font color="#FFFFFF" face="Verdana" size="1"><b> &n bsp; &nbs p; &n bsp; &nbs p;
Pregunta <%=session("posicion")%> de <%=session("npreguntas")%></b></font></td>
</tr>
<tr>
<td width="100%">
<div align="center">
<center>
<%idpregunta=pmytest(posicion,0)
sqltxt="select * from preguntas where idpregunta="&idpregunta
ra.open sqltxt,oconn
%>
<table border="0" width="90%">
<tr>
<td width="100%" colspan="2" align="center"><font face="Verdana" size="2"><b><%=ra("texto")%>
</b></font>
</td>
</tr>
<tr>
<td width="100%" colspan="2">
<p align="center"> </td>
</tr>
<tr>
<td width="100%" colspan="2">
<div align="center">
<center>
<table border="0" width="50%">
<%if ra("opcion1")<>"" then%>
<tr>
<td width="10%"><font face="Verdana" size="1"><input type="radio" value="1" name="R1"></font></td>
<td width="90%"><font face="Verdana" size="1"><%=ra("opcion1")%></font></td>
</tr>
<%end if%>
<%if ra("opcion2")<>"" then%>
<tr>
<td width="10%"><font face="Verdana" size="1"><input type="radio" value="2" name="R1"></font></td>
<td width="90%"><font face="Verdana" size="1"><%=ra("opcion2")%></font></td>
</tr>
<%end if%>
<%if ra("opcion3")<>"" then%>
<tr>
<td width="10%"><font face="Verdana" size="1"><input type="radio" value="3" name="R1"></font></td>
<td width="90%"><font face="Verdana" size="1"><%=ra("opcion3")%></font></td>
</tr>
<%end if%>
<%if ra("opcion4")<>"" then%>
<tr>
<td width="10%"><font face="Verdana" size="1"><input type="radio" value="4" name="R1"></font></td>
<td width="90%"><font face="Verdana" size="1"><%=ra("opcion4")%></font></td>
</tr>
<%end if
ra.close%>
</table>
</center>
</div>
</td>
</tr>
<tr>
<td width="100%">
</td>
</tr>
<tr>
<td width="100%">
<p align="center"><input type="submit" value="Enviar" name="B1"></td>
</tr>
</table>
</center>
</div>
<p align="center">
</form>
<%else
correctas=0
incorrectas=0
enblanco=0
sqltxt="select idpregunta, respuestacorrecta from preguntas where idtest="&session("test")
ra.open sqltxt,oconn
do while not ra.eof
for i=1 to session("npreguntas")
if pmytest(i,0)=ra("idpregunta") then
if pmytest(i,1)<>"" then
if cint(pmytest(i,1))=ra("respuestacorrecta") then
correctas=correctas+1
else
incorrectas=incorrectas+1
end if
else
enblanco=enblanco+1
end if
end if
next
ra.movenext
loop
ra.close
pcorrectas=correctas*10/session("npreguntas")
pincorrectas=incorrectas*(10/session("npreguntas")/2)*-1
total=pcorrectas+pincorrectas
if total<0 then total=0
if session("apuntar")<>"ok" then
Const adOpenKeyset = 1
Const adLockOptimistic = 3
ra.CursorType = adOpenKeyset
ra.LockType = adLockOptimistic
ra.open "puntuaciones",oconn
ra.addnew
ra("idtest")=cint(session("test"))
ra("puntuacion")=total
ra("fecha")=date()
if session("nick")="" then
nick="Anonimo"
else
nick=session("nick")
end if
ra("nick")=nick
ra.update
ra.close
session("apuntar")="ok"
end if
%>
</div>
</center>
</p>
<div align="center">
<center>
<table border="0" width="80%">
<tr>
<td width="100%" colspan="4" bgcolor="#B12148">
<p align="center"><font color="#FFFFFF"><%=session("titulo")%></font></td>
</tr>
<tr>
<td width="33%" valign="middle" bgcolor="#CDB1B7"><font face="Verdana" size="1"><b>Respuestas correctas</b></font></td>
<td width="7%" valign="middle" align="center" bgcolor="#CDB1B7"><font face="Verdana" size="1" color="#0000FF"><b><%=correctas%></b></font></td>
<%ancho=correctas/session("npreguntas")*100 %>
<td width="39%" bgcolor="#CDB1B7"><img border="0" src="barrav.gif" width="<%=ancho%>%" height="25"></td>
<td width="21%" align="right" valign="middle" bgcolor="#CDB1B7"><font face="Verdana" size="1"><b><%=formatnumber(pcorrectas,2)%> puntos</b></font></td>
</tr>
<tr>
<td width="33%" valign="middle" bgcolor="#CDB1B7"><font face="Verdana" size="1"><b>Respuestas incorrectas</b></font></td>
<td width="7%" valign="middle" align="center" bgcolor="#CDB1B7"><font face="Verdana" size="1" color="#0000FF"><b><%=incorrectas%></b></font></td>
<%ancho=incorrectas/session("npreguntas")*100 %>
<td width="39%" bgcolor="#CDB1B7"><img border="0" src="barrar.gif" width="<%=ancho%>%" height="25"></td>
<td width="21%" align="right" valign="middle" bgcolor="#CDB1B7"><font face="Verdana" size="1"><b><%=formatnumber(pincorrectas,2)%> puntos</b></font></td>
</tr>
<tr>
<td width="33%" valign="middle" bgcolor="#CDB1B7"><font face="Verdana" size="1"><b>Respuestas en blanco</b></font></td>
<td width="7%" valign="middle" align="center" bgcolor="#CDB1B7"><font face="Verdana" size="1" color="#0000FF"><b><%=enblanco%></b></font></td>
<%ancho=enblanco/session("npreguntas")*100 %>
<td width="39%" bgcolor="#CDB1B7"><img border="0" src="barran.gif" width="<%=ancho%>%" height="25"></td>
<td width="21%" align="right" valign="middle" bgcolor="#CDB1B7"></td>
</tr>
<tr>
<td width="33%" valign="middle" bgcolor="#CDB1B7"><font face="Verdana" size="1"><b>Calificación (sobre 10):</b></font></td>
<td width="7%" valign="middle" align="center" bgcolor="#CDB1B7">
<p align="center"><font face="Verdana" size="1" color="#0000FF"><b>
<%if total>=5 then%>
<img border="0" src="bien.gif"> </b></font></p>
<%else%>
<img border="0" src="mal.gif"> </b></font></p>
<%end if%>
</td>
<%ancho=total/session("npreguntas")*100 %>
<td width="39%" bgcolor="#CDB1B7"><img border="0" src="barraa.gif" width="<%=ancho%>%" height="25"></td>
<td width="21%" align="right" valign="middle" bgcolor="#CDB1B7"><font face="Verdana" size="1" color="#0000FF"><b><%=formatnumber(total,2)%> puntos</font></b></td>
</tr>
</table>
</center>
</div>
<p align="center">
<div align="center">
<center>
<table border="0" width="80%" bgcolor="#B12148">
<tr>
<td width="33%" align="center" bgcolor="#FFFFFF"><a href="resettest.asp?idtest=<%=session("test")%>">< font face="Verdana" size="1"><b>repetir el examen</b></font></a></td>
<td width="33%" align="center" bgcolor="#FFFFFF"><b><font face="Verdana" size="1"><a href="verrespuestas.asp?idtest=<%=session("test")% >">Ver
las respuestas correctas</a></font></b></td>
<td width="34%" align="center" bgcolor="#FFFFFF"><b><font face="Verdana" size="1"><a href="resettest.asp">Hacer otro test</a></font></b></td>
</tr>
</table>
</center>
</div>
<p align="center"> </p> |