Recomendado: ASP utiliza XML para empaquetar la carpeta especificada y cargarla en el directorio web, desactivarlo por sí mismo '=============================== 4 Archivos =================================
El código de ejemplo para Q&A en línea ASP es el archivo HTML, que es Test.asp, y el código es el siguiente:
- <%@Idioma = vBscriptCodePage = 936%>
- <%
- ifsession (nombre de usuario) = entonces
- Response.Write (<Script> Alert ('¡Inicie sesión y luego realice operaciones!'); Window.location = 'Login.asp? Reurl = test.asp'; </script>)
- Respuesta.end ()
- endif
- %>
- <! DOCTYPEHTMLPublic-// w3c // dtdxhtml1.0Transitional // gohttp: //www.w3.org/tr/xhtml1/dtd/xhtml1-transicional.dtd>
- <htmlxmlns = http: //www.w3.org/1999/xhtml>
- <Evista>
- <metahttp-oquiv = content-typeContent = text/html; charset = gb2312/>
- <title> Scenario Q&A </title>
- <styletype = text/css>
- <!-
- cuerpo{}{
- tamaño de fuente: 12px;
- Color:#0066ff;
- }
- aporte{}{
- borde: 1pxsolid#ffffff;
- Color de fondo: #EEEEE;
- Izquierda: 1px;
- arriba: 1px;
- Derecha: 1px;
- Abajo: 1px;
- clip: rect (10px, 10px, 10px, 10px);
- margen: 1px;
- relleno: 1px;
- }
- ->
- </style>
- </ablo>
- <scriptLanguage = javaScript>
- <!-
- functionChkform ()
- {
- VARE = document.frm;
- Varit, bandera, i;
- bandera = falso;
- para (i = 1; i <= 10; i ++)
- {
- variante = eval (E.Question+i);
- variantlen = eval (e.question+i+.length);
- para (varj = 0; j <itlen; j ++)
- {
- varitchk = eval (E.Question+i+[+j+]. versidado);
- if (itchk)
- {
- bandera = verdadero;
- romper;
- }
- if (! itchk && j == itlen-1)
- {
- bandera = falso;
- romper;
- }
- }
- if (! flag)
- {
- alerta (seleccione la respuesta a la pregunta +i +);
- returnfalse;
- }
- }
- if (! flag)
- {
- alerta (seleccione la respuesta a la pregunta +i +);
- eval (E.Question+i+.focus ());
- returnfalse;
- }
- returnTrue;
- }
- ->
- </script>
- <Body>
- <div> <strong> Scenario Q&A </strong> </div>
- <formname = frmaction = test_do.aspmethod = postsubmit = return (chkform ());>
- <p> <br/>
- 1. ¿Cuál es el nombre de la heroína en Olvided and Down? <br/>
- <Tabel>
- <inputType = radioname = cuestion1Value = a/>
- A. </etlabe>
- Lan <br/>
- <Tabel>
- <inputType = radioname = cuestion1Value = b/>
- B. </selabel>
- Jenny <br/> <label>
- <inputType = radioname = cuestion1Value = c/>
- C. </etlabe> Lucy </p>
- <p> 2. ¿Cuál es el nombre del bar en el pasado de la música? <br/>
- <Tabel>
- <inputType = radioname = cuestion2Value = a/>
- A. </etlabe>
- Olvidado <br/>
- <Tabel>
- <inputType = radioname = cuestion2Value = b/>
- B. </selabel>
- NV <br/>
- <Tabel>
- <inputType = radioname = cuestion2Value = c/>
- C
- Como una sombra </p>
- <p> 3. ¿Qué fotos hay en la pared de la foto olvidada? <br/>
- <Tabel>
- <inputType = radioname = cuestion3Value = a/>
- A. </etlabe>
- La heroína del pasado <br/>
- <Tabel>
- <inputType = radioname = cuestion3Value = b/>
- B. </selabel>
- El paisaje junto al mar <br/>
- <Tabel>
- <inputType = radioname = cuestion3Value = c/>
- C
- Exterior de barra </p>
- <p> 4. ¿Cuál es el nombre del vino la heroína bebidas en la música pasada? <br/>
- <Tabel>
- <inputType = radioname = cuestion4Value = a/>
- A. </etlabe>
- Belleza rosa roja <br/>
- <Tabel>
- <inputType = radioname = cuestion4Value = b/>
- B. </selabel>
- Rainbow de siete colores <br/>
- <Tabel>
- <inputType = radioname = cuestion4Value = c/>
- C
- Costa del Azure </p>
- <p> 5. ¿Quién es el personaje de portada de la revista NewVision en el olvido? <br/>
- <Tabel>
- <inputType = radioname = cuestion5Value = a/>
- A. </etlabe> xuanbin <br/>
- <Tabel>
- <inputType = radioname = cuestion5Value = b/>
- B. </Etiqueta> lluvia <br/>
- <Tabel>
- <inputType = radioname = cuestion5Value = c/>
- C
- <p> 6. ¿Cuál es el nombre del disco en el pasado de la música? <br/>
- <Tabel>
- <inputType = radioname = cuestion6Value = a/>
- A. </etlabe>
- Bewitched <br/>
- <Tabel>
- <inputType = radioname = cuestion6Value = b/>
- B. </selabel>
- Maravilloso <br/>
- <Tabel>
- <inputType = radioname = cuestion6Value = c/>
- C
- Hermoso </p>
- <p> 7. ¿Qué se escribe en la pared del bar en el pasado de la música? <br/>
- <Tabel>
- <inputType = radioname = cuestion7Value = a/>
- A. </etlabe>
- Loveisbeautiful <br/>
- <label> <inputType = radioname = cuestion7Value = b/>
- B. </selabel>
- Truthisbeautiful <br/>
- <label> <inputType = radioname = cuestion7Value = c/>
- C
- Smilleisbeautiful </p>
- <p> 8. ¿Qué se coloca en el bar en el pasado de la música? <br/>
- <label> <inputType = radioname = cuestion8Value = a/>
- A. </etlabe>
- Gramófono <br/>
- <label> <inputType = radioname = cuestion8Value = b/>
- B. </selabel>
- Radio <br/>
- <label> <inputType = radioname = cuestion8Value = c/>
- C
- Vinyl Records </p>
- <p> 9. ¿Cuál es la preferencia del protagonista masculino en la música pasada? <br/>
- <label> <inputType = radioname = cuestion9Value = a/>
- A. </etlabe>
- Película <br/>
- <label> <inputType = radioname = cuestion9Value = b/>
- B. </selabel>
- Fotografía <br/>
- <label> <inputType = radioname = cuestion9Value = c/>
- C
- Tabaco y música </p>
- <p> 10. ¿Cuál es el pasatiempo del protagonista en el enfriamiento y la maravilla? <br/>
- <label> <inputType = radioname = cuestion10Value = a/>
- A. </etlabe>
- Viajar <br/>
- <label> <inputType = radioname = cuestion10Value = b/>
- B. </selabel>
- Fotografía <br/>
- <label> <inputType = Radioname = Question10Value = C/>
- C
- Ve en línea </p>
- <p> <br/>
- <inputType = SubmitName = SubtItValue = Subt/
- <br/>
- </p>
- </form>
- </body>
- </html>
El siguiente es el código de fondo test_do.asp, el código es el siguiente:
- <%@Idioma = vBscriptCodePage = 936%>
- <!-#includeFile = conn.asp->
- <!-#includeFile = function.asp->
- <%
- Respuesta.cachecontrol = no-cache
- Respuesta.expires = -1
- Respuesta.ExpeesabSolute = Now ()-1
- ifsession (nombre de usuario) = entonces
- Response.Write (<Script> Alert ('Inicie sesión y luego opere!'); Window.location = 'Login.asp? Reurl = nv_scene_test.asp'; </script>)
- Respuesta.end ()
- endif
- 'La puntuación más alta para la opción de definición es la puntuación total
- Consttotalscore = 100
- Constitems = 10
- 'Defina la puntuación de la opción
- Dimresult (9)
- 'Los criterios de puntuación para la primera pregunta
- Resultado (0) = A | 10 | _ | B | 0 | _ | C | 0
- 'Criterios de puntaje para la pregunta 2
- Resultado (1) = A | 0 | _ | B | 10 | _ | C | 0
- 'Los criterios de puntaje de la tercera pregunta
- Resultado (2) = A | 10 | _ | B | 0 | _ | C | 0
- 'PREGUNTA 4 Puntaje estándar
- Resultado (3) = a | 0 | _ | B | 0 | _ | C | 10
- 'Pregunta 5 Puntaje estándar
- Resultado (4) = A | 0 | _ | B | 0 | _ | C | 10
- 'Pregunta 6 Criterios de puntaje
- Resultado (5) = A | 10 | _ | B | 0 | _ | C | 0
- 'Pregunta 7 Criterios de puntaje
- Resultado (6) = A | 0 | _ | B | 10 | _ | C | 0
- 'Pregunta 8 Criterios de puntaje
- Resultado (7) = A | 10 | _ | B | 0 | _ | C | 0
- 'Pregunta 9 Criterios de puntaje
- Resultado (8) = A | 0 | _ | B | 0 | _ | C | 10
- 'Pregunta 10º criterio de puntaje
- Resultado (9) = A | 0 | _ | B | 10 | _ | C | 0
- '' Pregunta 11 Criterios de puntaje
- 'Resultado (10) = a | 0 | _ | b | 0 | _ | c | 10
- '
- '' Pregunta 12 Criterios de puntaje
- 'Result (11) = A | 0 | _ | B | 10 | _ | C | 0
- '
- '' Pregunta 13 Criterios de puntaje
- 'Result (12) = A | 10 | _ | B | 0 | _ | C | 0
- '
- '' Pregunta 14 ° criterio de puntuación
- 'Result (13) = A | 0 | _ | B | 10 | _ | C | 0
- '
- '' Pregunta 15 ° criterio de puntaje
- 'Resultado (14) = a | 0 | _ | b | 0 | _ | c | 10
- Ifucase (request.servervariables (request_method)) = postthen
- Callchk_post ()
- Dimi, Total, Selitem, Resumen, Strdes, Strout
- Total = 0
- Fori = 0TO (elementos-1)
- Selval = Trim (request.form (pregunta e i+1))
- Arritem = Split (resultado (i), | _ |)
- Forj = 0toUbound (Arritem)
- IfSelval = Split (Arritem (J), |) (0) Entonces
- TotalTotal = Total+Cint (Split (Arritem (J), |) (1))
- SelitemSelitem = Selitem & <li> Pregunta & i+1 &: & Selval & </li> & vbcrlf
- Endif
- Próximo
- Próximo
- Resumen = FormatParcent (total/Totalscore)
- If (total/totalScore)> = 0.6Then
- strdes = regularidad y resumen y <br> lo has pasado con éxito
- Demás
- strdes = resultado y resumen y <br> Lamentablemente, su tasa de precisión no ha alcanzado el 60%. ¡Vuelve a intentarlo! <br> <ahref = test.asp '> Regrese a la página de preguntas y respuestas en línea >> </a>
- Endif
- strout = YouHaveSelected ThiseItemsBelow: <br> & Selitem & <br> Total: & Total & <br> Su precisión es: y resumen
- stroutstrout = strout & <br> & strdes
- str_sql = selectCount (1) fromUserInfowhereMemberId = '& Session (id) &'
- RowCount = DataConn.Execute (STR_SQL) (0)
- IfrowCount> 0Then'Update Personal Information si existe
- str_sql = updateUserInfo
- str_sqlstr_sql = str_sql & setResult = '& formatnumber (total/totalscore, 2) &'
- str_sqlstr_sql = str_sql &, ip = '& get_userip () &'
- str_sqlstr_sql = str_sql &, addtime = getDate ()
- str_sqlstr_sql = str_sql & wherememberid = '& session (id) &'
- Demás
- str_sql = InsertInToUserInfo (resultado, miembro, memberName, IP)
- str_sqlstr_sql = str_sql & valores ('& formatnumber (total/totalScore, 2) &', '& session (id) &', '& session (nombre de usuario) &', '& get_userip () &')
- Endif
- Dataconn.execute (str_sql)
- Endif
- %>
- <! DOCTYPEHTMLPublic-// w3c // dtdxhtml1.0Transitional // gohttp: //www.w3.org/tr/xhtml1/dtd/xhtml1-transicional.dtd>
- <htmlxmlns = http: //www.w3.org/1999/xhtml>
- <Evista>
- <metahttp-oquiv = content-typeContent = text/html; charset = gb2312/>
- <title> Resultados de pruebas de preguntas y respuestas en línea </title>
- <styletype = text/css>
- <!-
- cuerpo{
- tamaño de fuente: 12px;
- Color:#0066ff;
- }
- aporte{
- borde: 1pxsolid#ffffff;
- Color de fondo: #EEEEE;
- Izquierda: 1px;
- arriba: 1px;
- Derecha: 1px;
- Abajo: 1px;
- clip: rect (10px, 10px, 10px, 10px);
- margen: 1px;
- relleno: 1px;
- }
- ->
- </style>
- </ablo>
- <Body>
- <%Response.Write (Strout)%>
- </body>
- </html>
Compartir: Consejos para objetos de error ASP En VBScript, hay una declaración de reanudación de error ON que hace que el intérprete de script ignore los errores de tiempo de ejecución y continúe la ejecución del código de script. Luego, el script puede verificar el valor de la propiedad Err.Number para determinar si ocurrió un error. Si se produce un error, se devuelve un valor distinto de cero. En ASP 3.0, también puede usar el error GOTO 0 para "volver a" el valor predeterminado