Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d728647a70 | |||
| d5bf236022 | |||
| 64b3728cce | |||
| 38305c558c | |||
| c840ae6b43 | |||
| 079013c9b9 | |||
| a2c068cdc0 | |||
| ead0555d00 | |||
| 139b97737e | |||
| 9a01939bf2 | |||
| d0b45e8a88 | |||
| 645e2abc77 | |||
| d9020a66c6 | |||
| 9d59a9cc7c | |||
| 8ffb769861 | |||
| 1c3fbf2f90 | |||
| cd53cba69e | |||
| 5f407ce8f4 | |||
| d20b1fa7d7 | |||
| 02e725e0f3 | |||
| bdc7bef169 | |||
| 963ab50f37 |
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/triviagmatico/includes/conexionBD.php';
|
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||||
|
|
||||||
class Categoria{
|
class Categoria{
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// controladores/controladorResultados.php
|
||||||
session_start();
|
session_start();
|
||||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||||
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
|
||||||
if (!isset($_SESSION['idUsuario'])) {
|
if (!isset($_SESSION['idUsuario'])) {
|
||||||
@@ -26,7 +26,6 @@ if (is_array($conexion)) {
|
|||||||
switch ($orden) {
|
switch ($orden) {
|
||||||
case 'comprobarEstado':
|
case 'comprobarEstado':
|
||||||
try {
|
try {
|
||||||
// 1. Contar cuántos jugadores hay asignados en esta partida
|
|
||||||
$stmt = $conexion->prepare("
|
$stmt = $conexion->prepare("
|
||||||
SELECT COUNT(exu.idUsuario) AS total_jugadores
|
SELECT COUNT(exu.idUsuario) AS total_jugadores
|
||||||
FROM equipoxpartida exp
|
FROM equipoxpartida exp
|
||||||
@@ -38,7 +37,6 @@ switch ($orden) {
|
|||||||
|
|
||||||
$preguntasTotalesEsperadas = $totalJugadores * 10;
|
$preguntasTotalesEsperadas = $totalJugadores * 10;
|
||||||
|
|
||||||
// 2. Contar cuántas respuestas reales se han guardado
|
|
||||||
$stmtRespuestas = $conexion->prepare("
|
$stmtRespuestas = $conexion->prepare("
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM respuestaalmacenada ra
|
FROM respuestaalmacenada ra
|
||||||
@@ -50,12 +48,9 @@ switch ($orden) {
|
|||||||
|
|
||||||
$terminada = ($respuestasRespondidas >= $preguntasTotalesEsperadas && $preguntasTotalesEsperadas > 0);
|
$terminada = ($respuestasRespondidas >= $preguntasTotalesEsperadas && $preguntasTotalesEsperadas > 0);
|
||||||
|
|
||||||
// 3. Si ha terminado, guardamos los datos históricos una sola vez
|
if ($terminada && !isset($_SESSION['partidas_processed'][$idPartida])) {
|
||||||
if ($terminada && !isset($_SESSION['partidas_procesadas'][$idPartida])) {
|
|
||||||
|
|
||||||
$conexion->beginTransaction();
|
$conexion->beginTransaction();
|
||||||
|
|
||||||
// --- CÁLCULO DE VELOCIDAD ---
|
|
||||||
if (!isset($_SESSION['primeros_en_acertar'][$idPartida])) {
|
if (!isset($_SESSION['primeros_en_acertar'][$idPartida])) {
|
||||||
$_SESSION['primeros_en_acertar'][$idPartida] = [];
|
$_SESSION['primeros_en_acertar'][$idPartida] = [];
|
||||||
}
|
}
|
||||||
@@ -74,13 +69,11 @@ switch ($orden) {
|
|||||||
foreach ($todosLosAciertos as $acierto) {
|
foreach ($todosLosAciertos as $acierto) {
|
||||||
$idPxp = $acierto['idPartidaxPregunta'];
|
$idPxp = $acierto['idPartidaxPregunta'];
|
||||||
$idU = $acierto['idUsuario'];
|
$idU = $acierto['idUsuario'];
|
||||||
|
|
||||||
if (!isset($_SESSION['primeros_en_acertar'][$idPartida][$idPxp])) {
|
if (!isset($_SESSION['primeros_en_acertar'][$idPartida][$idPxp])) {
|
||||||
$_SESSION['primeros_en_acertar'][$idPartida][$idPxp] = $idU;
|
$_SESSION['primeros_en_acertar'][$idPartida][$idPxp] = $idU;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consulta de aciertos
|
|
||||||
$stmtAciertos = $conexion->prepare("
|
$stmtAciertos = $conexion->prepare("
|
||||||
SELECT ra.idUsuario, exu.idEquipo, COUNT(*) as aciertos_partida
|
SELECT ra.idUsuario, exu.idEquipo, COUNT(*) as aciertos_partida
|
||||||
FROM respuestaalmacenada ra
|
FROM respuestaalmacenada ra
|
||||||
@@ -93,11 +86,7 @@ switch ($orden) {
|
|||||||
$stmtAciertos->execute([':idPartida' => $idPartida]);
|
$stmtAciertos->execute([':idPartida' => $idPartida]);
|
||||||
$jugadoresPartida = $stmtAciertos->fetchAll(PDO::FETCH_ASSOC);
|
$jugadoresPartida = $stmtAciertos->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$updateAciertos = $conexion->prepare("
|
$updateAciertos = $conexion->prepare("UPDATE usuario SET aciertos = aciertos + :nuevos_aciertos WHERE idUsuario = :idUsuario");
|
||||||
UPDATE usuario
|
|
||||||
SET aciertos = aciertos + :nuevos_aciertos
|
|
||||||
WHERE idUsuario = :idUsuario
|
|
||||||
");
|
|
||||||
|
|
||||||
$puntosEquipos = [];
|
$puntosEquipos = [];
|
||||||
foreach ($jugadoresPartida as $jp) {
|
foreach ($jugadoresPartida as $jp) {
|
||||||
@@ -105,14 +94,9 @@ switch ($orden) {
|
|||||||
$idE = (int)$jp['idEquipo'];
|
$idE = (int)$jp['idEquipo'];
|
||||||
$nuevosAciertos = (int)$jp['aciertos_partida'];
|
$nuevosAciertos = (int)$jp['aciertos_partida'];
|
||||||
|
|
||||||
$updateAciertos->execute([
|
$updateAciertos->execute([':nuevos_aciertos' => $nuevosAciertos, ':idUsuario' => $idU]);
|
||||||
':nuevos_aciertos' => $nuevosAciertos,
|
|
||||||
':idUsuario' => $idU
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!isset($puntosEquipos[$idE])) {
|
if (!isset($puntosEquipos[$idE])) { $puntosEquipos[$idE] = 0; }
|
||||||
$puntosEquipos[$idE] = 0;
|
|
||||||
}
|
|
||||||
$puntosEquipos[$idE] += $nuevosAciertos;
|
$puntosEquipos[$idE] += $nuevosAciertos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +119,6 @@ switch ($orden) {
|
|||||||
foreach ($todosLosMiembros as $miembro) {
|
foreach ($todosLosMiembros as $miembro) {
|
||||||
$idU = (int)$miembro['idUsuario'];
|
$idU = (int)$miembro['idUsuario'];
|
||||||
$idE = (int)$miembro['idEquipo'];
|
$idE = (int)$miembro['idEquipo'];
|
||||||
|
|
||||||
if ($idE === $idEquipoGanador) {
|
if ($idE === $idEquipoGanador) {
|
||||||
$updateVictoria->execute([':idUsuario' => $idU]);
|
$updateVictoria->execute([':idUsuario' => $idU]);
|
||||||
} else {
|
} else {
|
||||||
@@ -144,23 +127,15 @@ switch ($orden) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marcar fecha fin de la partida para los históricos globales del grupo
|
$stmtFinalizar = $conexion->prepare("UPDATE partida SET fechaFin = NOW() WHERE idPartida = :idPartida AND fechaFin IS NULL");
|
||||||
$stmtFinalizar = $conexion->prepare("
|
|
||||||
UPDATE partida
|
|
||||||
SET fechaFin = NOW()
|
|
||||||
WHERE idPartida = :idPartida AND fechaFin IS NULL
|
|
||||||
");
|
|
||||||
$stmtFinalizar->execute([':idPartida' => $idPartida]);
|
$stmtFinalizar->execute([':idPartida' => $idPartida]);
|
||||||
|
|
||||||
$conexion->commit();
|
$conexion->commit();
|
||||||
$_SESSION['partidas_procesadas'][$idPartida] = true;
|
$_SESSION['partidas_procesadas'][$idPartida] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(['terminada' => $terminada]);
|
echo json_encode(['terminada' => $terminada]);
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
if ($conexion->inTransaction()) {
|
if ($conexion->inTransaction()) { $conexion->rollBack(); }
|
||||||
$conexion->rollBack();
|
|
||||||
}
|
|
||||||
echo json_encode(['error' => $e->getMessage()]);
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -170,11 +145,9 @@ switch ($orden) {
|
|||||||
$idUsuario = (int)$_SESSION['idUsuario'];
|
$idUsuario = (int)$_SESSION['idUsuario'];
|
||||||
$conexion->beginTransaction();
|
$conexion->beginTransaction();
|
||||||
|
|
||||||
// A. LIBERACIÓN INMEDIATA DEL JUGADOR ACTUAL: Lo borramos de su equipo
|
|
||||||
$stmtSalir = $conexion->prepare("DELETE FROM equipoxusuario WHERE idUsuario = :idUsuario");
|
$stmtSalir = $conexion->prepare("DELETE FROM equipoxusuario WHERE idUsuario = :idUsuario");
|
||||||
$stmtSalir->execute([':idUsuario' => $idUsuario]);
|
$stmtSalir->execute([':idUsuario' => $idUsuario]);
|
||||||
|
|
||||||
// B. CONTADOR DE ALUMNOS QUEDAN: Contamos cuántas personas quedan en los equipos de esta partida
|
|
||||||
$stmtContarQuedan = $conexion->prepare("
|
$stmtContarQuedan = $conexion->prepare("
|
||||||
SELECT COUNT(exu.idUsuario)
|
SELECT COUNT(exu.idUsuario)
|
||||||
FROM equipoxpartida exp
|
FROM equipoxpartida exp
|
||||||
@@ -184,9 +157,7 @@ switch ($orden) {
|
|||||||
$stmtContarQuedan->execute([':idPartida' => $idPartida]);
|
$stmtContarQuedan->execute([':idPartida' => $idPartida]);
|
||||||
$jugadoresRestantes = (int)$stmtContarQuedan->fetchColumn();
|
$jugadoresRestantes = (int)$stmtContarQuedan->fetchColumn();
|
||||||
|
|
||||||
// C. DESTRUCCIÓN EN CADENA AUTOMÁTICA ATÓMICA (Si da 0, somos los últimos en salir)
|
|
||||||
if ($jugadoresRestantes === 0) {
|
if ($jugadoresRestantes === 0) {
|
||||||
// 1. Limpiar las respuestas almacenadas
|
|
||||||
$stmtBorrarRespuestas = $conexion->prepare("
|
$stmtBorrarRespuestas = $conexion->prepare("
|
||||||
DELETE ra FROM respuestaalmacenada ra
|
DELETE ra FROM respuestaalmacenada ra
|
||||||
INNER JOIN partidaxpregunta pxp ON ra.idPartidaxPregunta = pxp.idPartidaxPregunta
|
INNER JOIN partidaxpregunta pxp ON ra.idPartidaxPregunta = pxp.idPartidaxPregunta
|
||||||
@@ -194,29 +165,22 @@ switch ($orden) {
|
|||||||
");
|
");
|
||||||
$stmtBorrarRespuestas->execute([':idPartida' => $idPartida]);
|
$stmtBorrarRespuestas->execute([':idPartida' => $idPartida]);
|
||||||
|
|
||||||
// 2. Limpiar las preguntas vinculadas a la partida
|
|
||||||
$stmtBorrarPreguntas = $conexion->prepare("DELETE FROM partidaxpregunta WHERE idPartida = :idPartida");
|
$stmtBorrarPreguntas = $conexion->prepare("DELETE FROM partidaxpregunta WHERE idPartida = :idPartida");
|
||||||
$stmtBorrarPreguntas->execute([':idPartida' => $idPartida]);
|
$stmtBorrarPreguntas->execute([':idPartida' => $idPartida]);
|
||||||
|
|
||||||
// 3. NUEVO: Obtener los IDs de los dos equipos que jugaban en esta partida antes de borrar la relación
|
|
||||||
$stmtObtenerEquipos = $conexion->prepare("SELECT idEquipo FROM equipoxpartida WHERE idPartida = :idPartida");
|
$stmtObtenerEquipos = $conexion->prepare("SELECT idEquipo FROM equipoxpartida WHERE idPartida = :idPartida");
|
||||||
$stmtObtenerEquipos->execute([':idPartida' => $idPartida]);
|
$stmtObtenerEquipos->execute([':idPartida' => $idPartida]);
|
||||||
$equiposDeLaPartida = $stmtObtenerEquipos->fetchAll(PDO::FETCH_COLUMN);
|
$equiposDeLaPartida = $stmtObtenerEquipos->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
// 4. Limpiar la relación de equipos de la partida (tabla intermedia)
|
|
||||||
$stmtBorrarEquiposPartida = $conexion->prepare("DELETE FROM equipoxpartida WHERE idPartida = :idPartida");
|
|
||||||
$stmtBorrarEquiposPartida = $conexion->prepare("DELETE FROM equipoxpartida WHERE idPartida = :idPartida");
|
$stmtBorrarEquiposPartida = $conexion->prepare("DELETE FROM equipoxpartida WHERE idPartida = :idPartida");
|
||||||
$stmtBorrarEquiposPartida->execute([':idPartida' => $idPartida]);
|
$stmtBorrarEquiposPartida->execute([':idPartida' => $idPartida]);
|
||||||
|
|
||||||
// 5. NUEVO: Borrar físicamente los equipos de la tabla 'equipo' si existen
|
|
||||||
if (!empty($equiposDeLaPartida)) {
|
if (!empty($equiposDeLaPartida)) {
|
||||||
// Creamos los marcadores (?, ?) de forma dinámica según los equipos que devuelva
|
|
||||||
$inQuery = implode(',', array_fill(0, count($equiposDeLaPartida), '?'));
|
$inQuery = implode(',', array_fill(0, count($equiposDeLaPartida), '?'));
|
||||||
$stmtBorrarEquiposFisicos = $conexion->prepare("DELETE FROM equipo WHERE idEquipo IN ($inQuery)");
|
$stmtBorrarEquiposFisicos = $conexion->prepare("DELETE FROM equipo WHERE idEquipo IN ($inQuery)");
|
||||||
$stmtBorrarEquiposFisicos->execute($equiposDeLaPartida);
|
$stmtBorrarEquiposFisicos->execute($equiposDeLaPartida);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Borrar físicamente la fila de la partida principal
|
|
||||||
$stmtBorrarSala = $conexion->prepare("DELETE FROM partida WHERE idPartida = :idPartida");
|
$stmtBorrarSala = $conexion->prepare("DELETE FROM partida WHERE idPartida = :idPartida");
|
||||||
$stmtBorrarSala->execute([':idPartida' => $idPartida]);
|
$stmtBorrarSala->execute([':idPartida' => $idPartida]);
|
||||||
}
|
}
|
||||||
@@ -224,11 +188,8 @@ switch ($orden) {
|
|||||||
$conexion->commit();
|
$conexion->commit();
|
||||||
echo json_encode(['exito' => true, 'usuarios_quedan' => $jugadoresRestantes]);
|
echo json_encode(['exito' => true, 'usuarios_quedan' => $jugadoresRestantes]);
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
if ($conexion->inTransaction()) {
|
if ($conexion->inTransaction()) { $conexion->rollBack(); }
|
||||||
$conexion->rollBack();
|
|
||||||
}
|
|
||||||
echo json_encode(['error' => $e->getMessage()]);
|
echo json_encode(['error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Triviagmatico</title>
|
||||||
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
||||||
<!-- Bootstrap 5 CSS -->
|
<!-- Bootstrap 5 CSS -->
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|||||||
@@ -60,12 +60,25 @@ function comprobarSesion() {
|
|||||||
`;
|
`;
|
||||||
contenedor.html(htmlUsuario);
|
contenedor.html(htmlUsuario);
|
||||||
|
|
||||||
|
// Si estamos en la página de perfil, rellenamos nombre y foto
|
||||||
|
if ($("#nombre").length) {
|
||||||
|
$("#nombre").text(respuesta.usuario.nombreUsuario);
|
||||||
|
// ?t= evita que el navegador enseñe la foto antigua en caché
|
||||||
|
$("#fotoPerfil").attr("src", avatarUrl + "?t=" + new Date().getTime());
|
||||||
|
}
|
||||||
|
|
||||||
// Si estamos en la página principal, mostramos el botón JUGAR
|
// Si estamos en la página principal, mostramos el botón JUGAR
|
||||||
if ($("#colBotonJugar").length) {
|
if ($("#colBotonJugar").length) {
|
||||||
$("#colBotonJugar").removeClass("d-none");
|
$("#colBotonJugar").removeClass("d-none");
|
||||||
$("#colRanking").removeClass("col-lg-8").addClass("col-lg-7 col-xl-8");
|
$("#colRanking").removeClass("col-lg-8").addClass("col-lg-7 col-xl-8");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Si estamos en el perfil y no hay sesión, volvemos al inicio
|
||||||
|
if ($("#nombre").length) {
|
||||||
|
window.location.href = "index.php";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// No hay sesión: Botones de Login y Registro
|
// No hay sesión: Botones de Login y Registro
|
||||||
const htmlInvitado = `
|
const htmlInvitado = `
|
||||||
<button type="button" class="btn btn-kahoot-login rounded-pill px-4" data-bs-toggle="modal" data-bs-target="#modalLogin">
|
<button type="button" class="btn btn-kahoot-login rounded-pill px-4" data-bs-toggle="modal" data-bs-target="#modalLogin">
|
||||||
|
|||||||
+6
-6
@@ -50,10 +50,9 @@ function cambiarNombre() {
|
|||||||
$("#nuevoNombre").val("");
|
$("#nuevoNombre").val("");
|
||||||
|
|
||||||
|
|
||||||
if (typeof comprobarEstadoSesion === "function") {
|
comprobarSesion();
|
||||||
comprobarEstadoSesion();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +70,7 @@ function borrarNombre() {
|
|||||||
|
|
||||||
function seleccionarFoto() {
|
function seleccionarFoto() {
|
||||||
$("#inputFoto").click();
|
$("#inputFoto").click();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#inputFoto").change(function () {
|
$("#inputFoto").change(function () {
|
||||||
@@ -80,6 +80,7 @@ $("#inputFoto").change(function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Comprobamos que sea una imagen
|
// Comprobamos que sea una imagen
|
||||||
if (!archivo.type.startsWith("image/")) {
|
if (!archivo.type.startsWith("image/")) {
|
||||||
alert("El archivo seleccionado no es una imagen.");
|
alert("El archivo seleccionado no es una imagen.");
|
||||||
@@ -110,9 +111,8 @@ $("#inputFoto").change(function () {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Actualizamos también el avatar superior en la cabecera
|
// Actualizamos también el avatar superior en la cabecera
|
||||||
if (typeof comprobarEstadoSesion === "function") {
|
|
||||||
comprobarEstadoSesion();
|
comprobarSesion();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
||||||
<title>Proyecto Trivial</title>
|
<title>Trivial - Juego</title>
|
||||||
<link rel="stylesheet" href="css/juego.css">
|
<link rel="stylesheet" href="css/juego.css">
|
||||||
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
// modelos/PartidaModelo.php
|
||||||
|
|
||||||
|
class PartidaModelo {
|
||||||
|
private $conexion;
|
||||||
|
|
||||||
|
public function __construct($conexion) {
|
||||||
|
$this->conexion = $conexion;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtiene los jugadores mapeados en la partida actual
|
||||||
|
public function obtenerJugadoresPartida($idPartida) {
|
||||||
|
$stmt = $this->conexion->prepare("
|
||||||
|
SELECT u.idUsuario, u.nombreUsuario, e.idEquipo, e.nombreEquipo
|
||||||
|
FROM equipoxpartida exp
|
||||||
|
INNER JOIN equipoxusuario exu ON exp.idEquipo = exu.idEquipo
|
||||||
|
INNER JOIN usuario u ON exu.idUsuario = u.idUsuario
|
||||||
|
INNER JOIN equipo e ON exu.idEquipo = e.idEquipo
|
||||||
|
WHERE exp.idPartida = :idPartida
|
||||||
|
");
|
||||||
|
$stmt->execute([':idPartida' => $idPartida]);
|
||||||
|
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtiene las respuestas guardadas por un usuario específico
|
||||||
|
public function obtenerRespuestasUsuario($idPartida, $idUsuario) {
|
||||||
|
$stmtRespuestas = $this->conexion->prepare("
|
||||||
|
SELECT ra.idPartidaxPregunta, r.correcta
|
||||||
|
FROM respuestaalmacenada ra
|
||||||
|
INNER JOIN respuesta r ON ra.idRespuesta = r.idRespuesta
|
||||||
|
INNER JOIN partidaxpregunta pxp ON ra.idPartidaxPregunta = pxp.idPartidaxPregunta
|
||||||
|
WHERE pxp.idPartida = :idPartida AND ra.idUsuario = :idUsuario
|
||||||
|
");
|
||||||
|
$stmtRespuestas->execute([':idPartida' => $idPartida, ':idUsuario' => $idUsuario]);
|
||||||
|
return $stmtRespuestas->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,42 +1,42 @@
|
|||||||
/*M!999999\- enable the sandbox mode */
|
-- phpMyAdmin SQL Dump
|
||||||
-- MariaDB dump 10.19-11.7.2-MariaDB, for Win64 (AMD64)
|
-- version 5.2.3
|
||||||
|
-- https://www.phpmyadmin.net/
|
||||||
--
|
--
|
||||||
-- Host: localhost Database: triviagmatico
|
-- Host: localhost:3306
|
||||||
-- ------------------------------------------------------
|
-- Generation Time: Oct 02, 2026 at 08:40 AM
|
||||||
-- Server version 10.4.32-MariaDB
|
-- Server version: 8.4.3
|
||||||
|
-- PHP Version: 8.3.30
|
||||||
|
|
||||||
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||||
|
START TRANSACTION;
|
||||||
|
SET time_zone = "+00:00";
|
||||||
|
|
||||||
|
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||||
/*!40101 SET NAMES utf8mb4 */;
|
/*!40101 SET NAMES utf8mb4 */;
|
||||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
|
||||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
--
|
||||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
-- Database: `triviagmatico`
|
||||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
--
|
||||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
|
||||||
/*M!100616 SET @OLD_NOTE_VERBOSITY=@@NOTE_VERBOSITY, NOTE_VERBOSITY=0 */;
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `categoria`
|
-- Table structure for table `categoria`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `categoria`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
|
||||||
CREATE TABLE `categoria` (
|
CREATE TABLE `categoria` (
|
||||||
`idCategoria` int(11) NOT NULL AUTO_INCREMENT,
|
`idCategoria` int NOT NULL,
|
||||||
`nombreCategoria` varchar(50) NOT NULL,
|
`nombreCategoria` varchar(50) COLLATE utf8mb4_spanish_ci NOT NULL
|
||||||
PRIMARY KEY (`idCategoria`)
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `categoria`
|
-- Dumping data for table `categoria`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `categoria` WRITE;
|
INSERT INTO `categoria` (`idCategoria`, `nombreCategoria`) VALUES
|
||||||
/*!40000 ALTER TABLE `categoria` DISABLE KEYS */;
|
|
||||||
INSERT INTO `categoria` VALUES
|
|
||||||
(4, 'Historia'),
|
(4, 'Historia'),
|
||||||
(5, 'Geografía'),
|
(5, 'Geografía'),
|
||||||
(6, 'Ciencia'),
|
(6, 'Ciencia'),
|
||||||
@@ -50,98 +50,69 @@ INSERT INTO `categoria` VALUES
|
|||||||
(14, 'Tecnología'),
|
(14, 'Tecnología'),
|
||||||
(15, 'Cultura'),
|
(15, 'Cultura'),
|
||||||
(16, 'Gastronomía');
|
(16, 'Gastronomía');
|
||||||
/*!40000 ALTER TABLE `categoria` ENABLE KEYS */;
|
|
||||||
UNLOCK TABLES;
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `equipo`
|
-- Table structure for table `equipo`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `equipo`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
|
||||||
CREATE TABLE `equipo` (
|
CREATE TABLE `equipo` (
|
||||||
`idEquipo` int(11) NOT NULL AUTO_INCREMENT,
|
`idEquipo` int NOT NULL,
|
||||||
`nombreEquipo` varchar(50) NOT NULL,
|
`nombreEquipo` varchar(50) COLLATE utf8mb4_spanish_ci NOT NULL
|
||||||
PRIMARY KEY (`idEquipo`)
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `equipo`
|
-- Dumping data for table `equipo`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `equipo` WRITE;
|
INSERT INTO `equipo` (`idEquipo`, `nombreEquipo`) VALUES
|
||||||
/*!40000 ALTER TABLE `equipo` DISABLE KEYS */;
|
|
||||||
INSERT INTO `equipo` VALUES
|
|
||||||
(1, 'Los Trivialistas'),
|
(1, 'Los Trivialistas'),
|
||||||
(2, 'Los Cerebritos'),
|
(2, 'Los Cerebritos'),
|
||||||
(3, 'Los Sabios'),
|
(3, 'Los Sabios'),
|
||||||
(4, 'Los Exploradores');
|
(4, 'Los Exploradores');
|
||||||
/*!40000 ALTER TABLE `equipo` ENABLE KEYS */;
|
|
||||||
UNLOCK TABLES;
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `equipoxpartida`
|
-- Table structure for table `equipoxpartida`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `equipoxpartida`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
|
||||||
CREATE TABLE `equipoxpartida` (
|
CREATE TABLE `equipoxpartida` (
|
||||||
`idEquipoxPartida` int(11) NOT NULL AUTO_INCREMENT,
|
`idEquipoxPartida` int NOT NULL,
|
||||||
`idPartida` int(11) DEFAULT NULL,
|
`idPartida` int DEFAULT NULL,
|
||||||
`idEquipo` int(11) DEFAULT NULL,
|
`idEquipo` int DEFAULT NULL
|
||||||
PRIMARY KEY (`idEquipoxPartida`),
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||||
KEY `FK idEquipo tabla equipo` (`idEquipo`),
|
|
||||||
KEY `FK idPartida tabla partida` (`idPartida`),
|
|
||||||
CONSTRAINT `FK idEquipo tabla equipo` FOREIGN KEY (`idEquipo`) REFERENCES `equipo` (`idEquipo`),
|
|
||||||
CONSTRAINT `FK idPartida tabla partida` FOREIGN KEY (`idPartida`) REFERENCES `partida` (`idPartida`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `equipoxpartida`
|
-- Dumping data for table `equipoxpartida`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `equipoxpartida` WRITE;
|
INSERT INTO `equipoxpartida` (`idEquipoxPartida`, `idPartida`, `idEquipo`) VALUES
|
||||||
/*!40000 ALTER TABLE `equipoxpartida` DISABLE KEYS */;
|
|
||||||
INSERT INTO `equipoxpartida` VALUES
|
|
||||||
(1, 1, 1),
|
(1, 1, 1),
|
||||||
(2, 1, 2),
|
(2, 1, 2),
|
||||||
(3, 2, 2),
|
(3, 2, 2),
|
||||||
(4, 2, 3),
|
(4, 2, 3),
|
||||||
(5, 3, 3),
|
(5, 3, 3),
|
||||||
(6, 3, 4);
|
(6, 3, 4);
|
||||||
/*!40000 ALTER TABLE `equipoxpartida` ENABLE KEYS */;
|
|
||||||
UNLOCK TABLES;
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `equipoxusuario`
|
-- Table structure for table `equipoxusuario`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `equipoxusuario`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
|
||||||
CREATE TABLE `equipoxusuario` (
|
CREATE TABLE `equipoxusuario` (
|
||||||
`idEquipoxUsuario` int(11) NOT NULL AUTO_INCREMENT,
|
`idEquipoxUsuario` int NOT NULL,
|
||||||
`idUsuario` int(11) NOT NULL,
|
`idUsuario` int NOT NULL,
|
||||||
`idEquipo` int(11) NOT NULL,
|
`idEquipo` int NOT NULL
|
||||||
PRIMARY KEY (`idEquipoxUsuario`),
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||||
KEY `idUsuario` (`idUsuario`),
|
|
||||||
KEY `idEquipo` (`idEquipo`),
|
|
||||||
CONSTRAINT `equipoxusuario_ibfk_1` FOREIGN KEY (`idUsuario`) REFERENCES `usuario` (`idUsuario`),
|
|
||||||
CONSTRAINT `equipoxusuario_ibfk_2` FOREIGN KEY (`idEquipo`) REFERENCES `equipo` (`idEquipo`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `equipoxusuario`
|
-- Dumping data for table `equipoxusuario`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `equipoxusuario` WRITE;
|
INSERT INTO `equipoxusuario` (`idEquipoxUsuario`, `idUsuario`, `idEquipo`) VALUES
|
||||||
/*!40000 ALTER TABLE `equipoxusuario` DISABLE KEYS */;
|
|
||||||
INSERT INTO `equipoxusuario` VALUES
|
|
||||||
(1, 1, 1),
|
(1, 1, 1),
|
||||||
(2, 2, 1),
|
(2, 2, 1),
|
||||||
(3, 3, 1),
|
(3, 3, 1),
|
||||||
@@ -152,68 +123,48 @@ INSERT INTO `equipoxusuario` VALUES
|
|||||||
(8, 8, 3),
|
(8, 8, 3),
|
||||||
(9, 9, 4),
|
(9, 9, 4),
|
||||||
(10, 10, 4);
|
(10, 10, 4);
|
||||||
/*!40000 ALTER TABLE `equipoxusuario` ENABLE KEYS */;
|
|
||||||
UNLOCK TABLES;
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `partida`
|
-- Table structure for table `partida`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `partida`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
|
||||||
CREATE TABLE `partida` (
|
CREATE TABLE `partida` (
|
||||||
`idPartida` int(11) NOT NULL AUTO_INCREMENT,
|
`idPartida` int NOT NULL,
|
||||||
`nombrePartida` varchar(100) NOT NULL,
|
`nombrePartida` varchar(100) COLLATE utf8mb4_spanish_ci NOT NULL,
|
||||||
`idUsuario` int(11) NOT NULL,
|
`idUsuario` int NOT NULL,
|
||||||
`fechaCreacion` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`fechaCreacion` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`fechaInicio` DATETIME NULL,
|
`fechaInicio` datetime DEFAULT NULL,
|
||||||
`fechaFin` DATETIME NULL,
|
`fechaFin` datetime DEFAULT NULL
|
||||||
PRIMARY KEY (`idPartida`),
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||||
KEY `FK idUsuario tabla usuario` (`idUsuario`),
|
|
||||||
CONSTRAINT `FK idUsuario tabla usuario` FOREIGN KEY (`idUsuario`) REFERENCES `usuario` (`idUsuario`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `partida`
|
-- Dumping data for table `partida`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `partida` WRITE;
|
INSERT INTO `partida` (`idPartida`, `nombrePartida`, `idUsuario`, `fechaCreacion`, `fechaInicio`, `fechaFin`) VALUES
|
||||||
/*!40000 ALTER TABLE `partida` DISABLE KEYS */;
|
(1, 'Partida de prueba 1', 1, '2026-10-01 09:03:18', NULL, NULL),
|
||||||
INSERT INTO `partida` (idPartida, nombrePartida, idUsuario, fechaInicio, fechaFin) VALUES
|
(2, 'Partida de prueba 2', 4, '2026-10-01 09:03:18', NULL, NULL),
|
||||||
(1,'Partida de prueba 1',1, NULL, NULL),
|
(3, 'Partida de prueba 3', 9, '2026-10-01 09:03:18', NULL, NULL);
|
||||||
(2,'Partida de prueba 2',4, NULL, NULL),
|
|
||||||
(3,'Partida de prueba 3',9, NULL, NULL);
|
-- --------------------------------------------------------
|
||||||
/*!40000 ALTER TABLE `partida` ENABLE KEYS */;
|
|
||||||
UNLOCK TABLES;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `partidaxpregunta`
|
-- Table structure for table `partidaxpregunta`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `partidaxpregunta`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
|
||||||
CREATE TABLE `partidaxpregunta` (
|
CREATE TABLE `partidaxpregunta` (
|
||||||
`idPartidaxPregunta` int(11) NOT NULL AUTO_INCREMENT,
|
`idPartidaxPregunta` int NOT NULL,
|
||||||
`idPartida` int(11) NOT NULL,
|
`idPartida` int NOT NULL,
|
||||||
`idPregunta` int(11) NOT NULL,
|
`idPregunta` int NOT NULL
|
||||||
PRIMARY KEY (`idPartidaxPregunta`),
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||||
KEY `idPartida` (`idPartida`),
|
|
||||||
KEY `idPregunta` (`idPregunta`),
|
|
||||||
CONSTRAINT `partidaxpregunta_ibfk_1` FOREIGN KEY (`idPartida`) REFERENCES `partida` (`idPartida`),
|
|
||||||
CONSTRAINT `partidaxpregunta_ibfk_2` FOREIGN KEY (`idPregunta`) REFERENCES `pregunta` (`idPregunta`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `partidaxpregunta`
|
-- Dumping data for table `partidaxpregunta`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `partidaxpregunta` WRITE;
|
INSERT INTO `partidaxpregunta` (`idPartidaxPregunta`, `idPartida`, `idPregunta`) VALUES
|
||||||
/*!40000 ALTER TABLE `partidaxpregunta` DISABLE KEYS */;
|
|
||||||
INSERT INTO `partidaxpregunta` VALUES
|
|
||||||
(1, 1, 2140),
|
(1, 1, 2140),
|
||||||
(2, 1, 2141),
|
(2, 1, 2141),
|
||||||
(3, 1, 2142),
|
(3, 1, 2142),
|
||||||
@@ -234,34 +185,24 @@ INSERT INTO `partidaxpregunta` VALUES
|
|||||||
(18, 2, 2158),
|
(18, 2, 2158),
|
||||||
(19, 2, 2159),
|
(19, 2, 2159),
|
||||||
(20, 2, 2160);
|
(20, 2, 2160);
|
||||||
/*!40000 ALTER TABLE `partidaxpregunta` ENABLE KEYS */;
|
|
||||||
UNLOCK TABLES;
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `pregunta`
|
-- Table structure for table `pregunta`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `pregunta`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
|
||||||
CREATE TABLE `pregunta` (
|
CREATE TABLE `pregunta` (
|
||||||
`idPregunta` int(11) NOT NULL AUTO_INCREMENT,
|
`idPregunta` int NOT NULL,
|
||||||
`idCategoria` int(11) NOT NULL,
|
`idCategoria` int NOT NULL,
|
||||||
`nombrePregunta` varchar(255) NOT NULL,
|
`nombrePregunta` varchar(255) COLLATE utf8mb4_spanish_ci NOT NULL
|
||||||
PRIMARY KEY (`idPregunta`),
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||||
UNIQUE KEY `nombrePregunta` (`nombrePregunta`),
|
|
||||||
KEY `idCategoria` (`idCategoria`),
|
|
||||||
CONSTRAINT `pregunta_ibfk_1` FOREIGN KEY (`idCategoria`) REFERENCES `categoria` (`idCategoria`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=2535 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `pregunta`
|
-- Dumping data for table `pregunta`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `pregunta` WRITE;
|
INSERT INTO `pregunta` (`idPregunta`, `idCategoria`, `nombrePregunta`) VALUES
|
||||||
/*!40000 ALTER TABLE `pregunta` DISABLE KEYS */;
|
|
||||||
INSERT INTO `pregunta` VALUES
|
|
||||||
(2140, 4, '¿En qué año llegó Cristóbal Colón a América?'),
|
(2140, 4, '¿En qué año llegó Cristóbal Colón a América?'),
|
||||||
(2141, 5, '¿Cuál es la capital de España?'),
|
(2141, 5, '¿Cuál es la capital de España?'),
|
||||||
(2142, 6, '¿Qué planeta es conocido como el planeta rojo?'),
|
(2142, 6, '¿Qué planeta es conocido como el planeta rojo?'),
|
||||||
@@ -487,42 +428,29 @@ INSERT INTO `pregunta` VALUES
|
|||||||
(2525, 6, '¿Qué científico estudió la electricidad y los rayos con una cometa?'),
|
(2525, 6, '¿Qué científico estudió la electricidad y los rayos con una cometa?'),
|
||||||
(2531, 14, '¿Qué unidad se utiliza normalmente para medir almacenamiento digital?'),
|
(2531, 14, '¿Qué unidad se utiliza normalmente para medir almacenamiento digital?'),
|
||||||
(2534, 16, '¿Qué dulce español se consume tradicionalmente en Navidad?');
|
(2534, 16, '¿Qué dulce español se consume tradicionalmente en Navidad?');
|
||||||
/*!40000 ALTER TABLE `pregunta` ENABLE KEYS */;
|
|
||||||
UNLOCK TABLES;
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `respuesta`
|
-- Table structure for table `respuesta`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `respuesta`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
|
||||||
CREATE TABLE `respuesta` (
|
CREATE TABLE `respuesta` (
|
||||||
`idRespuesta` int(11) NOT NULL AUTO_INCREMENT,
|
`idRespuesta` int NOT NULL,
|
||||||
`idPregunta` int(11) NOT NULL,
|
`idPregunta` int NOT NULL,
|
||||||
`nombreRespuesta` varchar(255) NOT NULL,
|
`nombreRespuesta` varchar(255) COLLATE utf8mb4_spanish_ci NOT NULL,
|
||||||
`correcta` tinyint(1) DEFAULT 0,
|
`correcta` tinyint(1) DEFAULT '0'
|
||||||
PRIMARY KEY (`idRespuesta`),
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||||
KEY `idPregunta` (`idPregunta`),
|
|
||||||
CONSTRAINT `respuesta_ibfk_1` FOREIGN KEY (`idPregunta`) REFERENCES `pregunta` (`idPregunta`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=4935 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `respuesta`
|
-- Dumping data for table `respuesta`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `respuesta` WRITE;
|
INSERT INTO `respuesta` (`idRespuesta`, `idPregunta`, `nombreRespuesta`, `correcta`) VALUES
|
||||||
/*!40000 ALTER TABLE `respuesta` DISABLE KEYS */;
|
|
||||||
INSERT INTO `respuesta` VALUES
|
|
||||||
(3355, 2140, '1492', 1),
|
(3355, 2140, '1492', 1),
|
||||||
(3356, 2140, '1512', 0),
|
(3356, 2140, '1512', 0),
|
||||||
(3357, 2140, '1453', 0),
|
(3357, 2140, '1453', 0),
|
||||||
(3358, 2140, '1600', 0),
|
(3358, 2140, '1600', 0),
|
||||||
(3399,2141,'Madrid',1),
|
|
||||||
(3400,2141,'Barcelona',0),
|
|
||||||
(3401,2141,'Sevilla',0),
|
|
||||||
(3402,2141,'Valencia',0),
|
|
||||||
(3363, 2142, 'Marte', 1),
|
(3363, 2142, 'Marte', 1),
|
||||||
(3364, 2142, 'Venus', 0),
|
(3364, 2142, 'Venus', 0),
|
||||||
(3365, 2142, 'Júpiter', 0),
|
(3365, 2142, 'Júpiter', 0),
|
||||||
@@ -559,6 +487,10 @@ INSERT INTO `respuesta` VALUES
|
|||||||
(3396, 2150, 'Julio César', 0),
|
(3396, 2150, 'Julio César', 0),
|
||||||
(3397, 2150, 'Nerón', 0),
|
(3397, 2150, 'Nerón', 0),
|
||||||
(3398, 2150, 'Trajano', 0),
|
(3398, 2150, 'Trajano', 0),
|
||||||
|
(3399, 2141, 'Madrid', 1),
|
||||||
|
(3400, 2141, 'Barcelona', 0),
|
||||||
|
(3401, 2141, 'Sevilla', 0),
|
||||||
|
(3402, 2141, 'Valencia', 0),
|
||||||
(3403, 2152, 'Oxígeno', 1),
|
(3403, 2152, 'Oxígeno', 1),
|
||||||
(3404, 2152, 'Helio', 0),
|
(3404, 2152, 'Helio', 0),
|
||||||
(3405, 2152, 'Hidrógeno', 0),
|
(3405, 2152, 'Hidrógeno', 0),
|
||||||
@@ -1415,70 +1347,44 @@ INSERT INTO `respuesta` VALUES
|
|||||||
(4932, 2534, 'Croissant', 0),
|
(4932, 2534, 'Croissant', 0),
|
||||||
(4933, 2534, 'Brownie', 0),
|
(4933, 2534, 'Brownie', 0),
|
||||||
(4934, 2534, 'Tiramisú', 0);
|
(4934, 2534, 'Tiramisú', 0);
|
||||||
/*!40000 ALTER TABLE `respuesta` ENABLE KEYS */;
|
|
||||||
UNLOCK TABLES;
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `respuestaalmacenada`
|
-- Table structure for table `respuestaalmacenada`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `respuestaalmacenada`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
|
||||||
CREATE TABLE `respuestaalmacenada` (
|
CREATE TABLE `respuestaalmacenada` (
|
||||||
`idRespuestaAlmacenada` int(11) NOT NULL AUTO_INCREMENT,
|
`idRespuestaAlmacenada` int NOT NULL,
|
||||||
`idPartidaxPregunta` int(11) NOT NULL,
|
`idPartidaxPregunta` int NOT NULL,
|
||||||
`idUsuario` int(11) NOT NULL,
|
`idUsuario` int NOT NULL,
|
||||||
`idRespuesta` int(11) NOT NULL,
|
`idRespuesta` int NOT NULL,
|
||||||
`primero` tinyint(1) DEFAULT 0,
|
`tiempoRespuesta` int NOT NULL
|
||||||
PRIMARY KEY (`idRespuestaAlmacenada`),
|
|
||||||
KEY `idPartidaxPregunta` (`idPartidaxPregunta`),
|
|
||||||
KEY `idUsuario` (`idUsuario`),
|
|
||||||
KEY `idRespuesta` (`idRespuesta`),
|
|
||||||
CONSTRAINT `respuestaalmacenada_ibfk_1` FOREIGN KEY (`idPartidaxPregunta`) REFERENCES `partidaxpregunta` (`idPartidaxPregunta`) ON DELETE CASCADE,
|
|
||||||
CONSTRAINT `respuestaalmacenada_ibfk_2` FOREIGN KEY (`idUsuario`) REFERENCES `usuario` (`idUsuario`) ON DELETE CASCADE,
|
|
||||||
CONSTRAINT `respuestaalmacenada_ibfk_3` FOREIGN KEY (`idRespuesta`) REFERENCES `respuesta` (`idRespuesta`) ON DELETE CASCADE
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
-- --------------------------------------------------------
|
||||||
-- Dumping data for table `respuestaalmacenada`
|
|
||||||
--
|
|
||||||
|
|
||||||
LOCK TABLES `respuestaalmacenada` WRITE;
|
|
||||||
/*!40000 ALTER TABLE `respuestaalmacenada` DISABLE KEYS */;
|
|
||||||
/*!40000 ALTER TABLE `respuestaalmacenada` ENABLE KEYS */;
|
|
||||||
UNLOCK TABLES;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Table structure for table `usuario`
|
-- Table structure for table `usuario`
|
||||||
--
|
--
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `usuario`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8mb4 */;
|
|
||||||
CREATE TABLE `usuario` (
|
CREATE TABLE `usuario` (
|
||||||
`idUsuario` int(11) NOT NULL AUTO_INCREMENT,
|
`idUsuario` int NOT NULL,
|
||||||
`nombreUsuario` varchar(50) NOT NULL,
|
`nombreUsuario` varchar(50) COLLATE utf8mb4_spanish_ci NOT NULL,
|
||||||
`contrasena` varchar(100) NOT NULL,
|
`contrasena` varchar(100) COLLATE utf8mb4_spanish_ci NOT NULL,
|
||||||
`email` varchar(50) NOT NULL,
|
`email` varchar(50) COLLATE utf8mb4_spanish_ci NOT NULL,
|
||||||
`avatar` varchar(200) DEFAULT NULL,
|
`avatar` varchar(200) COLLATE utf8mb4_spanish_ci DEFAULT NULL,
|
||||||
`cookie` varchar(200) DEFAULT NULL,
|
`cookie` varchar(200) COLLATE utf8mb4_spanish_ci DEFAULT NULL,
|
||||||
`aciertos` int(11) NOT NULL,
|
`aciertos` int NOT NULL,
|
||||||
`victorias` int(11) NOT NULL,
|
`victorias` int NOT NULL,
|
||||||
`derrotas` int(11) NOT NULL,
|
`derrotas` int NOT NULL
|
||||||
PRIMARY KEY (`idUsuario`),
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||||
UNIQUE KEY `email` (`email`)
|
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `usuario`
|
-- Dumping data for table `usuario`
|
||||||
--
|
--
|
||||||
|
|
||||||
LOCK TABLES `usuario` WRITE;
|
INSERT INTO `usuario` (`idUsuario`, `nombreUsuario`, `contrasena`, `email`, `avatar`, `cookie`, `aciertos`, `victorias`, `derrotas`) VALUES
|
||||||
/*!40000 ALTER TABLE `usuario` DISABLE KEYS */;
|
|
||||||
INSERT INTO `usuario` VALUES
|
|
||||||
(1, 'Carlos', '1234', 'carlos@test.com', NULL, NULL, 125, 18, 7),
|
(1, 'Carlos', '1234', 'carlos@test.com', NULL, NULL, 125, 18, 7),
|
||||||
(2, 'Lucia', '1234', 'lucia@test.com', NULL, NULL, 98, 14, 9),
|
(2, 'Lucia', '1234', 'lucia@test.com', NULL, NULL, 98, 14, 9),
|
||||||
(3, 'Miguel', 'abcd', 'miguel@test.com', NULL, NULL, 210, 32, 5),
|
(3, 'Miguel', 'abcd', 'miguel@test.com', NULL, NULL, 210, 32, 5),
|
||||||
@@ -1488,21 +1394,203 @@ INSERT INTO `usuario` VALUES
|
|||||||
(7, 'Javier', '1234', 'javier@test.com', NULL, NULL, 185, 27, 8),
|
(7, 'Javier', '1234', 'javier@test.com', NULL, NULL, 185, 27, 8),
|
||||||
(8, 'Marta', 'qwer', 'marta@test.com', NULL, NULL, 67, 9, 13),
|
(8, 'Marta', 'qwer', 'marta@test.com', NULL, NULL, 67, 9, 13),
|
||||||
(9, 'Alejandro', 'qwer', 'alejandro@test.com', NULL, NULL, 240, 41, 4),
|
(9, 'Alejandro', 'qwer', 'alejandro@test.com', NULL, NULL, 240, 41, 4),
|
||||||
(10,'Elena','hola','elena@test.com',NULL,NULL,112,16,10);
|
(10, 'Elena', 'hola', 'elena@test.com', NULL, NULL, 112, 16, 10),
|
||||||
/*!40000 ALTER TABLE `usuario` ENABLE KEYS */;
|
(11, 'papa', '$2y$10$tj.YXSaXhMbh63zYuwbnSuc8bVNzIHI3zZHs1cCmS.iNN25fRbZ5u', 'pepe', 'img/avatars/defaultProfile.jpeg', NULL, 13, 6, 0);
|
||||||
UNLOCK TABLES;
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Dumping routines for database 'triviagmatico'
|
-- Indexes for dumped tables
|
||||||
--
|
--
|
||||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
|
||||||
|
|
||||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
--
|
||||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
-- Indexes for table `categoria`
|
||||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
--
|
||||||
|
ALTER TABLE `categoria`
|
||||||
|
ADD PRIMARY KEY (`idCategoria`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `equipo`
|
||||||
|
--
|
||||||
|
ALTER TABLE `equipo`
|
||||||
|
ADD PRIMARY KEY (`idEquipo`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `equipoxpartida`
|
||||||
|
--
|
||||||
|
ALTER TABLE `equipoxpartida`
|
||||||
|
ADD PRIMARY KEY (`idEquipoxPartida`),
|
||||||
|
ADD KEY `FK idEquipo tabla equipo` (`idEquipo`),
|
||||||
|
ADD KEY `FK idPartida tabla partida` (`idPartida`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `equipoxusuario`
|
||||||
|
--
|
||||||
|
ALTER TABLE `equipoxusuario`
|
||||||
|
ADD PRIMARY KEY (`idEquipoxUsuario`),
|
||||||
|
ADD KEY `idUsuario` (`idUsuario`),
|
||||||
|
ADD KEY `idEquipo` (`idEquipo`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `partida`
|
||||||
|
--
|
||||||
|
ALTER TABLE `partida`
|
||||||
|
ADD PRIMARY KEY (`idPartida`),
|
||||||
|
ADD KEY `FK idUsuario tabla usuario` (`idUsuario`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `partidaxpregunta`
|
||||||
|
--
|
||||||
|
ALTER TABLE `partidaxpregunta`
|
||||||
|
ADD PRIMARY KEY (`idPartidaxPregunta`),
|
||||||
|
ADD KEY `idPartida` (`idPartida`),
|
||||||
|
ADD KEY `idPregunta` (`idPregunta`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `pregunta`
|
||||||
|
--
|
||||||
|
ALTER TABLE `pregunta`
|
||||||
|
ADD PRIMARY KEY (`idPregunta`),
|
||||||
|
ADD UNIQUE KEY `nombrePregunta` (`nombrePregunta`),
|
||||||
|
ADD KEY `idCategoria` (`idCategoria`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `respuesta`
|
||||||
|
--
|
||||||
|
ALTER TABLE `respuesta`
|
||||||
|
ADD PRIMARY KEY (`idRespuesta`),
|
||||||
|
ADD KEY `idPregunta` (`idPregunta`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `respuestaalmacenada`
|
||||||
|
--
|
||||||
|
ALTER TABLE `respuestaalmacenada`
|
||||||
|
ADD PRIMARY KEY (`idRespuestaAlmacenada`),
|
||||||
|
ADD KEY `idPartidaxPregunta` (`idPartidaxPregunta`),
|
||||||
|
ADD KEY `idUsuario` (`idUsuario`),
|
||||||
|
ADD KEY `idRespuesta` (`idRespuesta`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `usuario`
|
||||||
|
--
|
||||||
|
ALTER TABLE `usuario`
|
||||||
|
ADD PRIMARY KEY (`idUsuario`),
|
||||||
|
ADD UNIQUE KEY `email` (`email`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for dumped tables
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `categoria`
|
||||||
|
--
|
||||||
|
ALTER TABLE `categoria`
|
||||||
|
MODIFY `idCategoria` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `equipo`
|
||||||
|
--
|
||||||
|
ALTER TABLE `equipo`
|
||||||
|
MODIFY `idEquipo` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `equipoxpartida`
|
||||||
|
--
|
||||||
|
ALTER TABLE `equipoxpartida`
|
||||||
|
MODIFY `idEquipoxPartida` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `equipoxusuario`
|
||||||
|
--
|
||||||
|
ALTER TABLE `equipoxusuario`
|
||||||
|
MODIFY `idEquipoxUsuario` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `partida`
|
||||||
|
--
|
||||||
|
ALTER TABLE `partida`
|
||||||
|
MODIFY `idPartida` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `partidaxpregunta`
|
||||||
|
--
|
||||||
|
ALTER TABLE `partidaxpregunta`
|
||||||
|
MODIFY `idPartidaxPregunta` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=101;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `pregunta`
|
||||||
|
--
|
||||||
|
ALTER TABLE `pregunta`
|
||||||
|
MODIFY `idPregunta` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2535;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `respuesta`
|
||||||
|
--
|
||||||
|
ALTER TABLE `respuesta`
|
||||||
|
MODIFY `idRespuesta` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4935;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `respuestaalmacenada`
|
||||||
|
--
|
||||||
|
ALTER TABLE `respuestaalmacenada`
|
||||||
|
MODIFY `idRespuestaAlmacenada` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=51;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT for table `usuario`
|
||||||
|
--
|
||||||
|
ALTER TABLE `usuario`
|
||||||
|
MODIFY `idUsuario` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Constraints for dumped tables
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Constraints for table `equipoxpartida`
|
||||||
|
--
|
||||||
|
ALTER TABLE `equipoxpartida`
|
||||||
|
ADD CONSTRAINT `FK idEquipo tabla equipo` FOREIGN KEY (`idEquipo`) REFERENCES `equipo` (`idEquipo`),
|
||||||
|
ADD CONSTRAINT `FK idPartida tabla partida` FOREIGN KEY (`idPartida`) REFERENCES `partida` (`idPartida`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Constraints for table `equipoxusuario`
|
||||||
|
--
|
||||||
|
ALTER TABLE `equipoxusuario`
|
||||||
|
ADD CONSTRAINT `equipoxusuario_ibfk_1` FOREIGN KEY (`idUsuario`) REFERENCES `usuario` (`idUsuario`),
|
||||||
|
ADD CONSTRAINT `equipoxusuario_ibfk_2` FOREIGN KEY (`idEquipo`) REFERENCES `equipo` (`idEquipo`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Constraints for table `partida`
|
||||||
|
--
|
||||||
|
ALTER TABLE `partida`
|
||||||
|
ADD CONSTRAINT `FK idUsuario tabla usuario` FOREIGN KEY (`idUsuario`) REFERENCES `usuario` (`idUsuario`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Constraints for table `partidaxpregunta`
|
||||||
|
--
|
||||||
|
ALTER TABLE `partidaxpregunta`
|
||||||
|
ADD CONSTRAINT `partidaxpregunta_ibfk_1` FOREIGN KEY (`idPartida`) REFERENCES `partida` (`idPartida`),
|
||||||
|
ADD CONSTRAINT `partidaxpregunta_ibfk_2` FOREIGN KEY (`idPregunta`) REFERENCES `pregunta` (`idPregunta`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Constraints for table `pregunta`
|
||||||
|
--
|
||||||
|
ALTER TABLE `pregunta`
|
||||||
|
ADD CONSTRAINT `pregunta_ibfk_1` FOREIGN KEY (`idCategoria`) REFERENCES `categoria` (`idCategoria`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Constraints for table `respuesta`
|
||||||
|
--
|
||||||
|
ALTER TABLE `respuesta`
|
||||||
|
ADD CONSTRAINT `respuesta_ibfk_1` FOREIGN KEY (`idPregunta`) REFERENCES `pregunta` (`idPregunta`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Constraints for table `respuestaalmacenada`
|
||||||
|
--
|
||||||
|
ALTER TABLE `respuestaalmacenada`
|
||||||
|
ADD CONSTRAINT `respuestaalmacenada_ibfk_1` FOREIGN KEY (`idPartidaxPregunta`) REFERENCES `partidaxpregunta` (`idPartidaxPregunta`) ON DELETE CASCADE,
|
||||||
|
ADD CONSTRAINT `respuestaalmacenada_ibfk_2` FOREIGN KEY (`idUsuario`) REFERENCES `usuario` (`idUsuario`) ON DELETE CASCADE,
|
||||||
|
ADD CONSTRAINT `respuestaalmacenada_ibfk_3` FOREIGN KEY (`idRespuesta`) REFERENCES `respuesta` (`idRespuesta`) ON DELETE CASCADE;
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */;
|
|
||||||
|
|
||||||
-- Dump completed on 2026-09-25 10:00:41
|
|
||||||
+3
-19
@@ -1,17 +1,3 @@
|
|||||||
<?php
|
|
||||||
if (session_status() === PHP_SESSION_NONE) {
|
|
||||||
session_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redirección si el usuario no ha iniciado sesión
|
|
||||||
if (!isset($_SESSION['idUsuario'])) {
|
|
||||||
header('Location: login.php');
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$nombreUsuario = htmlspecialchars($_SESSION['nombreUsuario'] ?? 'Usuario');
|
|
||||||
$avatarUsuario = htmlspecialchars($_SESSION['avatar'] ?? 'img/avatars/defaultProfile.jpeg');
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="es">
|
<html lang="es">
|
||||||
|
|
||||||
@@ -20,7 +6,7 @@ $avatarUsuario = htmlspecialchars($_SESSION['avatar'] ?? 'img/avatars/defaultPro
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
||||||
|
|
||||||
<title>Perfil</title>
|
<title>Trivial - Perfil</title>
|
||||||
|
|
||||||
<!-- Bootstrap -->
|
<!-- Bootstrap -->
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
@@ -61,15 +47,13 @@ $avatarUsuario = htmlspecialchars($_SESSION['avatar'] ?? 'img/avatars/defaultPro
|
|||||||
<div class="col-md-6 text-center">
|
<div class="col-md-6 text-center">
|
||||||
|
|
||||||
<!-- Nombre -->
|
<!-- Nombre -->
|
||||||
<h1 id="nombre" class="nombre">
|
<h1 id="nombre" class="nombre"></h1>
|
||||||
<?= $nombreUsuario ?>
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<!-- FOTO DE PERFIL -->
|
<!-- FOTO DE PERFIL -->
|
||||||
<div class="foto-container">
|
<div class="foto-container">
|
||||||
|
|
||||||
<img id="fotoPerfil"
|
<img id="fotoPerfil"
|
||||||
src="<?= $avatarUsuario ?>"
|
src="img/avatars/defaultProfile.jpeg"
|
||||||
alt="Foto de perfil"
|
alt="Foto de perfil"
|
||||||
class="avatar rounded-circle">
|
class="avatar rounded-circle">
|
||||||
|
|
||||||
|
|||||||
+11
-101
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// resultados.php (Actúa como el Controlador Frontal de esta pantalla)
|
||||||
session_start();
|
session_start();
|
||||||
require_once __DIR__ . '/includes/conexionBD.php';
|
require_once __DIR__ . '/includes/conexionBD.php';
|
||||||
|
require_once __DIR__ . '/modelos/PartidaModelo.php';
|
||||||
|
|
||||||
$idPartida = intval($_GET['idPartida'] ?? 0);
|
$idPartida = intval($_GET['idPartida'] ?? 0);
|
||||||
if ($idPartida <= 0) {
|
if ($idPartida <= 0) {
|
||||||
@@ -12,37 +14,22 @@ if (is_array($conexion)) {
|
|||||||
die("Error de conexión a la base de datos.");
|
die("Error de conexión a la base de datos.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtener listado de jugadores y sus equipos en esta partida
|
// Instanciamos el modelo
|
||||||
$stmt = $conexion->prepare("
|
$modelo = new PartidaModelo($conexion);
|
||||||
SELECT u.idUsuario, u.nombreUsuario, e.idEquipo, e.nombreEquipo
|
|
||||||
FROM equipoxpartida exp
|
|
||||||
INNER JOIN equipoxusuario exu ON exp.idEquipo = exu.idEquipo
|
|
||||||
INNER JOIN usuario u ON exu.idUsuario = u.idUsuario
|
|
||||||
INNER JOIN equipo e ON exu.idEquipo = e.idEquipo
|
|
||||||
WHERE exp.idPartida = :idPartida
|
|
||||||
");
|
|
||||||
$stmt->execute([':idPartida' => $idPartida]);
|
|
||||||
$listaJugadoresRaw = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
|
// Obtenemos datos crudos del modelo
|
||||||
|
$listaJugadoresRaw = $modelo->obtenerJugadoresPartida($idPartida);
|
||||||
$primerosEnAcertar = $_SESSION['primeros_en_acertar'][$idPartida] ?? [];
|
$primerosEnAcertar = $_SESSION['primeros_en_acertar'][$idPartida] ?? [];
|
||||||
|
|
||||||
$jugadoresFinales = [];
|
$jugadoresFinales = [];
|
||||||
$equiposFinales = [];
|
$equiposFinales = [];
|
||||||
|
|
||||||
// Respuestas de velocidad (+2 o +1) procesadas en la capa de la vista
|
// Procesamiento de la lógica de negocio (puntos y velocidad)
|
||||||
foreach ($listaJugadoresRaw as $jugador) {
|
foreach ($listaJugadoresRaw as $jugador) {
|
||||||
$idU = (int)$jugador['idUsuario'];
|
$idU = (int)$jugador['idUsuario'];
|
||||||
$idE = (int)$jugador['idEquipo'];
|
$idE = (int)$jugador['idEquipo'];
|
||||||
|
|
||||||
$stmtRespuestas = $conexion->prepare("
|
$respuestasUsuario = $modelo->obtenerRespuestasUsuario($idPartida, $idU);
|
||||||
SELECT ra.idPartidaxPregunta, r.correcta
|
|
||||||
FROM respuestaalmacenada ra
|
|
||||||
INNER JOIN respuesta r ON ra.idRespuesta = r.idRespuesta
|
|
||||||
INNER JOIN partidaxpregunta pxp ON ra.idPartidaxPregunta = pxp.idPartidaxPregunta
|
|
||||||
WHERE pxp.idPartida = :idPartida AND ra.idUsuario = :idUsuario
|
|
||||||
");
|
|
||||||
$stmtRespuestas->execute([':idPartida' => $idPartida, ':idUsuario' => $idU]);
|
|
||||||
$respuestasUsuario = $stmtRespuestas->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
$aciertos = 0;
|
$aciertos = 0;
|
||||||
$puntosTotalesJugador = 0;
|
$puntosTotalesJugador = 0;
|
||||||
@@ -52,6 +39,7 @@ foreach ($listaJugadoresRaw as $jugador) {
|
|||||||
$aciertos++;
|
$aciertos++;
|
||||||
$idPxp = $resp['idPartidaxPregunta'];
|
$idPxp = $resp['idPartidaxPregunta'];
|
||||||
|
|
||||||
|
// Regula si es el más rápido (+2) o normal (+1)
|
||||||
if (isset($primerosEnAcertar[$idPxp]) && $primerosEnAcertar[$idPxp] === $idU) {
|
if (isset($primerosEnAcertar[$idPxp]) && $primerosEnAcertar[$idPxp] === $idU) {
|
||||||
$puntosTotalesJugador += 2;
|
$puntosTotalesJugador += 2;
|
||||||
} else {
|
} else {
|
||||||
@@ -76,86 +64,8 @@ foreach ($listaJugadoresRaw as $jugador) {
|
|||||||
$equiposFinales[$idE]['puntos'] += $puntosTotalesJugador;
|
$equiposFinales[$idE]['puntos'] += $puntosTotalesJugador;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ordenaciones de rankings
|
||||||
usort($jugadoresFinales, function($a, $b) { return $b['puntos'] <=> $a['puntos']; });
|
usort($jugadoresFinales, function($a, $b) { return $b['puntos'] <=> $a['puntos']; });
|
||||||
usort($equiposFinales, function($a, $b) { return $b['puntos'] <=> $a['puntos']; });
|
usort($equiposFinales, function($a, $b) { return $b['puntos'] <=> $a['puntos']; });
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
require_once __DIR__ . '/vistas/vistaResultados.php';
|
||||||
<html lang="es">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Resultados - Trivial</title>
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">
|
|
||||||
<link rel="stylesheet" href="css/index.css">
|
|
||||||
<link rel="stylesheet" href="css/resultados.css">
|
|
||||||
<script src="js/jquery-4.0.0.min.js"></script>
|
|
||||||
</head>
|
|
||||||
<body data-id-partida="<?php echo $idPartida; ?>">
|
|
||||||
|
|
||||||
<div id="pantalla-espera" class="contenedor">
|
|
||||||
<h2> <i class="bi bi-hourglass"></i> Esperando a que todos los jugadores terminen...</h2>
|
|
||||||
<p>Calculando estadísticas de velocidad y actualizando perfiles históricos en el servidor.</p>
|
|
||||||
<div class="loader"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="pantalla-resultados" class="contenedor" style="display:none;">
|
|
||||||
<h1> <i class="bi bi-trophy-fill"></i> Resultados de la Partida <i class="bi bi-trophy-fill"></i> </h1>
|
|
||||||
|
|
||||||
<h2>Clasificación por Equipos</h2>
|
|
||||||
<table class="tabla-ranking">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Posición</th>
|
|
||||||
<th>Equipo</th>
|
|
||||||
<th>Puntos Totales</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($equiposFinales as $index => $eq): ?>
|
|
||||||
<tr class="<?php echo $index === 0 ? 'top-team' : ''; ?>">
|
|
||||||
<td>#<?php echo $index + 1; ?></td>
|
|
||||||
<td><?php echo htmlspecialchars($eq['nombre']); ?></td>
|
|
||||||
<td><strong><?php echo $eq['puntos']; ?> pts</strong></td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<h2>Rendimiento Individual</h2>
|
|
||||||
<table class="tabla-ranking">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Posición</th>
|
|
||||||
<th>Jugador</th>
|
|
||||||
<th>Equipo</th>
|
|
||||||
<th>Aciertos</th>
|
|
||||||
<th>Puntos Logrados</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($jugadoresFinales as $index => $jug): ?>
|
|
||||||
<tr class="<?php echo $index === 0 ? 'top-player' : ''; ?>">
|
|
||||||
<td>#<?php echo $index + 1; ?></td>
|
|
||||||
<td><?php echo htmlspecialchars($jug['nombre']); ?></td>
|
|
||||||
<td><?php echo htmlspecialchars($jug['equipo']); ?></td>
|
|
||||||
<td><?php echo $jug['aciertos']; ?> / 10</td>
|
|
||||||
<td><strong><?php echo $jug['puntos']; ?> pts</strong></td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="contenedor-boton">
|
|
||||||
<a href="<?= $_ENV['urlBase'] ?>/" id="btnVolverInicio" data-id="<?php echo $idPartida; ?>" class="btn btn-play-kahoot"> <i class="bi bi-arrow-left"></i> Volver al Inicio <i class="bi bi-house-fill"></i> </a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="js/resultados.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Trivial - Resultados</title>
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">
|
||||||
|
<link rel="stylesheet" href="css/index.css">
|
||||||
|
<link rel="stylesheet" href="css/resultados.css">
|
||||||
|
<script src="js/jquery-4.0.0.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body data-id-partida="<?php echo $idPartida; ?>">
|
||||||
|
|
||||||
|
<div id="pantalla-espera" class="contenedor">
|
||||||
|
<h2> <i class="bi bi-hourglass-split"></i> Esperando a que todos los jugadores terminen...</h2>
|
||||||
|
<p>Calculando estadísticas de velocidad y actualizando perfiles históricos en el servidor.</p>
|
||||||
|
<div class="loader"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="pantalla-resultados" class="contenedor" style="display:none;">
|
||||||
|
<h1><i class="bi bi-trophy-fill"></i> Resultados de la Partida <i class="bi bi-trophy-fill"></i></h1>
|
||||||
|
|
||||||
|
<h2>Clasificación por Equipos</h2>
|
||||||
|
<table class="tabla-ranking">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Posición</th>
|
||||||
|
<th>Equipo</th>
|
||||||
|
<th>Puntos Totales</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($equiposFinales as $index => $eq): ?>
|
||||||
|
<tr class="<?php echo $index === 0 ? 'top-team' : ''; ?>">
|
||||||
|
<td>#<?php echo $index + 1; ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($eq['nombre']); ?></td>
|
||||||
|
<td><strong><?php echo $eq['puntos']; ?> pts</strong></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2>Rendimiento Individual</h2>
|
||||||
|
<table class="tabla-ranking">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Posición</th>
|
||||||
|
<th>Jugador</th>
|
||||||
|
<th>Equipo</th>
|
||||||
|
<th>Aciertos</th>
|
||||||
|
<th>Puntos Logrados</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($jugadoresFinales as $index => $jug): ?>
|
||||||
|
<tr class="<?php echo $index === 0 ? 'top-player' : ''; ?>">
|
||||||
|
<td>#<?php echo $index + 1; ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($jug['nombre']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($jug['equipo']); ?></td>
|
||||||
|
<td><?php echo $jug['aciertos']; ?> / 10</td>
|
||||||
|
<td><strong><?php echo $jug['puntos']; ?> pts</strong></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="contenedor-boton">
|
||||||
|
<a href="<?php echo $_ENV['urlBase'] ?>" id="btnVolverInicio" data-id="<?php echo $idPartida; ?>" class="btn btn-play-kahoot"> <i class="bi bi-arrow-left"></i> Volver al Inicio <i class="bi bi-house-fill"></i> </a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="js/resultados.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user