| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 
 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>{TITLE}</title>
    <script type="text/javascript">
        // JavaScript Document
        function corregir() {
            var numeroPreguntas=3;
            var numeroRespuestas=4;
            var nombreid = new Array();
            var correctas=["p11","p23","p31","p34"];
            var cont=0, contAcierto=0, contFallo=0, contBlanco=0, contResultado=0, indice, seleccionada, fallos=0;
            var controlador=1;var indice2;
 
            for (pregun=1;pregun<=numeroPreguntas;pregun++) {
                for (respuesta=1;respuesta<=numeroRespuestas;respuesta++) {
                    nombreid[cont]="p"+pregun+respuesta; // me creo las ids de los radios a comprobar
                    //var indice=nombreid[cont];
                    cont++;
                }
            }
 
            var pregSeleccionadas = 0; //Para contar cuantas alternativas estan checked
            for (i=0;i<nombreid.length;i++){
                indice=nombreid[i];
                seleccionada=document.getElementById(indice).checked;
 
                if(seleccionada){
                    pregSeleccionadas++;
                    for(j=0;j<correctas.length;j++){
                        if(indice==correctas[j]){
                            contAcierto++;
                        }
                    }
                }
            }
            //Naturalmente las blancas seran:
            contBlanco = numeroPreguntas - pregSeleccionadas;
            //y finalmente sabemos que Total de preguntas = buenas + malas + blancas, por lo que:
            contFallo = numeroPreguntas - contBlanco - contAcierto;
 
            document.getElementById("aciertos").value = contAcierto;
            document.getElementById("fallos").value = contFallo;
            document.getElementById("blancos").value = contBlanco;
            document.getElementById("puntuacion").value = puntuacion;
        }
    </script>
</head>
<body>
<form action="" method="post" name="Preguntas">
    <br />
<!-- Primera pregunta -->
    1.- ¿En que año cayo el muro de berlin?<br />
    <p><input type="radio" name="pregunta1" id="p11" value="A" />1989</p>  
    <p><input type="radio" name="pregunta1" id="p12" value="B" />1990</p>  
    <p><input type="radio" name="pregunta1" id="p13" value="C" />1992</p>  
    <p><input type="radio" name="pregunta1" id="p14" value="D" />1985</p>
    <br />
 
<!-- Segunda pregunta -->   
    2.- ¿En que dia del ano se murio cervantes?<br />
    <p><input type="radio" name="pregunta2"  id="p21" value="A" />El 20 de enero</p>  
    <p><input type="radio" name="pregunta2"  id="p22" value="B" />El 1 de mayo</p>  
    <p><input type="radio" name="pregunta2"  id="p23" value="C" />El mismo dia del ano que Shekspear</p>  
    <p><input type="radio" name="pregunta2"  id="p24" value="D" />El dia de la st jordi</p>
    <br />
 
<!-- Tercera pregunta -->
    3.- ¿En que fecha se murio franco?<br />
    <p><input type="radio" name="pregunta3"  id="p31" value="A" />El 20 de noviembre de 1975</p>  
    <p><input type="radio" name="pregunta3"  id="p32" value="B" />El dia del golpe de estado</p>  
    <p><input type="radio" name="pregunta3"  id="p33" value="C" />El 20 de noviembre de 1974</p>  
    <p><input type="radio" name="pregunta3"  id="p34" value="D" />39 anos exacto depues de la muerte de Primo de Rivera</p>
    <br />
    <input type="button" name="boton" value=" CORREGIR " onclick="corregir()"/>
</form>
 
<br /><br />
 
<b>RESULTADO DEL TEST</b> <P>
 
<form name="resultado" action="">
Has acertado <input type="text" size="3" name="aciertos" id="aciertos" value= ""/> preguntas <br>
Has fallado en <input type="text" size="3" name="fallos" id="fallos" value=""/> preguntas <br>
Has dejado de responder <input size="3" name="blancos" id="blancos" type="text"  value=""/> preguntas <P>
PUNTUACIÓN: <input type="text" size="5" id="puntuacion" readonly="readonly"/> puntos
</form>
</body>
</html> |