Merge pull request 'add tiempo de respuesta' (#26) from add_tiempo into main
Reviewed-on: #26
This commit was merged in pull request #26.
This commit is contained in:
+12
-2
@@ -18,9 +18,10 @@ let preguntas = [];
|
|||||||
let indice = 0; // pregunta que se está mostrando
|
let indice = 0; // pregunta que se está mostrando
|
||||||
let bloqueado = false; // true mientras se envía una respuesta o se ve el feedback
|
let bloqueado = false; // true mientras se envía una respuesta o se ve el feedback
|
||||||
let numeroAciertos = 0; // número de aciertos del jugador
|
let numeroAciertos = 0; // número de aciertos del jugador
|
||||||
|
let tiempoRespuesta = 0;
|
||||||
|
let intervaloTiempo;
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
// Obtenemos el idPartida de la URL
|
// Obtenemos el idPartida de la URL
|
||||||
// Ejemplo: juego.php?idPartida=3
|
// Ejemplo: juego.php?idPartida=3
|
||||||
|
|
||||||
@@ -83,6 +84,11 @@ function cargarPreguntas() {
|
|||||||
function mostrarPregunta() {
|
function mostrarPregunta() {
|
||||||
const pregunta = preguntas[indice];
|
const pregunta = preguntas[indice];
|
||||||
|
|
||||||
|
tiempoRespuesta = 0;
|
||||||
|
intervaloTiempo = setInterval(function () {
|
||||||
|
tiempoRespuesta++;
|
||||||
|
}, 100);
|
||||||
|
|
||||||
bloqueado = false;
|
bloqueado = false;
|
||||||
|
|
||||||
$("#textoPregunta").text(pregunta.nombrePregunta);
|
$("#textoPregunta").text(pregunta.nombrePregunta);
|
||||||
@@ -111,6 +117,9 @@ function mostrarPregunta() {
|
|||||||
|
|
||||||
// 3. El usuario pulsa una respuesta: se guarda y se enseña si ha acertado
|
// 3. El usuario pulsa una respuesta: se guarda y se enseña si ha acertado
|
||||||
function responder($botonPulsado) {
|
function responder($botonPulsado) {
|
||||||
|
clearInterval(intervaloTiempo);
|
||||||
|
console.log("Tiempo de respuesta: " + tiempoRespuesta / 10 + " segundos");
|
||||||
|
|
||||||
if (bloqueado) {
|
if (bloqueado) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -130,7 +139,8 @@ function responder($botonPulsado) {
|
|||||||
orden: "responder",
|
orden: "responder",
|
||||||
idPartida: idPartida,
|
idPartida: idPartida,
|
||||||
idPartidaxPregunta: pregunta.idPartidaxPregunta,
|
idPartidaxPregunta: pregunta.idPartidaxPregunta,
|
||||||
idRespuesta: idRespuesta,
|
idRespuesta: idRespuesta,
|
||||||
|
tiempoRespuesta: tiempoRespuesta,
|
||||||
},
|
},
|
||||||
success: function (datos) {
|
success: function (datos) {
|
||||||
if (datos.error) {
|
if (datos.error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user