Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f74b518d22 | |||
| 77e512be5b |
+1
-1
@@ -71,7 +71,7 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancelar</button>
|
||||
<button type="button" class="btn btn-kahoot-register" id="btnCrearSala">Crear sala</button>
|
||||
<button type="button" class="btn btn-kahoot-login" id="btnCrearSala">Crear sala</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,118 +1,79 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once '../clases/claseJuego.php';
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
// Comprobamos que haya un usuario conectado
|
||||
|
||||
// Hay que estar logueado y decir de qué partida se trata
|
||||
if (!isset($_SESSION['idUsuario'])) {
|
||||
echo json_encode([
|
||||
'error' => 'Debes iniciar sesión para jugar.'
|
||||
]);
|
||||
|
||||
echo json_encode(['error' => 'Debes iniciar sesión para jugar.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$idUsuario = (int)$_SESSION['idUsuario'];
|
||||
|
||||
// Comprobamos que se haya indicado la partida
|
||||
|
||||
if (!isset($_POST['idPartida'])) {
|
||||
echo json_encode([
|
||||
'error' => 'No se ha indicado la partida.'
|
||||
]);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$idPartida = intval($_POST['idPartida']);
|
||||
$idPartida = intval($_POST['idPartida'] ?? 0);
|
||||
|
||||
if ($idPartida <= 0) {
|
||||
echo json_encode([
|
||||
'error' => 'La partida indicada no es válida.'
|
||||
]);
|
||||
|
||||
echo json_encode(['error' => 'No se ha indicado la partida.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Comprobamos que el usuario pertenezca a la partida
|
||||
|
||||
// Solo pueden jugar los usuarios que están en uno de los equipos de la partida
|
||||
$perteneceAPartida = Juego::usuarioEnPartida($idPartida, $idUsuario);
|
||||
|
||||
if (is_array($perteneceAPartida)) {
|
||||
echo json_encode($perteneceAPartida);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
if (!$perteneceAPartida) {
|
||||
echo json_encode([
|
||||
'error' => 'No formas parte de esta partida.'
|
||||
]);
|
||||
|
||||
echo json_encode(['error' => 'No formas parte de esta partida.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Comprobamos la orden
|
||||
|
||||
$orden = $_POST['orden'] ?? '';
|
||||
|
||||
switch ($orden) {
|
||||
|
||||
// CARGAR LAS PREGUNTAS DE LA PARTIDA
|
||||
switch ($_POST['orden'] ?? '') {
|
||||
|
||||
// Devuelve las 10 preguntas con sus respuestas (sin marcar la correcta)
|
||||
case 'cargarPreguntas':
|
||||
|
||||
$resultado = Juego::cargarPreguntas($idPartida, $idUsuario);
|
||||
echo json_encode($resultado);
|
||||
echo json_encode(Juego::cargarPreguntas($idPartida, $idUsuario));
|
||||
|
||||
break;
|
||||
|
||||
// REGISTRAR RESPUESTA
|
||||
|
||||
// Guarda la respuesta del usuario y dice si ha acertado
|
||||
case 'responder':
|
||||
|
||||
if (!isset($_POST['idPartidaxPregunta']) || !isset($_POST['idRespuesta'])){
|
||||
echo json_encode([
|
||||
'error' => 'Faltan datos para registrar la respuesta.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$idPartidaxPregunta = intval($_POST['idPartidaxPregunta']);
|
||||
|
||||
$idRespuesta = intval($_POST['idRespuesta']);
|
||||
$idPartidaxPregunta = intval($_POST['idPartidaxPregunta'] ?? 0);
|
||||
$idRespuesta = intval($_POST['idRespuesta'] ?? 0);
|
||||
|
||||
if ($idPartidaxPregunta <= 0 || $idRespuesta <= 0) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'Los datos de la respuesta no son válidos.'
|
||||
]);
|
||||
|
||||
echo json_encode(['error' => 'Faltan datos para registrar la respuesta.']);
|
||||
break;
|
||||
}
|
||||
|
||||
// Registramos la respuesta del usuario
|
||||
|
||||
$resultado = Juego::registrarRespuesta($idPartida, $idUsuario, $idPartidaxPregunta, $idRespuesta);
|
||||
|
||||
echo json_encode($resultado);
|
||||
echo json_encode(
|
||||
Juego::registrarRespuesta(
|
||||
$idPartida,
|
||||
$idUsuario,
|
||||
$idPartidaxPregunta,
|
||||
$idRespuesta
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
// Finalizar la partida y registrar los aciertos del usuario
|
||||
|
||||
// Recibe los aciertos del jugador al terminar sus 10 preguntas,
|
||||
// para que resultados.php los pueda usar al montar la hoja de resultados
|
||||
case 'finalizarPartida':
|
||||
|
||||
$aciertos = intval($_POST['aciertos'] ?? 0);
|
||||
|
||||
// Guardamos los aciertos en la sesión
|
||||
|
||||
if (!isset($_SESSION['aciertosPorPartida'])) {
|
||||
|
||||
$_SESSION['aciertosPorPartida'] = [];
|
||||
}
|
||||
|
||||
@@ -120,21 +81,16 @@ switch ($orden) {
|
||||
|
||||
echo json_encode([
|
||||
'exito' => 'Aciertos registrados correctamente.',
|
||||
|
||||
'idPartida' => $idPartida,
|
||||
|
||||
'aciertos' => $aciertos
|
||||
]);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'La orden indicada no existe.'
|
||||
]);
|
||||
echo json_encode(['error' => 'La orden indicada no existe.']);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?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');
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/conexionBD.php';
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
@@ -26,7 +26,7 @@ if (is_array($conexion)) {
|
||||
switch ($orden) {
|
||||
case 'comprobarEstado':
|
||||
try {
|
||||
// 1. Contar cuántos jugadores hay asignados en esta partida
|
||||
// Contar jugadores totales apuntados en los equipos de esta partida
|
||||
$stmt = $conexion->prepare("
|
||||
SELECT COUNT(exu.idUsuario) AS total_jugadores
|
||||
FROM equipoxpartida exp
|
||||
@@ -38,7 +38,7 @@ switch ($orden) {
|
||||
|
||||
$preguntasTotalesEsperadas = $totalJugadores * 10;
|
||||
|
||||
// 2. Contar cuántas respuestas reales se han guardado
|
||||
// Contar respuestas dadas en la partida
|
||||
$stmtRespuestas = $conexion->prepare("
|
||||
SELECT COUNT(*)
|
||||
FROM respuestaalmacenada ra
|
||||
@@ -50,16 +50,17 @@ switch ($orden) {
|
||||
|
||||
$terminada = ($respuestasRespondidas >= $preguntasTotalesEsperadas && $preguntasTotalesEsperadas > 0);
|
||||
|
||||
// 3. Si ha terminado, guardamos los datos históricos una sola vez
|
||||
// Cuando la partida finaliza, se actualizan los históricos
|
||||
if ($terminada && !isset($_SESSION['partidas_procesadas'][$idPartida])) {
|
||||
|
||||
$conexion->beginTransaction();
|
||||
|
||||
// --- CÁLCULO DE VELOCIDAD ---
|
||||
// CÁLCULO DE VELOCIDAD PREGUNTA A PREGUNTA EN SESIÓN
|
||||
if (!isset($_SESSION['primeros_en_acertar'][$idPartida])) {
|
||||
$_SESSION['primeros_en_acertar'][$idPartida] = [];
|
||||
}
|
||||
|
||||
// Vemos quién fue el primero
|
||||
$stmtVelocidad = $conexion->prepare("
|
||||
SELECT ra.idPartidaxPregunta, ra.idUsuario
|
||||
FROM respuestaalmacenada ra
|
||||
@@ -80,7 +81,8 @@ switch ($orden) {
|
||||
}
|
||||
}
|
||||
|
||||
// Consulta de aciertos
|
||||
// Actualizamos la base de datos
|
||||
// Buscamos los aciertos de cada jugador en la partida actual
|
||||
$stmtAciertos = $conexion->prepare("
|
||||
SELECT ra.idUsuario, exu.idEquipo, COUNT(*) as aciertos_partida
|
||||
FROM respuestaalmacenada ra
|
||||
@@ -88,12 +90,12 @@ switch ($orden) {
|
||||
INNER JOIN respuesta r ON ra.idRespuesta = r.idRespuesta
|
||||
INNER JOIN equipoxusuario exu ON ra.idUsuario = exu.idUsuario
|
||||
WHERE pxp.idPartida = :idPartida AND r.correcta = 1
|
||||
GROUP BY ra.idUsuario, exu.idEquipo
|
||||
GROUP BY ra.idUsuario
|
||||
");
|
||||
$stmtAciertos->execute([':idPartida' => $idPartida]);
|
||||
$jugadoresPartida = $stmtAciertos->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$updateAciertos = $conexion->prepare("
|
||||
$updateAciertosGlobales = $conexion->prepare("
|
||||
UPDATE usuario
|
||||
SET aciertos = aciertos + :nuevos_aciertos
|
||||
WHERE idUsuario = :idUsuario
|
||||
@@ -105,6 +107,7 @@ switch ($orden) {
|
||||
$idE = (int)$jp['idEquipo'];
|
||||
$nuevosAciertos = (int)$jp['aciertos_partida'];
|
||||
|
||||
// Sumamos los aciertos al perfil del usuario
|
||||
$updateAciertos->execute([
|
||||
':nuevos_aciertos' => $nuevosAciertos,
|
||||
':idUsuario' => $idU
|
||||
@@ -116,10 +119,11 @@ switch ($orden) {
|
||||
$puntosEquipos[$idE] += $nuevosAciertos;
|
||||
}
|
||||
|
||||
if (!empty($puntosEquipos)) {
|
||||
// Determinamos qué equipo ha obtenido más aciertos en la partida
|
||||
arsort($puntosEquipos);
|
||||
$idEquipoGanador = key($puntosEquipos);
|
||||
|
||||
// Obtenemos todos los usuarios de la partida para asignar victorias/derrotas
|
||||
$stmtMiembros = $conexion->prepare("
|
||||
SELECT exu.idUsuario, exu.idEquipo
|
||||
FROM equipoxpartida exp
|
||||
@@ -142,15 +146,6 @@ switch ($orden) {
|
||||
$updateDerrota->execute([':idUsuario' => $idU]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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->execute([':idPartida' => $idPartida]);
|
||||
|
||||
$conexion->commit();
|
||||
$_SESSION['partidas_procesadas'][$idPartida] = true;
|
||||
@@ -165,70 +160,7 @@ switch ($orden) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'registrarSalidaUsuario':
|
||||
try {
|
||||
$idUsuario = (int)$_SESSION['idUsuario'];
|
||||
$conexion->beginTransaction();
|
||||
|
||||
// A. LIBERACIÓN INMEDIATA DEL JUGADOR ACTUAL: Lo borramos de su equipo
|
||||
$stmtSalir = $conexion->prepare("DELETE FROM equipoxusuario WHERE 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("
|
||||
SELECT COUNT(exu.idUsuario)
|
||||
FROM equipoxpartida exp
|
||||
INNER JOIN equipoxusuario exu ON exp.idEquipo = exu.idEquipo
|
||||
WHERE exp.idPartida = :idPartida
|
||||
");
|
||||
$stmtContarQuedan->execute([':idPartida' => $idPartida]);
|
||||
$jugadoresRestantes = (int)$stmtContarQuedan->fetchColumn();
|
||||
|
||||
// C. DESTRUCCIÓN EN CADENA AUTOMÁTICA ATÓMICA (Si da 0, somos los últimos en salir)
|
||||
if ($jugadoresRestantes === 0) {
|
||||
// 1. Limpiar las respuestas almacenadas
|
||||
$stmtBorrarRespuestas = $conexion->prepare("
|
||||
DELETE ra FROM respuestaalmacenada ra
|
||||
INNER JOIN partidaxpregunta pxp ON ra.idPartidaxPregunta = pxp.idPartidaxPregunta
|
||||
WHERE pxp.idPartida = :idPartida
|
||||
");
|
||||
$stmtBorrarRespuestas->execute([':idPartida' => $idPartida]);
|
||||
|
||||
// 2. Limpiar las preguntas vinculadas a la partida
|
||||
$stmtBorrarPreguntas = $conexion->prepare("DELETE FROM partidaxpregunta WHERE 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->execute([':idPartida' => $idPartida]);
|
||||
$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->execute([':idPartida' => $idPartida]);
|
||||
|
||||
// 5. NUEVO: Borrar físicamente los equipos de la tabla 'equipo' si existen
|
||||
if (!empty($equiposDeLaPartida)) {
|
||||
// Creamos los marcadores (?, ?) de forma dinámica según los equipos que devuelva
|
||||
$inQuery = implode(',', array_fill(0, count($equiposDeLaPartida), '?'));
|
||||
$stmtBorrarEquiposFisicos = $conexion->prepare("DELETE FROM equipo WHERE idEquipo IN ($inQuery)");
|
||||
$stmtBorrarEquiposFisicos->execute($equiposDeLaPartida);
|
||||
}
|
||||
|
||||
// 6. Borrar físicamente la fila de la partida principal
|
||||
$stmtBorrarSala = $conexion->prepare("DELETE FROM partida WHERE idPartida = :idPartida");
|
||||
$stmtBorrarSala->execute([':idPartida' => $idPartida]);
|
||||
}
|
||||
|
||||
$conexion->commit();
|
||||
echo json_encode(['exito' => true, 'usuarios_quedan' => $jugadoresRestantes]);
|
||||
} catch (PDOException $e) {
|
||||
if ($conexion->inTransaction()) {
|
||||
$conexion->rollBack();
|
||||
}
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
default:
|
||||
echo json_encode(['error' => 'Acción no permitida']);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -77,9 +77,8 @@
|
||||
}
|
||||
|
||||
.btn-unirse:hover {
|
||||
background-color: #1f6f09;
|
||||
background-color: #0f56ab;
|
||||
color: white;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.modal-kahoot {
|
||||
|
||||
@@ -121,7 +121,6 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 15px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn-play-kahoot:hover {
|
||||
|
||||
@@ -401,18 +401,3 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
.modal-kahoot {
|
||||
border: none;
|
||||
border-radius: 20px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.modal-kahoot-header {
|
||||
background-color: var(--kahoot-purple);
|
||||
color: white;
|
||||
border-bottom: none;
|
||||
}
|
||||
+109
-372
@@ -1,442 +1,179 @@
|
||||
/* ==========================================================================
|
||||
VARIABLES DEL PROYECTO
|
||||
ESTILOS GENERALES Y FONDO
|
||||
========================================================================== */
|
||||
|
||||
:root {
|
||||
--kahoot-purple: #46178f;
|
||||
--kahoot-purple-dark: #35116f;
|
||||
--kahoot-blue: #1368ce;
|
||||
--kahoot-blue-dark: #0c4891;
|
||||
--kahoot-red: #e21b3c;
|
||||
--kahoot-yellow: #ffa602;
|
||||
--kahoot-yellow-dark: #d88900;
|
||||
--kahoot-green: #26890c;
|
||||
--kahoot-green-hover: #1f6f09;
|
||||
|
||||
--background: #f2f2f2;
|
||||
--text-dark: #333333;
|
||||
--text-muted: #666666;
|
||||
--white: #ffffff;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
ESTILOS GENERALES
|
||||
========================================================================== */
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-shadow: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Fredoka', sans-serif;
|
||||
background-color: var(--background);
|
||||
color: var(--text-dark);
|
||||
font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
||||
background-color: #f0f4f8;
|
||||
color: #2c3e50;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
padding: 30px 20px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
CONTENEDOR PRINCIPAL
|
||||
========================================================================== */
|
||||
|
||||
/* Contenedor principal estilo tarjeta */
|
||||
.contenedor {
|
||||
width: 100%;
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
background-color: var(--white);
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.10);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
PANTALLA DE ESPERA
|
||||
========================================================================== */
|
||||
|
||||
#pantalla-espera {
|
||||
padding: 70px 30px;
|
||||
max-width: 900px;
|
||||
background: #ffffff;
|
||||
padding: 40px;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
|
||||
text-align: center;
|
||||
animation: fadeIn 0.5s ease-in-out;
|
||||
}
|
||||
|
||||
#pantalla-espera h2 {
|
||||
color: var(--kahoot-purple);
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
color: #1a365d;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.6rem;
|
||||
color: #2b6cb0;
|
||||
margin-top: 30px;
|
||||
margin-bottom: 15px;
|
||||
text-align: left;
|
||||
border-bottom: 2px solid #e2e8f0;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
#pantalla-espera p {
|
||||
color: var(--text-muted);
|
||||
p {
|
||||
font-size: 1.1rem;
|
||||
margin-bottom: 35px;
|
||||
color: #718096;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
LOADER
|
||||
PANTALLA DE ESPERA Y ANIMACIÓN DE CARGA (LOADER)
|
||||
========================================================================== */
|
||||
#pantalla-espera {
|
||||
padding: 60px 20px;
|
||||
}
|
||||
|
||||
.loader {
|
||||
width: 65px;
|
||||
height: 65px;
|
||||
margin: 0 auto;
|
||||
|
||||
border: 7px solid #e5e5e5;
|
||||
border-top-color: var(--kahoot-purple);
|
||||
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border: 6px solid #e2e8f0;
|
||||
border-top: 6px solid #3182ce;
|
||||
border-radius: 50%;
|
||||
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 0 auto;
|
||||
animation: spin 1.2s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
CABECERA DE RESULTADOS
|
||||
TABLAS DE CLASIFICACIÓN (RANKING)
|
||||
========================================================================== */
|
||||
|
||||
#pantalla-resultados {
|
||||
padding: 40px;
|
||||
}
|
||||
|
||||
#pantalla-resultados h1 {
|
||||
text-align: center;
|
||||
color: var(--kahoot-yellow);
|
||||
font-size: 2.6rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 35px;
|
||||
|
||||
text-shadow: 2px 2px 0 rgba(70, 23, 143, 0.10);
|
||||
}
|
||||
|
||||
#pantalla-resultados h2 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
|
||||
margin-top: 35px;
|
||||
margin-bottom: 15px;
|
||||
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 3px solid #eee;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
TABLAS
|
||||
========================================================================== */
|
||||
|
||||
.tabla-ranking {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
|
||||
overflow: hidden;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border: 2px solid #eeeeee;
|
||||
border-radius: 15px;
|
||||
|
||||
margin-bottom: 30px;
|
||||
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.06);
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 20px;
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
|
||||
/* Cabecera */
|
||||
|
||||
.tabla-ranking thead th {
|
||||
background-color: var(--kahoot-purple);
|
||||
color: white;
|
||||
|
||||
padding: 15px 18px;
|
||||
|
||||
font-size: 0.95rem;
|
||||
font-weight: 700;
|
||||
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
|
||||
.tabla-ranking th,
|
||||
.tabla-ranking td {
|
||||
padding: 16px 20px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.tabla-ranking thead th:first-child {
|
||||
border-top-left-radius: 12px;
|
||||
.tabla-ranking th {
|
||||
background-color: #2d3748;
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
font-size: 0.9rem;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.tabla-ranking thead th:last-child {
|
||||
border-top-right-radius: 12px;
|
||||
/* Alinear los puntos y aciertos a la derecha para mejor lectura numérica */
|
||||
.tabla-ranking th:last-child,
|
||||
.tabla-ranking td:last-child {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
/* Celdas */
|
||||
|
||||
.tabla-ranking tbody td {
|
||||
padding: 16px 18px;
|
||||
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
|
||||
border-bottom: 1px solid #eeeeee;
|
||||
|
||||
color: var(--text-dark);
|
||||
}
|
||||
|
||||
|
||||
/* Última fila */
|
||||
|
||||
.tabla-ranking tbody tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
|
||||
/* Hover */
|
||||
|
||||
.tabla-ranking tbody tr {
|
||||
transition:
|
||||
transform 0.15s ease,
|
||||
background-color 0.15s ease;
|
||||
.tabla-ranking tr {
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.tabla-ranking tbody tr:hover {
|
||||
background-color: #f7f3ff;
|
||||
background-color: #f7fafc;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
COLUMNA DE POSICIÓN
|
||||
RESALTADO DE GANADORES (1º PUESTO)
|
||||
========================================================================== */
|
||||
|
||||
.tabla-ranking tbody td:first-child {
|
||||
font-weight: 700;
|
||||
color: var(--kahoot-purple);
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
PUNTOS
|
||||
========================================================================== */
|
||||
|
||||
.tabla-ranking td strong {
|
||||
color: var(--kahoot-green);
|
||||
font-size: 1.15rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
EQUIPO / JUGADOR GANADOR
|
||||
========================================================================== */
|
||||
|
||||
/* Fila del Equipo Ganador y Jugador Ganador */
|
||||
.tabla-ranking tr.top-team,
|
||||
.tabla-ranking tr.top-player {
|
||||
background-color: #fff7df !important;
|
||||
font-weight: 700;
|
||||
background-color: #fefcbf !important; /* Amarillo suave */
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
/* Línea lateral amarilla */
|
||||
|
||||
/* Cambiar el color del texto del puesto #1 a dorado/corona */
|
||||
.tabla-ranking tr.top-team td:first-child,
|
||||
.tabla-ranking tr.top-player td:first-child {
|
||||
color: var(--kahoot-yellow-dark);
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
|
||||
/* Puntos del ganador */
|
||||
|
||||
.tabla-ranking tr.top-team td strong,
|
||||
.tabla-ranking tr.top-player td strong {
|
||||
color: var(--kahoot-green);
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
BOTÓN VOLVER AL INICIO
|
||||
========================================================================== */
|
||||
|
||||
.contenedor-boton {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
margin-top: 40px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
|
||||
/* Botón */
|
||||
|
||||
.btn-inicio {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
|
||||
min-width: 240px;
|
||||
|
||||
padding: 15px 28px;
|
||||
|
||||
background-color: var(--kahoot-blue);
|
||||
color: white;
|
||||
|
||||
border: none;
|
||||
border-bottom: 5px solid var(--kahoot-blue-dark);
|
||||
|
||||
border-radius: 12px;
|
||||
|
||||
font-family: 'Fredoka', sans-serif;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
|
||||
text-decoration: none;
|
||||
|
||||
box-shadow: 0 5px 10px rgba(19, 104, 206, 0.25);
|
||||
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
|
||||
/* Hover */
|
||||
|
||||
.btn-inicio:hover {
|
||||
background-color: #0f56ab;
|
||||
color: white;
|
||||
|
||||
transform: translateY(-3px);
|
||||
|
||||
box-shadow: 0 8px 15px rgba(19, 104, 206, 0.30);
|
||||
}
|
||||
|
||||
|
||||
/* Click */
|
||||
|
||||
.btn-inicio:active {
|
||||
transform: translateY(3px);
|
||||
|
||||
border-bottom-width: 2px;
|
||||
|
||||
box-shadow: 0 3px 6px rgba(19, 104, 206, 0.20);
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
RESPONSIVE
|
||||
========================================================================== */
|
||||
|
||||
@media (max-width: 768px) {
|
||||
|
||||
body {
|
||||
padding: 15px 10px;
|
||||
}
|
||||
|
||||
#pantalla-resultados {
|
||||
padding: 25px 15px;
|
||||
}
|
||||
|
||||
#pantalla-resultados h1 {
|
||||
font-size: 2rem;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
#pantalla-resultados h2 {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
|
||||
.tabla-ranking {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.tabla-ranking thead th,
|
||||
.tabla-ranking tbody td {
|
||||
padding: 12px 10px;
|
||||
}
|
||||
|
||||
.tabla-ranking thead th {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.tabla-ranking tbody td {
|
||||
font-size: 0.9rem;
|
||||
color: #b7791f;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.tabla-ranking td strong {
|
||||
font-size: 1rem;
|
||||
color: #2f855a; /* Verde para destacar los aciertos conseguidos */
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
EFECTOS VISUALES SUAVES
|
||||
========================================================================== */
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(10px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
ESTILOS DEL BOTÓN DE RETORNO A INICIO
|
||||
========================================================================== */
|
||||
.contenedor-boton {
|
||||
margin-top: 40px;
|
||||
padding-top: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn-inicio {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
display: inline-block;
|
||||
background-color: #3182ce; /* Azul corporativo */
|
||||
color: #ffffff;
|
||||
padding: 14px 28px;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 6px rgba(49, 130, 206, 0.2);
|
||||
transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
|
||||
/* ==========================================================================
|
||||
MÓVILES PEQUEÑOS
|
||||
========================================================================== */
|
||||
|
||||
@media (max-width: 500px) {
|
||||
|
||||
body {
|
||||
padding: 10px 5px;
|
||||
.btn-inicio:hover {
|
||||
background-color: #2b6cb0; /* Azul ligeramente más oscuro al pasar el cursor */
|
||||
box-shadow: 0 6px 12px rgba(43, 108, 176, 0.3);
|
||||
transform: translateY(-2px); /* Pequeño salto hacia arriba */
|
||||
}
|
||||
|
||||
#pantalla-espera {
|
||||
padding: 50px 20px;
|
||||
}
|
||||
|
||||
#pantalla-espera h2 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
#pantalla-espera p {
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
#pantalla-resultados {
|
||||
padding: 20px 10px;
|
||||
}
|
||||
|
||||
#pantalla-resultados h1 {
|
||||
font-size: 1.7rem;
|
||||
}
|
||||
|
||||
#pantalla-resultados h2 {
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
.tabla-ranking {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tabla-ranking thead th,
|
||||
.tabla-ranking tbody td {
|
||||
padding: 10px 8px;
|
||||
}
|
||||
|
||||
.contenedor-boton {
|
||||
margin-top: 25px;
|
||||
}
|
||||
.btn-inicio:active {
|
||||
transform: translateY(0); /* Vuelve a su posición normal al pulsar */
|
||||
box-shadow: 0 2px 4px rgba(43, 108, 176, 0.2);
|
||||
}
|
||||
|
||||
+1
-1
@@ -276,7 +276,7 @@ $(document).on("click", ".btn-abandonar-sala", function () {
|
||||
mensaje.text(
|
||||
"Si abandonas la sala como anfitrión, la partida terminará para todos los jugadores.",
|
||||
);
|
||||
botonConfirmar.text("Sí, terminar partida");
|
||||
botonConfirmar.text("Sí, abandonar");
|
||||
} else {
|
||||
titulo.text("¿Abandonar la sala?");
|
||||
mensaje.text(
|
||||
|
||||
+1
-2
@@ -43,7 +43,7 @@ function comprobarSesion() {
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end user-dropdown-menu" aria-labelledby="userDropdown">
|
||||
<li>
|
||||
<a class="dropdown-item d-flex align-items-center gap-2" href="perfil.php">
|
||||
<a class="dropdown-item d-flex align-items-center gap-2" href="perfil.html">
|
||||
<i class="fa-solid fa-user text-primary"></i> Perfil
|
||||
</a>
|
||||
</li>
|
||||
@@ -203,4 +203,3 @@ $(document).on("click", "#botonCerrarSesion", function (event) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+5
-5
@@ -36,11 +36,11 @@ function renderizarTablaRanking(jugadores) {
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th scope="col" style="width: 10%;">#</th>
|
||||
<th scope="col" class="text-start" style="width: 30%;"><i class="fa-solid fa-user"></i> <br> Jugador</th>
|
||||
<th scope="col" style="width: 15%;"><i class="fa-solid fa-trophy text-warning me-1"></i> <br> Victorias</th>
|
||||
<th scope="col" style="width: 15%;"><i class="fa-solid fa-xmark text-danger me-1"></i> <br> Derrotas</th>
|
||||
<th scope="col" style="width: 15%;"><i class="fa-solid fa-bullseye text-success me-1"></i> <br> Aciertos</th>
|
||||
<th scope="col" style="width: 15%;"><i class="fa-solid fa-medal text-info me-1"></i> <br> Efectividad</th>
|
||||
<th scope="col" class="text-start" style="width: 35%;">Jugador</th>
|
||||
<th scope="col" style="width: 15%;"><i class="fa-solid fa-trophy text-warning me-1"></i> Vic</th>
|
||||
<th scope="col" style="width: 15%;"><i class="fa-solid fa-xmark text-danger me-1"></i> Der</th>
|
||||
<th scope="col" style="width: 15%;"><i class="fa-solid fa-bullseye text-success me-1"></i> Aciertos</th>
|
||||
<th scope="col" style="width: 10%;"><i class="fa-solid fa-percent text-info me-1"></i> % Vic</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
+1
-13
@@ -20,18 +20,7 @@ let bloqueado = false; // true mientras se envía una respuesta o se ve el feedb
|
||||
let numeroAciertos = 0; // número de aciertos del jugador
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// Obtenemos el idPartida de la URL
|
||||
// Ejemplo: juego.php?idPartida=3
|
||||
|
||||
const parametros = new URLSearchParams(window.location.search);
|
||||
|
||||
idPartida = parseInt(parametros.get("idPartida"), 10);
|
||||
|
||||
if (!idPartida || idPartida < 1) {
|
||||
mostrarError("La partida indicada no es válida.");
|
||||
return;
|
||||
}
|
||||
idPartida = parseInt($("body").data("id-partida"), 10);
|
||||
|
||||
// Un solo listener para todos los botones de respuesta
|
||||
$("#respuestas").on("click", ".btn-answer", function () {
|
||||
@@ -114,7 +103,6 @@ function responder($botonPulsado) {
|
||||
if (bloqueado) {
|
||||
return;
|
||||
}
|
||||
|
||||
bloqueado = true;
|
||||
|
||||
const pregunta = preguntas[indice];
|
||||
|
||||
+27
-4
@@ -1,3 +1,26 @@
|
||||
// COMPROBAR SESIÓN Y MOSTRAR NOMBRE/AVATAR
|
||||
// (antes en perfil.php)
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: { orden: "comprobarSesion" },
|
||||
}).done(function (respuesta) {
|
||||
if (typeof respuesta === "string") respuesta = JSON.parse(respuesta);
|
||||
|
||||
if (!respuesta.activa) {
|
||||
// Sin sesión: fuera de aquí
|
||||
window.location.href = "index.php";
|
||||
return;
|
||||
}
|
||||
|
||||
$("#nombre").text(respuesta.usuario.nombreUsuario || "Usuario");
|
||||
$("#fotoPerfil").attr(
|
||||
"src",
|
||||
respuesta.usuario.avatar || "img/avatars/defaultProfile.jpeg"
|
||||
);
|
||||
});
|
||||
|
||||
// =========================
|
||||
// MOSTRAR ESTADISTICAS
|
||||
// =========================
|
||||
@@ -50,8 +73,8 @@ function cambiarNombre() {
|
||||
$("#nuevoNombre").val("");
|
||||
|
||||
|
||||
if (typeof comprobarEstadoSesion === "function") {
|
||||
comprobarEstadoSesion();
|
||||
if (typeof comprobarSesion === "function") {
|
||||
comprobarSesion();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -110,8 +133,8 @@ $("#inputFoto").change(function () {
|
||||
);
|
||||
|
||||
// Actualizamos también el avatar superior en la cabecera
|
||||
if (typeof comprobarEstadoSesion === "function") {
|
||||
comprobarEstadoSesion();
|
||||
if (typeof comprobarSesion === "function") {
|
||||
comprobarSesion();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+10
-52
@@ -1,7 +1,5 @@
|
||||
$(document).ready(function () {
|
||||
// Captura segura del ID de la partida desde el body de la página
|
||||
const idPartida =
|
||||
$("body").attr("data-id-partida") || $("body").data("id-partida");
|
||||
const idPartida = $("body").data("id-partida");
|
||||
|
||||
comprobarEstadoPartida(idPartida);
|
||||
|
||||
@@ -11,70 +9,30 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
function comprobarEstadoPartida(idPartida, intervalo = null) {
|
||||
if (!idPartida || idPartida <= 0) return;
|
||||
|
||||
$.ajax({
|
||||
url: "controladores/controladorResultados.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {
|
||||
orden: "comprobarEstado",
|
||||
idPartida: idPartida,
|
||||
idPartida: idPartida
|
||||
},
|
||||
success: function (respuesta) {
|
||||
if (respuesta.error) {
|
||||
console.error("Error del controlador:", respuesta.error);
|
||||
console.error("Error:", respuesta.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (respuesta.terminada === true || respuesta.terminada === "true") {
|
||||
if (intervalo !== null) {
|
||||
clearInterval(intervalo);
|
||||
}
|
||||
if (respuesta.terminada) {
|
||||
if (intervalo !== null) clearInterval(intervalo);
|
||||
|
||||
$("#pantalla-espera").hide();
|
||||
$("#pantalla-resultados").show();
|
||||
$("#pantalla-espera").fadeOut(400, function() {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
console.log("Esperando conexión con el servidor del Trivial...");
|
||||
},
|
||||
console.log("Error de comunicación con el controlador.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// INTERCEPTOR DE SALIDA: Saca al usuario y destruye la sala en cascada
|
||||
$(document).on("click", "#btnVolverInicio", function (e) {
|
||||
e.preventDefault(); // Congelamos un instante la redirección
|
||||
|
||||
const urlDestino = $(this).attr("href");
|
||||
// Leemos el ID de forma científica directamente desde el botón pulsado
|
||||
const idPartida = $(this).attr("data-id");
|
||||
|
||||
if (!idPartida) {
|
||||
window.location.href = urlDestino;
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "controladores/controladorResultados.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {
|
||||
orden: "registrarSalidaUsuario",
|
||||
idPartida: idPartida,
|
||||
},
|
||||
success: function (response) {
|
||||
console.log(
|
||||
"Servidor procesó la salida. Usuarios restantes: " +
|
||||
response.usuarios_quedan,
|
||||
);
|
||||
},
|
||||
error: function (error) {
|
||||
console.error("Error técnico al salir de la sala:", error);
|
||||
},
|
||||
complete: function () {
|
||||
// Rompemos la pausa y mandamos al jugador al menú de inicio limpio
|
||||
window.location.href = urlDestino;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Hay que estar logueado para jugar
|
||||
if (!isset($_SESSION['idUsuario'])) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
// La partida llega por la URL: juego.php?idPartida=3
|
||||
$idPartida = filter_input(INPUT_GET, 'idPartida', FILTER_VALIDATE_INT);
|
||||
|
||||
if (!$idPartida || $idPartida < 1) {
|
||||
header('Location: buscadorSala.php');
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@@ -8,48 +24,28 @@
|
||||
<title>Proyecto Trivial</title>
|
||||
<link rel="stylesheet" href="css/juego.css">
|
||||
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
||||
|
||||
</head>
|
||||
<body data-id-partida="<?= (int)$idPartida ?>">
|
||||
|
||||
<body>
|
||||
|
||||
<!-- CABECERA Y PROGRESO -->
|
||||
|
||||
<!-- Progreso: "Pregunta 3 de 10" + barra -->
|
||||
<div class="game-header">
|
||||
|
||||
<span id="contadorPregunta">
|
||||
Cargando…
|
||||
</span>
|
||||
|
||||
<span id="contadorPregunta">Cargando…</span>
|
||||
</div>
|
||||
|
||||
<div class="progress-track">
|
||||
|
||||
<div class="progress-fill" id="barraProgreso"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- PREGUNTA -->
|
||||
|
||||
<!-- Contenedor de la Pregunta (lo rellena js/juego.js) -->
|
||||
<div class="question-container">
|
||||
|
||||
<div id="textoPregunta">
|
||||
Cargando preguntas…
|
||||
</div>
|
||||
|
||||
<div id="textoPregunta">Cargando preguntas…</div>
|
||||
<div id="feedback" class="feedback" aria-live="polite"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- RESPUESTAS -->
|
||||
|
||||
<!-- Contenedor de Respuestas (Estilo Kahoot, lo rellena js/juego.js) -->
|
||||
<div class="answers-grid" id="respuestas"></div>
|
||||
|
||||
<!-- JAVASCRIPT -->
|
||||
|
||||
<script src="js/jquery-4.0.0.min.js"></script>
|
||||
<script src="js/juego.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+4
-17
@@ -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>
|
||||
<html lang="es">
|
||||
|
||||
@@ -41,7 +27,7 @@ $avatarUsuario = htmlspecialchars($_SESSION['avatar'] ?? 'img/avatars/defaultPro
|
||||
|
||||
<body>
|
||||
|
||||
<?php include_once 'cabecera.php'; ?>
|
||||
<div id="cabecera"></div>
|
||||
|
||||
<div class="perfil-container">
|
||||
|
||||
@@ -62,14 +48,14 @@ $avatarUsuario = htmlspecialchars($_SESSION['avatar'] ?? 'img/avatars/defaultPro
|
||||
|
||||
<!-- Nombre -->
|
||||
<h1 id="nombre" class="nombre">
|
||||
<?= $nombreUsuario ?>
|
||||
|
||||
</h1>
|
||||
|
||||
<!-- FOTO DE PERFIL -->
|
||||
<div class="foto-container">
|
||||
|
||||
<img id="fotoPerfil"
|
||||
src="<?= $avatarUsuario ?>"
|
||||
src="img/avatars/defaultProfile.jpeg"
|
||||
alt="Foto de perfil"
|
||||
class="avatar rounded-circle">
|
||||
|
||||
@@ -309,6 +295,7 @@ $avatarUsuario = htmlspecialchars($_SESSION['avatar'] ?? 'img/avatars/defaultPro
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Tu JavaScript -->
|
||||
<script>$("#cabecera").load("cabecera.php");</script>
|
||||
<script src="js/perfil.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
+8
-13
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once __DIR__ . '/includes/conexionBD.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/conexionBD.php';
|
||||
|
||||
$idPartida = intval($_GET['idPartida'] ?? 0);
|
||||
if ($idPartida <= 0) {
|
||||
@@ -29,7 +29,7 @@ $primerosEnAcertar = $_SESSION['primeros_en_acertar'][$idPartida] ?? [];
|
||||
$jugadoresFinales = [];
|
||||
$equiposFinales = [];
|
||||
|
||||
// Respuestas de velocidad (+2 o +1) procesadas en la capa de la vista
|
||||
// Respuestas de velocidad (+2 o +1)
|
||||
foreach ($listaJugadoresRaw as $jugador) {
|
||||
$idU = (int)$jugador['idUsuario'];
|
||||
$idE = (int)$jugador['idEquipo'];
|
||||
@@ -52,6 +52,7 @@ foreach ($listaJugadoresRaw as $jugador) {
|
||||
$aciertos++;
|
||||
$idPxp = $resp['idPartidaxPregunta'];
|
||||
|
||||
// Si el ID de usuario coincide con el primero guardado de esa pregunta se lleva 2 puntos
|
||||
if (isset($primerosEnAcertar[$idPxp]) && $primerosEnAcertar[$idPxp] === $idU) {
|
||||
$puntosTotalesJugador += 2;
|
||||
} else {
|
||||
@@ -76,6 +77,7 @@ foreach ($listaJugadoresRaw as $jugador) {
|
||||
$equiposFinales[$idE]['puntos'] += $puntosTotalesJugador;
|
||||
}
|
||||
|
||||
// Ordenar según la puntuación final de mayor a menor
|
||||
usort($jugadoresFinales, function($a, $b) { return $b['puntos'] <=> $a['puntos']; });
|
||||
usort($equiposFinales, function($a, $b) { return $b['puntos'] <=> $a['puntos']; });
|
||||
?>
|
||||
@@ -86,24 +88,19 @@ usort($equiposFinales, function($a, $b) { return $b['puntos'] <=> $a['puntos'];
|
||||
<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>
|
||||
<script src="https://jquery.com"></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>
|
||||
<h2>⌛ 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>
|
||||
<h1>🏆 Resultados de la Partida 🏆</h1>
|
||||
|
||||
<h2>Clasificación por Equipos</h2>
|
||||
<table class="tabla-ranking">
|
||||
@@ -149,11 +146,9 @@ usort($equiposFinales, function($a, $b) { return $b['puntos'] <=> $a['puntos'];
|
||||
</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>
|
||||
<a href="/triviagmatico/buscadorSala.php" class="btn-inicio">Volver al Inicio 🏠</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="js/resultados.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user