
27/04/2009, 15:15
|
| | Fecha de Ingreso: enero-2009
Mensajes: 112
Antigüedad: 16 años, 3 meses Puntos: 0 | |
Respuesta: mi aplicacion no suma los valores que deberia aqui les va chico espero me puedan ayudar, mil gracias..
<%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()
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") 'se cambio la linea a form1 a r1
session("mytest")=pmytest
if posicion <= session("npreguntas") then
posicion=posicion+1
session("posicion")=posicion
end if
end if
if pmytest(posicion,0)<>"" then
dim row
%>
<html>
<head>
<title>Test </title>
</head>
<body>
</p>
<form method="POST" action="test.asp" id="R1" name="R1">
<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>
Pregunta <%=session("posicion")%> de <%=session("npreguntas")%></b></font></td>
</tr>
<tr>
<td width="100%">
<div align="center">
<center>
<%idpregunta=pmytest(posicion,0)
sqltxt="select newid() as row, opcion1, opcion2, opcion3, opcion4, texto, respuestacorrecta from Preguntas order by row"
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="R1"></td>
</tr>
</table>
</center>
</div>
<p align="center">
</form>
<%else
correctas=0
ncorrectas=0
nblanco=0
sqltxt="select idpregunta, respuestacorrecta from preguntas where idtest="&session("test")
ra.open sqltxt,oconn,adOpenKeyset,adLockOptimistic
do while not ra.eof
for i=1 to session("npreguntas")
if pmytest(i,0)=ra("idpregunta") then
if pmytest(i,1)<>"" then
if (pmytest(i,1))= ra("respuestacorrecta") then '***LINEA 162***se elimino el cint
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
adLockOptimistic
ra.open "puntuaciones", oconn
ra.addnew
ra("idtest")=(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%"> |