CÓDIGOS PARA TEST CON RESPUESTAS SIN BASE DE DATOS

Los códigos siguientes permiten crear un examen, mostrando sus respuestas correctas, sin tener que utilizar ninguna base de datos.

El script es sencillo de implementar y solamente se deben agregar los códigos correspondientes a las respuestas correctas entre <head> y </head>, así como algunos comentarios básicos; las preguntas del test y las opciones de respuesta van entre <body> y </body>.

Los pasos son:


1. Agregar el siguiente código entre <head> y </head>:

<script> var ans = new Array;var done = new Array;var score = 0; ans[1] = "a"; ans[2] = "b"; ans[3] = "a"; ans[4] = "a"; ans[5] = "c";
function Engine(question, answer) { if (answer != ans[question]) { if (!done[question]) { done[question] = -1; alert("Incorrecto\n\nPuntaje - Score: " + score); } else {
alert("No puede marcar más de una respuesta\n\nAgregar otro comentario"); } } else { if (!done[question]) { done[question] = -1; score++;
alert("Correcto\n\nOtro comentario\n\nPuntaje - Score: " + score); }
else { alert("No puede marcar más de una respuesta"); } } } function NextLevel () { if (score>= 5)
{ alert("¡Felicitaciones\n\nCongratulations"); self.location="test1.html" } else {
alert("Ver las respuestas correctas al final del Test\n\nOtro comentario") } } </script>

Cambiar la letra en color azul por la letra que corresponda a la respuesta correcta de su examen.

Cambiar los comentarios en rojo por los que crea necesarios. Puede agregar más de un texto, separándolos con \n\n.

Si agrega más preguntas, debe agregar las respuestas y cambiar el valor del score.
ans[6] = "a";
(score > = 6)


2. Agregar el siguiente código entre <body> y </body>:

<p>01. ¿Cuánto suman 1+1?
<br>
<br>
<input onClick="Engine(1, this.value)" type="radio" value="a"> Dos  
<input onClick="Engine(1, this.value)" type="radio" value="b"> Tres  
<input onClick="Engine(1, this.value)" type="radio" value="c"> Uno</p>


<br>

<p>02. ¿Cuánto suman 2+2?
<br>
<br>
<input onClick="Engine(2, this.value)" type="radio" value="a"> Dos  
<input onClick="Engine(2, this.value)" type="radio" value="b"> Cuatro  
<input onClick="Engine(2, this.value)" type="radio" value="c"> Uno</p>


<br>

<p>03. ¿Cuál es el resultado de 6-2?
<br>
<br>
<input onClick="Engine(3, this.value)" type="radio" value="a"> Cuatro  
<input onClick="Engine(3, this.value)" type="radio" value="b"> Tres  
<input onClick="Engine(3, this.value)" type="radio" value="c"> Uno</p>


<br>

<p>04. ¿Cuánto suman 3+4?
<br>
<br>
<input onClick="Engine(4, this.value)" type="radio" value="a"> Siete  
<input onClick="Engine(4, this.value)" type="radio" value="b"> Seis  
<input onClick="Engine(4, this.value)" type="radio" value="c"> Cuatro</p>


<br>

<p>05. ¿Cuál es el resultado de 10-3?
<br>
<br>
<input onClick="Engine(5, this.value)" type="radio" value="a"> Seis  
<input onClick="Engine(5, this.value)" type="radio" value="b"> Cinco  
<input onClick="Engine(5, this.value)" type="radio" value="c"> Siete</p>


<br>

Así se verá el Examen y sus respuestas:


01. ¿Cuánto suman 1+1?

Dos Tres Uno


02. ¿Cuánto suman 2+2?

Dos Cuatro Uno


03. ¿Cuál es el resultado de 6-2?

Cuatro Tres Uno


04. ¿Cuánto suman 3+4?

Siete Seis Cuatro


05. ¿Cuál es el resultado de 10-3?

Seis Cinco Siete



Ver otro ejemplo del código de examen con respuestas, en funcionamiento, en test10.html



Código Abrir Ventana Alerta onclick





Usamos cookies propias y de terceros para estadísticas y publicidad personalizada.
Si continúa navegando, consideramos que acepta su uso. X +Info