28 Commits

Author SHA1 Message Date
margarita 5bf5b7a3bc triviagmatico 30/09/26 a 13:30 2026-10-01 12:07:47 +02:00
jorge e8accf949e revert 7f70112f63
revert Merge pull request 'Fix inicia partida todos los usuarios' (#21) from partida into main

Reviewed-on: #21
2026-10-01 11:16:36 +02:00
jorge fa883cde39 revert eed77db62f
revert Subir archivos a "controladores"
2026-10-01 11:16:20 +02:00
jorge ae213a3d12 revert a66ac7086d
revert Subir archivos a "js"
2026-10-01 11:16:14 +02:00
jorge cd0685f41c revert 71fb45b94c
revert Merge branch 'main' of https://git.desarrolloalcala.com/jorge/triviagmatico
2026-10-01 11:15:10 +02:00
jorge e3395a017c revert 8d5d7da615
revert Merge pull request 'Resultados victor' (#25) from resultados_victor into main

Reviewed-on: #25
2026-10-01 11:13:07 +02:00
jorge 396aca8b03 revert c6db380ef9
revert Merge branch 'main' of https://git.desarrolloalcala.com/jorge/triviagmatico
2026-10-01 11:12:58 +02:00
jorge c6db380ef9 Merge branch 'main' of https://git.desarrolloalcala.com/jorge/triviagmatico 2026-10-01 10:53:03 +02:00
jorge 8d5d7da615 Merge pull request 'Resultados victor' (#25) from resultados_victor into main
Reviewed-on: #25
2026-10-01 10:52:42 +02:00
jorge 7f70112f63 Merge pull request 'Fix inicia partida todos los usuarios' (#21) from partida into main
Reviewed-on: #21
2026-10-01 10:49:10 +02:00
dbvictor2002 a66ac7086d Subir archivos a "js" 2026-10-01 10:47:05 +02:00
dbvictor2002 eed77db62f Subir archivos a "controladores" 2026-10-01 10:46:36 +02:00
dbvictor2002 83545152bb Subir archivos a "/" 2026-10-01 10:46:12 +02:00
jorge 71fb45b94c Merge branch 'main' of https://git.desarrolloalcala.com/jorge/triviagmatico 2026-10-01 08:58:45 +02:00
jorge 5b6352b4ee Merge pull request 'Css' (#23) from css into main
Reviewed-on: #23
2026-09-30 13:25:02 +02:00
Isaac 7e1344a395 Arreglado CSS modal crear pregunta en perfil 2026-09-30 13:15:52 +02:00
Isaac db5061ec7f Ajustes a la tabla para dejarla buena, bonita y barata 2026-09-30 13:08:04 +02:00
Isaac 737b76e83b Ajuste texto para host 2026-09-30 12:48:38 +02:00
Isaac 3705a9ea9e Ajuste CSS más acorde 2026-09-30 12:41:50 +02:00
Isaac 72134b405c Arreglado CSS botón "Unirse" 2026-09-30 12:31:50 +02:00
profesor 91056a05d9 Merge pull request 'carga jquery desde CDN, no iba' (#22) from corrigiendo_rutas into main
Reviewed-on: #22
2026-09-30 12:25:22 +02:00
profesor 18a56e0bbd Merge pull request 'MVC juego.php' (#20) from MVC_juego.php into main
Reviewed-on: #20
2026-09-30 12:13:38 +02:00
Juanjo ed7067161a MVC juego.php 2026-09-30 11:30:30 +02:00
jorge 2531ef321a cabecera mvc modificada 2026-09-30 11:08:09 +02:00
jorge d3e523ad73 Merge pull request 'Preguntas y respuestas duplicadas eliminadas' (#19) from preguntas_victor into main
Reviewed-on: #19
2026-09-30 11:06:25 +02:00
v.rodriguezcamacho 77249ba51b Preguntas y respuestas duplicadas eliminadas 2026-09-30 11:00:21 +02:00
dbvictor2002 5446352cf9 Fix inicia partida todos los usuarios 2026-09-30 10:21:43 +02:00
profesor 95f7d8dad6 carga jquery desde CDN, no iba 2026-09-30 09:57:00 +02:00
14 changed files with 188 additions and 995 deletions
+1 -1
View File
@@ -71,7 +71,7 @@
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancelar</button> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancelar</button>
<button type="button" class="btn btn-kahoot-login" id="btnCrearSala">Crear sala</button> <button type="button" class="btn btn-kahoot-register" id="btnCrearSala">Crear sala</button>
</div> </div>
</div> </div>
</div> </div>
+82 -38
View File
@@ -1,79 +1,118 @@
<?php <?php
session_start(); session_start();
require_once '../clases/claseJuego.php'; require_once '../clases/claseJuego.php';
header('Content-Type: application/json; charset=utf-8'); header('Content-Type: application/json; charset=utf-8');
// Hay que estar logueado y decir de qué partida se trata // Comprobamos que haya un usuario conectado
if (!isset($_SESSION['idUsuario'])) { 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; exit;
} }
$idUsuario = (int)$_SESSION['idUsuario']; $idUsuario = (int) $_SESSION['idUsuario'];
$idPartida = intval($_POST['idPartida'] ?? 0);
// 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']);
if ($idPartida <= 0) { if ($idPartida <= 0) {
echo json_encode(['error' => 'No se ha indicado la partida.']); echo json_encode([
'error' => 'La partida indicada no es válida.'
]);
exit; exit;
} }
// Solo pueden jugar los usuarios que están en uno de los equipos de la partida // Comprobamos que el usuario pertenezca a la partida
$perteneceAPartida = Juego::usuarioEnPartida($idPartida, $idUsuario);
$perteneceAPartida = Juego::usuarioEnPartida($idPartida,$idUsuario);
if (is_array($perteneceAPartida)) { if (is_array($perteneceAPartida)) {
echo json_encode($perteneceAPartida); echo json_encode($perteneceAPartida);
exit; exit;
} }
if (!$perteneceAPartida) { if (!$perteneceAPartida) {
echo json_encode(['error' => 'No formas parte de esta partida.']); echo json_encode([
'error' => 'No formas parte de esta partida.'
]);
exit; exit;
} }
// Comprobamos la orden
switch ($_POST['orden'] ?? '') { $orden = $_POST['orden'] ?? '';
switch ($orden) {
// CARGAR LAS PREGUNTAS DE LA PARTIDA
// Devuelve las 10 preguntas con sus respuestas (sin marcar la correcta)
case 'cargarPreguntas': case 'cargarPreguntas':
echo json_encode(Juego::cargarPreguntas($idPartida, $idUsuario)); $resultado = Juego::cargarPreguntas($idPartida, $idUsuario);
echo json_encode($resultado);
break; break;
// REGISTRAR RESPUESTA
// Guarda la respuesta del usuario y dice si ha acertado
case 'responder': case 'responder':
$idPartidaxPregunta = intval($_POST['idPartidaxPregunta'] ?? 0); if (!isset($_POST['idPartidaxPregunta']) || !isset($_POST['idRespuesta'])){
$idRespuesta = intval($_POST['idRespuesta'] ?? 0); echo json_encode([
'error' => 'Faltan datos para registrar la respuesta.'
if ($idPartidaxPregunta <= 0 || $idRespuesta <= 0) { ]);
echo json_encode(['error' => 'Faltan datos para registrar la respuesta.']);
break;
}
echo json_encode(
Juego::registrarRespuesta(
$idPartida,
$idUsuario,
$idPartidaxPregunta,
$idRespuesta
)
);
break; break;
}
$idPartidaxPregunta = intval($_POST['idPartidaxPregunta']);
$idRespuesta = intval($_POST['idRespuesta']);
if ($idPartidaxPregunta <= 0 || $idRespuesta <= 0){
echo json_encode([
'error' => 'Los datos de la respuesta no son válidos.'
]);
break;
}
// Registramos la respuesta del usuario
$resultado = Juego::registrarRespuesta($idPartida, $idUsuario, $idPartidaxPregunta, $idRespuesta);
echo json_encode($resultado);
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': case 'finalizarPartida':
$aciertos = intval($_POST['aciertos'] ?? 0); $aciertos = intval($_POST['aciertos'] ?? 0);
// Guardamos los aciertos en la sesión
if (!isset($_SESSION['aciertosPorPartida'])) { if (!isset($_SESSION['aciertosPorPartida'])) {
$_SESSION['aciertosPorPartida'] = []; $_SESSION['aciertosPorPartida'] = [];
} }
@@ -81,16 +120,21 @@ switch ($_POST['orden'] ?? '') {
echo json_encode([ echo json_encode([
'exito' => 'Aciertos registrados correctamente.', 'exito' => 'Aciertos registrados correctamente.',
'idPartida' => $idPartida, 'idPartida' => $idPartida,
'aciertos' => $aciertos 'aciertos' => $aciertos
]); ]);
break; break;
default: default:
echo json_encode(['error' => 'La orden indicada no existe.']); echo json_encode([
'error' => 'La orden indicada no existe.'
]);
break; break;
} }
?>
-14
View File
@@ -1,14 +0,0 @@
<?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');
?>
+2 -1
View File
@@ -77,8 +77,9 @@
} }
.btn-unirse:hover { .btn-unirse:hover {
background-color: #0f56ab; background-color: #1f6f09;
color: white; color: white;
transform: translateY(-2px);
} }
.modal-kahoot { .modal-kahoot {
+15
View File
@@ -401,3 +401,18 @@
} }
} }
.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;
}
+1 -1
View File
@@ -276,7 +276,7 @@ $(document).on("click", ".btn-abandonar-sala", function () {
mensaje.text( mensaje.text(
"Si abandonas la sala como anfitrión, la partida terminará para todos los jugadores.", "Si abandonas la sala como anfitrión, la partida terminará para todos los jugadores.",
); );
botonConfirmar.text("Sí, abandonar"); botonConfirmar.text("Sí, terminar partida");
} else { } else {
titulo.text("¿Abandonar la sala?"); titulo.text("¿Abandonar la sala?");
mensaje.text( mensaje.text(
+3 -2
View File
@@ -43,7 +43,7 @@ function comprobarSesion() {
</button> </button>
<ul class="dropdown-menu dropdown-menu-end user-dropdown-menu" aria-labelledby="userDropdown"> <ul class="dropdown-menu dropdown-menu-end user-dropdown-menu" aria-labelledby="userDropdown">
<li> <li>
<a class="dropdown-item d-flex align-items-center gap-2" href="perfil.html"> <a class="dropdown-item d-flex align-items-center gap-2" href="perfil.php">
<i class="fa-solid fa-user text-primary"></i> Perfil <i class="fa-solid fa-user text-primary"></i> Perfil
</a> </a>
</li> </li>
@@ -202,4 +202,5 @@ $(document).on("click", "#botonCerrarSesion", function (event) {
window.location.href = "index.php"; window.location.href = "index.php";
} }
}); });
}); });
+5 -5
View File
@@ -36,11 +36,11 @@ function renderizarTablaRanking(jugadores) {
<thead class="table-dark"> <thead class="table-dark">
<tr> <tr>
<th scope="col" style="width: 10%;">#</th> <th scope="col" style="width: 10%;">#</th>
<th scope="col" class="text-start" style="width: 35%;">Jugador</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> Vic</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> Der</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> Aciertos</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: 10%;"><i class="fa-solid fa-percent text-info me-1"></i> % Vic</th> <th scope="col" style="width: 15%;"><i class="fa-solid fa-medal text-info me-1"></i> <br> Efectividad</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
+14 -2
View File
@@ -20,7 +20,18 @@ let bloqueado = false; // true mientras se envía una respuesta o se ve el feedb
let numeroAciertos = 0; // número de aciertos del jugador let numeroAciertos = 0; // número de aciertos del jugador
$(document).ready(function () { $(document).ready(function () {
idPartida = parseInt($("body").data("id-partida"), 10);
// 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;
}
// Un solo listener para todos los botones de respuesta // Un solo listener para todos los botones de respuesta
$("#respuestas").on("click", ".btn-answer", function () { $("#respuestas").on("click", ".btn-answer", function () {
@@ -103,6 +114,7 @@ function responder($botonPulsado) {
if (bloqueado) { if (bloqueado) {
return; return;
} }
bloqueado = true; bloqueado = true;
const pregunta = preguntas[indice]; const pregunta = preguntas[indice];
@@ -216,4 +228,4 @@ function mostrarError(mensaje) {
$("#feedback").html( $("#feedback").html(
'<a href="buscadorSala.php">Volver al buscador de salas</a>', '<a href="buscadorSala.php">Volver al buscador de salas</a>',
); );
} }
+4 -27
View File
@@ -1,26 +1,3 @@
// 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 // MOSTRAR ESTADISTICAS
// ========================= // =========================
@@ -73,8 +50,8 @@ function cambiarNombre() {
$("#nuevoNombre").val(""); $("#nuevoNombre").val("");
if (typeof comprobarSesion === "function") { if (typeof comprobarEstadoSesion === "function") {
comprobarSesion(); comprobarEstadoSesion();
} }
} }
}); });
@@ -133,8 +110,8 @@ $("#inputFoto").change(function () {
); );
// Actualizamos también el avatar superior en la cabecera // Actualizamos también el avatar superior en la cabecera
if (typeof comprobarSesion === "function") { if (typeof comprobarEstadoSesion === "function") {
comprobarSesion(); comprobarEstadoSesion();
} }
} }
}); });
+27 -23
View File
@@ -1,22 +1,6 @@
<?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> <!DOCTYPE html>
<html lang="es"> <html lang="es">
<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">
@@ -24,28 +8,48 @@ if (!$idPartida || $idPartida < 1) {
<title>Proyecto Trivial</title> <title>Proyecto Trivial</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">
</head> </head>
<body data-id-partida="<?= (int)$idPartida ?>">
<!-- Progreso: "Pregunta 3 de 10" + barra --> <body>
<!-- CABECERA Y PROGRESO -->
<div class="game-header"> <div class="game-header">
<span id="contadorPregunta">Cargando…</span>
<span id="contadorPregunta">
Cargando…
</span>
</div> </div>
<div class="progress-track"> <div class="progress-track">
<div class="progress-fill" id="barraProgreso"></div> <div class="progress-fill" id="barraProgreso"></div>
</div> </div>
<!-- Contenedor de la Pregunta (lo rellena js/juego.js) --> <!-- PREGUNTA -->
<div class="question-container"> <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 id="feedback" class="feedback" aria-live="polite"></div>
</div> </div>
<!-- Contenedor de Respuestas (Estilo Kahoot, lo rellena js/juego.js) --> <!-- RESPUESTAS -->
<div class="answers-grid" id="respuestas"></div> <div class="answers-grid" id="respuestas"></div>
<!-- JAVASCRIPT -->
<script src="js/jquery-4.0.0.min.js"></script> <script src="js/jquery-4.0.0.min.js"></script>
<script src="js/juego.js"></script> <script src="js/juego.js"></script>
</body> </body>
</html> </html>
File diff suppressed because it is too large Load Diff
+17 -4
View File
@@ -1,3 +1,17 @@
<?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">
@@ -27,7 +41,7 @@
<body> <body>
<div id="cabecera"></div> <?php include_once 'cabecera.php'; ?>
<div class="perfil-container"> <div class="perfil-container">
@@ -48,14 +62,14 @@
<!-- Nombre --> <!-- Nombre -->
<h1 id="nombre" class="nombre"> <h1 id="nombre" class="nombre">
<?= $nombreUsuario ?>
</h1> </h1>
<!-- FOTO DE PERFIL --> <!-- FOTO DE PERFIL -->
<div class="foto-container"> <div class="foto-container">
<img id="fotoPerfil" <img id="fotoPerfil"
src="img/avatars/defaultProfile.jpeg" src="<?= $avatarUsuario ?>"
alt="Foto de perfil" alt="Foto de perfil"
class="avatar rounded-circle"> class="avatar rounded-circle">
@@ -295,7 +309,6 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Tu JavaScript --> <!-- Tu JavaScript -->
<script>$("#cabecera").load("cabecera.php");</script>
<script src="js/perfil.js"></script> <script src="js/perfil.js"></script>
</body> </body>
+1 -1
View File
@@ -89,7 +89,7 @@ usort($equiposFinales, function($a, $b) { return $b['puntos'] <=> $a['puntos'];
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Resultados - Trivial</title> <title>Resultados - Trivial</title>
<link rel="stylesheet" href="css/resultados.css"> <link rel="stylesheet" href="css/resultados.css">
<script src="https://jquery.com"></script> <script src="https://cdn.jsdelivr.net/npm/jquery@4.0.0/dist/jquery.min.js"></script>
</head> </head>
<body data-id-partida="<?php echo $idPartida; ?>"> <body data-id-partida="<?php echo $idPartida; ?>">