Compare commits
86 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 02c109662d | |||
| 22f38f924f | |||
| 01aa2643f6 | |||
| 07c1f79474 | |||
| 54b6b0d67b | |||
| 57e3dfc444 | |||
| 8c7958ad96 | |||
| bf2361ad43 | |||
| 03715d621e | |||
| 6da20872c6 | |||
| 26a46c29e8 | |||
| 9a5575fe25 | |||
| 0518cecd1e | |||
| d6e1cd8c2d | |||
| 4e345fa01d | |||
| 413d9552f2 | |||
| 6beb655e83 | |||
| 7292b932dd | |||
| 36fb2d96fc | |||
| 9c67d76265 | |||
| 8d6272c664 | |||
| 3a888fc6eb | |||
| 859f86aeb1 | |||
| 67224911dc | |||
| 9657374edd | |||
| f729a54bc2 | |||
| 6b7e54f1ee | |||
| 4ee0f619cf | |||
| 72dc4dec8f | |||
| 18ba294dc7 | |||
| ca5a5558b4 | |||
| e081b831b4 | |||
| ab26f5fa9a | |||
| 5c1fa24ebf | |||
| 35611746a6 | |||
| 956798b634 | |||
| 9515a1e923 | |||
| 3ed1a747f7 | |||
| c95bc19155 | |||
| b96a18b88b | |||
| c8f2f86364 | |||
| 5eccd108ef | |||
| 6a72c7cafe | |||
| 8c5684aedc | |||
| 8646f18782 | |||
| 9fc1f6be24 | |||
| 0caa264961 | |||
| 3d5aff18f4 | |||
| 17f3058ec7 | |||
| 08131b46e4 | |||
| c52fab2d6c | |||
| 22f86c2d6d | |||
| cb3b00fba3 | |||
| 9df7bd9d45 | |||
| fdd0712cd5 | |||
| 52a97dfd01 | |||
| 63e9c3ceab | |||
| 87fdf7285f | |||
| 9bcb06a651 | |||
| b9dea2a3ca | |||
| cab040aaa1 | |||
| a3cd770956 | |||
| db6e1304bf | |||
| b2f8a6c8d5 | |||
| 38a091a2fd | |||
| 3348188d44 | |||
| e102298961 | |||
| d1c381d7ac | |||
| ee781cb1e7 | |||
| f784c7bfff | |||
| 29a11a8514 | |||
| c603a3c0ba | |||
| afbf66c073 | |||
| 9e722b1af7 | |||
| 7190f3971f | |||
| 747a9dd06b | |||
| 4def004bd6 | |||
| cf8a14c51a | |||
| 835b8e332b | |||
| 66acfb27d0 | |||
| 4cb4faff1b | |||
| d65b7fcb91 | |||
| a6a78d9381 | |||
| 050d5e49c4 | |||
| 2cc13ce4ed | |||
| 8caaeeaef0 |
@@ -52,4 +52,27 @@ Equipos de Backend y Frontend.
|
||||
|
||||
# Notas sueltas
|
||||
|
||||
|
||||
## Publicación en el servidor
|
||||
|
||||
Configuración de acceso al servidor de producción:
|
||||
|
||||
- SSH/SCP/SFTP:
|
||||
- Host: desarrolloalcala.com
|
||||
- Puerto: 2222
|
||||
- Usuario: alumnado
|
||||
- Contraseña: epdsrntr\*\*
|
||||
- Acceso WEB al panel de control:
|
||||
- URL: http://desarrolloalcala.com
|
||||
- Usuario: alumnado
|
||||
- Contraseña: epdsrntr\*\*
|
||||
- Acceso a PHPMyAdmin
|
||||
- http://desarrolloalcala.com/phpmyadmin
|
||||
- usuario: alumnado
|
||||
- contraseña: epdsrntr\*\*
|
||||
|
||||
Here are information to log into the database:
|
||||
|
||||
- Type: mysql
|
||||
- Database user: my_webapp
|
||||
- Database name: my_webapp
|
||||
- Password: 07tCqBO3B6Q3cncKMF2FHcpgsLjFTx
|
||||
@@ -0,0 +1,105 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Trivial - Lobby</title>
|
||||
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/index.css">
|
||||
<link rel="stylesheet" href="css/buscadorSala.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php include_once("cabecera.php"); ?>
|
||||
|
||||
<main class="container py-4">
|
||||
|
||||
<!-- Botón Volver -->
|
||||
<div class="mb-4">
|
||||
<a href="index.php" class="btn btn-outline-secondary d-inline-flex align-items-center gap-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/>
|
||||
</svg>
|
||||
Volver al Inicio
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Botón Crear Sala -->
|
||||
<div id="contenedorCrearSala" class="text-center mb-5">
|
||||
<button type="button" class="btn btn-play-kahoot btn-crear-sala" data-bs-toggle="modal" data-bs-target="#modalCrearSala">
|
||||
<span>+</span> Crear sala
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Contenedor Principal de Salas -->
|
||||
<div id="contenedorSalas" class="row justify-content-center g-4">
|
||||
<div id="cargandoSalas" class="col-12 text-center">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="visually-hidden">Cargando...</span>
|
||||
</div>
|
||||
<p class="mt-3 text-muted">Cargando salas...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<!-- Modal Crear Sala -->
|
||||
<div class="modal fade" id="modalCrearSala" tabindex="-1" aria-labelledby="modalCrearSalaLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content modal-kahoot">
|
||||
<div class="modal-header modal-kahoot-header">
|
||||
<h5 class="modal-title" id="modalCrearSalaLabel">Crear sala</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Cerrar"></button>
|
||||
</div>
|
||||
<div class="modal-body p-4">
|
||||
<div class="mb-3">
|
||||
<label for="nombreSala" class="form-label">Nombre de la sala</label>
|
||||
<input type="text" id="nombreSala" class="form-control input-kahoot" name="nombreSala" placeholder="Ej. Noche de Trivial" maxlength="100">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="nombreEquipo1" class="form-label">Nombre del equipo 1</label>
|
||||
<input type="text" id="nombreEquipo1" name="nombreEquipo1" class="form-control input-kahoot" placeholder="Ej. Los cerebritos" maxlength="50">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="nombreEquipo2" class="form-label">Nombre del equipo 2</label>
|
||||
<input type="text" id="nombreEquipo2" name="nombreEquipo2" class="form-control input-kahoot" placeholder="Ej. Los campeones" maxlength="50">
|
||||
</div>
|
||||
</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-login" id="btnCrearSala">Crear sala</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--MODAL ABANDONAR SALA -->
|
||||
<!-- Modal Confirmar Abandonar Sala -->
|
||||
<div class="modal fade" id="modalAbandonarSala" tabindex="-1" aria-labelledby="modalAbandonarSalaLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content modal-kahoot text-center p-3">
|
||||
<div class="modal-body">
|
||||
<div class="mb-3 fs-1">⚠️</div>
|
||||
<h4 class="modal-title mb-2 fw-bold text-white" id="modalAbandonarSalaLabel">¿Abandonar la sala?</h4>
|
||||
<p class="text-white-50">Si sales de la sala, perderás tu lugar en el equipo.</p>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-center border-0 gap-2">
|
||||
<button type="button" class="btn btn-secondary px-4 py-2" data-bs-dismiss="modal">
|
||||
Cancelar
|
||||
</button>
|
||||
<button type="button" id="btnConfirmarAbandonar" class="btn btn-danger px-4 py-2">
|
||||
Sí, salir
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="js/jquery-4.0.0.min.js"></script>
|
||||
<script src="js/buscadorSala.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- FontAwesome para iconos -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
|
||||
<!-- Google Fonts para estilo Kahoot -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/index.css">
|
||||
<script src="js/jquery-4.0.0.min.js"></script>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-kahoot py-3 mb-4">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="index.php">
|
||||
<img src="img/favicon/favicon.svg" alt="TRIVIAGMÁTICO" class="me-2" style="height: 35px;">
|
||||
TRIVIAGMÁTICO
|
||||
</a>
|
||||
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarContent">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0"></ul>
|
||||
|
||||
<!-- Contenedor dinámico de usuario/botones -->
|
||||
<div class="d-flex align-items-center gap-3" id="contenedorUsuarioCabecera">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- MODAL DE LOGIN -->
|
||||
<div class="modal fade" id="modalLogin" tabindex="-1" aria-labelledby="loginModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content border-dark">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5 fw-bold" id="loginModalLabel">
|
||||
<i class="fa-solid fa-right-to-bracket text-primary me-2"></i>Iniciar sesión
|
||||
</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cerrar"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="formLogin">
|
||||
<div class="form-floating mb-3">
|
||||
<input type="email" class="form-control border-dark" id="loginEmail" name="email" placeholder="Correo electrónico" required>
|
||||
<label for="loginEmail">Correo electrónico</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input type="password" class="form-control border-dark" id="loginPassword" name="contrasena" placeholder="Contraseña" required>
|
||||
<label for="loginPassword">Contraseña</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" id="recordar" name="recordar" type="checkbox" />
|
||||
<label for="recordar" class="small">Recuérdeme durante 10 días</label>
|
||||
</div>
|
||||
<input type="hidden" name="orden" value="validar">
|
||||
</form>
|
||||
<div id="errorLogin" class="text-danger fw-bold mt-2"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary rounded-pill px-3" data-bs-dismiss="modal">Cancelar</button>
|
||||
<button type="button" class="btn btn-primary rounded-pill px-4" id="botonAceptarLogin">Entrar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MODAL DE REGISTRO -->
|
||||
<div class="modal fade" id="modalRegistro" tabindex="-1" aria-labelledby="registroModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content border-dark">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5 fw-bold" id="registroModalLabel">
|
||||
<i class="fa-solid fa-user-plus text-success me-2"></i>Registrarse
|
||||
</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cerrar"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="formRegistro">
|
||||
<div class="form-floating mb-3">
|
||||
<input type="text" class="form-control border-dark" id="regNombre" name="nombreUsuario" placeholder="Nombre" required>
|
||||
<label for="regNombre">Nombre</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input type="email" class="form-control border-dark" id="regEmail" name="email" placeholder="Correo electrónico" required>
|
||||
<label for="regEmail">Correo electrónico</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input type="password" class="form-control border-dark" id="regPassword" name="contrasena" placeholder="Contraseña" required>
|
||||
<label for="regPassword">Contraseña</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input type="password" class="form-control border-dark" id="regPasswordConfirm" name="contrasenaConfirm" placeholder="Confirmar contraseña" required>
|
||||
<label for="regPasswordConfirm">Confirmar contraseña</label>
|
||||
</div>
|
||||
<input type="hidden" name="orden" value="registrar">
|
||||
</form>
|
||||
<div id="errorRegistro" class="text-danger fw-bold mt-2"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary rounded-pill px-3" data-bs-dismiss="modal">Cancelar</button>
|
||||
<button type="button" class="btn btn-success rounded-pill px-4" id="botonAceptarRegistro">Registrarse</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="js/cabecera.js"></script>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
require_once '../includes/conexionBD.php';
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/triviagmatico/includes/conexionBD.php';
|
||||
|
||||
|
||||
class Categoria{
|
||||
|
||||
@@ -35,7 +36,7 @@ class Categoria{
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al guardar la categoría.',
|
||||
'error_tecnico' => $error
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
|
||||
$conexion = null;
|
||||
@@ -64,7 +65,7 @@ class Categoria{
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al obtener el listado de categorías.',
|
||||
'error_tecnico' => $error
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
|
||||
$conexion = null;
|
||||
@@ -94,7 +95,7 @@ class Categoria{
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al buscar la categoría.',
|
||||
'error_tecnico' => $error
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
|
||||
$conexion = null;
|
||||
@@ -134,7 +135,7 @@ class Categoria{
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al eliminar la categoría.',
|
||||
'error_tecnico' => $error
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
|
||||
$conexion = null;
|
||||
@@ -1,41 +1,49 @@
|
||||
<?php
|
||||
require_once '../includes/conexionBD.php';
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
|
||||
class Equipo{
|
||||
|
||||
class Equipo
|
||||
{
|
||||
|
||||
public $idEquipo;
|
||||
public $nombreEquipo;
|
||||
|
||||
function __construct($idEquipo=null, $nombreEquipo=null){
|
||||
function __construct($idEquipo = null, $nombreEquipo = null)
|
||||
{
|
||||
$this->idEquipo = $idEquipo;
|
||||
$this->nombreEquipo = $nombreEquipo;
|
||||
}
|
||||
|
||||
|
||||
function crear(){
|
||||
function crear()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if(is_array($conexion)){
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
$consulta = $conexion->prepare("INSERT INTO equipo (nombreEquipo) VALUES (:nombreEquipo)");
|
||||
} else {
|
||||
try {
|
||||
$consulta = $conexion->prepare(
|
||||
"INSERT INTO equipo (nombreEquipo) VALUES (:nombreEquipo)"
|
||||
);
|
||||
|
||||
$consulta->bindParam(':nombreEquipo', $this->nombreEquipo);
|
||||
|
||||
$consulta->execute();
|
||||
|
||||
// Guardamos el ID generado por la BD
|
||||
$this->idEquipo = (int)$conexion->lastInsertId();
|
||||
|
||||
$respuesta = [
|
||||
'exito' => 'Equipo creado correctamente',
|
||||
'exito_tecnico' => $this->nombreEquipo
|
||||
'exito_tecnico' => $this->idEquipo
|
||||
];
|
||||
|
||||
return $respuesta;
|
||||
|
||||
}catch(PDOException $error){
|
||||
} catch (PDOException $error) {
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al guardar el equipo.',
|
||||
'error_tecnico' => $error
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
|
||||
$conexion = null;
|
||||
@@ -45,13 +53,15 @@ class Equipo{
|
||||
}
|
||||
|
||||
|
||||
function listar(){
|
||||
|
||||
function listar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if(is_array($conexion)){
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
} else {
|
||||
try {
|
||||
$sql = 'SELECT * FROM equipo';
|
||||
|
||||
$consulta = $conexion->prepare($sql);
|
||||
@@ -60,11 +70,10 @@ class Equipo{
|
||||
$resultado = $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $resultado;
|
||||
|
||||
}catch(PDOException $error){
|
||||
} catch (PDOException $error) {
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al obtener el listado de equipos.',
|
||||
'error_tecnico' => $error
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
|
||||
$conexion = null;
|
||||
@@ -74,13 +83,14 @@ class Equipo{
|
||||
}
|
||||
|
||||
|
||||
function buscar(){
|
||||
function buscar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if(is_array($conexion)){
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
} else {
|
||||
try {
|
||||
$consulta = $conexion->prepare("SELECT * FROM equipo WHERE idEquipo = :idEquipo");
|
||||
|
||||
$consulta->bindParam(':idEquipo', $this->idEquipo);
|
||||
@@ -90,11 +100,10 @@ class Equipo{
|
||||
$resultado = $consulta->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
return $resultado;
|
||||
|
||||
}catch(PDOException $error){
|
||||
} catch (PDOException $error) {
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al buscar el equipo.',
|
||||
'error_tecnico' => $error
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
|
||||
$conexion = null;
|
||||
@@ -104,25 +113,26 @@ class Equipo{
|
||||
}
|
||||
|
||||
|
||||
function borrar(){
|
||||
function borrar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if(is_array($conexion)){
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
} else {
|
||||
try {
|
||||
$consulta = $conexion->prepare("DELETE FROM equipo WHERE idEquipo = :idEquipo");
|
||||
|
||||
$consulta->bindParam(':idEquipo', $this->idEquipo);
|
||||
|
||||
$consulta->execute();
|
||||
|
||||
if($consulta->rowCount() > 0){
|
||||
if ($consulta->rowCount() > 0) {
|
||||
$respuesta = [
|
||||
'exito' => 'Se eliminó correctamente el equipo',
|
||||
'exito_tecnico' => $this->idEquipo
|
||||
];
|
||||
}else{
|
||||
} else {
|
||||
$respuesta = [
|
||||
'error' => 'No existe ningún equipo con ese ID.',
|
||||
'error_tecnico' => $this->idEquipo
|
||||
@@ -130,8 +140,7 @@ class Equipo{
|
||||
}
|
||||
|
||||
return $respuesta;
|
||||
|
||||
}catch(PDOException $error){
|
||||
} catch (PDOException $error) {
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al eliminar el equipo.',
|
||||
'error_tecnico' => $error
|
||||
@@ -142,7 +151,4 @@ class Equipo{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
|
||||
class EquipoxPartida
|
||||
{
|
||||
public $idEquipoxPartida;
|
||||
public $idEquipo;
|
||||
public $idPartida;
|
||||
|
||||
public function __construct(
|
||||
$idEquipoxPartida = null,
|
||||
$idEquipo = null,
|
||||
$idPartida = null
|
||||
) {
|
||||
$this->idEquipoxPartida = $idEquipoxPartida;
|
||||
$this->idEquipo = $idEquipo;
|
||||
$this->idPartida = $idPartida;
|
||||
}
|
||||
|
||||
public function insertar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$sql = "
|
||||
INSERT INTO equipoxpartida
|
||||
(idEquipo, idPartida)
|
||||
VALUES
|
||||
(:idEquipo, :idPartida)
|
||||
";
|
||||
|
||||
$consulta = $conexion->prepare($sql);
|
||||
|
||||
$consulta->bindParam(':idEquipo', $this->idEquipo);
|
||||
$consulta->bindParam(':idPartida', $this->idPartida);
|
||||
|
||||
$consulta->execute();
|
||||
|
||||
$this->idEquipoxPartida = (int)$conexion->lastInsertId();
|
||||
|
||||
return [
|
||||
'exito' => 'Equipo vinculado a la partida correctamente.',
|
||||
'exito_tecnico' => $this->idEquipoxPartida
|
||||
];
|
||||
|
||||
} catch (PDOException $error) {
|
||||
|
||||
return [
|
||||
'error' => 'Ocurrió un error al vincular el equipo con la partida.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
|
||||
|
||||
class EquipoxUsuario
|
||||
{
|
||||
public $idEquipoxUsuario;
|
||||
public $idUsuario;
|
||||
public $idEquipo;
|
||||
|
||||
public function __construct($idEquipoxUsuario = null, $idUsuario = null, $idEquipo = null)
|
||||
{
|
||||
$this->idEquipoxUsuario = $idEquipoxUsuario;
|
||||
$this->idUsuario = $idUsuario;
|
||||
$this->idEquipo = $idEquipo;
|
||||
}
|
||||
|
||||
public function registrarUsuarioEnEquipo()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) return $conexion;
|
||||
|
||||
try {
|
||||
$sql = "INSERT INTO equipoxusuario (idUsuario, idEquipo) VALUES (:idUsuario, :idEquipo)";
|
||||
$consulta = $conexion->prepare($sql);
|
||||
$consulta->bindParam(':idUsuario', $this->idUsuario);
|
||||
$consulta->bindParam(':idEquipo', $this->idEquipo);
|
||||
$consulta->execute();
|
||||
|
||||
return [
|
||||
'exito' => 'Usuario vinculado al equipo correctamente.',
|
||||
'exito_tecnico' => $conexion->lastInsertId()
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al unir al usuario con el equipo.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public static function listarUsuariosPorEquipo($idEquipo)
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) return $conexion;
|
||||
|
||||
try {
|
||||
$sql = "SELECT u.* FROM equipoxusuario exu
|
||||
INNER JOIN usuario u ON exu.idUsuario = u.idUsuario
|
||||
WHERE exu.idEquipo = :idEquipo";
|
||||
$consulta = $conexion->prepare($sql);
|
||||
$consulta->bindParam(':idEquipo', $idEquipo);
|
||||
$consulta->execute();
|
||||
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al obtener los miembros del equipo.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
public function obtenerSalaUsuario($idUsuario)
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
exu.idEquipo,
|
||||
exp.idPartida
|
||||
FROM equipoxusuario exu
|
||||
|
||||
INNER JOIN equipoxpartida exp
|
||||
ON exu.idEquipo = exp.idEquipo
|
||||
|
||||
WHERE exu.idUsuario = :idUsuario
|
||||
|
||||
LIMIT 1
|
||||
";
|
||||
|
||||
$consulta = $conexion->prepare($sql);
|
||||
|
||||
$consulta->bindParam(
|
||||
':idUsuario',
|
||||
$idUsuario,
|
||||
PDO::PARAM_INT
|
||||
);
|
||||
|
||||
$consulta->execute();
|
||||
|
||||
$resultado = $consulta->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$resultado) {
|
||||
|
||||
return [
|
||||
'asociado' => false
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'asociado' => true,
|
||||
'idEquipo' => $resultado['idEquipo'],
|
||||
'idPartida' => $resultado['idPartida']
|
||||
];
|
||||
|
||||
} catch (PDOException $error) {
|
||||
|
||||
return [
|
||||
'error' => 'Ocurrió un error al obtener la sala del usuario.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public static function salirDeSala($idUsuario)
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
$sql = "DELETE FROM equipoxusuario WHERE idUsuario = :idUsuario";
|
||||
$consulta = $conexion->prepare($sql);
|
||||
$consulta->bindParam(':idUsuario', $idUsuario, PDO::PARAM_INT);
|
||||
$consulta->execute();
|
||||
|
||||
return [
|
||||
'exito' => true,
|
||||
'mensaje' => 'Usuario eliminado de la sala correctamente.'
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al salir de la sala.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
|
||||
class Partida
|
||||
{
|
||||
|
||||
public $idPartida;
|
||||
public $nombrePartida;
|
||||
public $idUsuario;
|
||||
|
||||
public function __construct(
|
||||
$idPartida = null,
|
||||
$nombrePartida = null,
|
||||
$idUsuario = null
|
||||
) {
|
||||
$this->idPartida = $idPartida;
|
||||
$this->nombrePartida = $nombrePartida;
|
||||
$this->idUsuario = $idUsuario;
|
||||
}
|
||||
|
||||
public function insertar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$consulta = $conexion->prepare("
|
||||
INSERT INTO partida
|
||||
(nombrePartida,idUsuario)
|
||||
VALUES
|
||||
(:nombrePartida,:idUsuario)
|
||||
");
|
||||
$consulta->bindParam(":nombrePartida", $this->nombrePartida);
|
||||
$consulta->bindParam(":idUsuario", $this->idUsuario);
|
||||
$consulta->execute();
|
||||
return [
|
||||
"exito" => "La partida se creó correctamente.",
|
||||
"exito_tecnico" => $conexion->lastInsertId()
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al guardar la partida.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function listar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$consulta = $conexion->prepare("SELECT * FROM partida");
|
||||
$consulta->execute();
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al obtener el listado.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function buscar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$consulta = $conexion->prepare("
|
||||
SELECT *
|
||||
FROM partida
|
||||
WHERE idPartida=:idPartida
|
||||
");
|
||||
$consulta->bindParam(":idPartida", $this->idPartida);
|
||||
$consulta->execute();
|
||||
return $consulta->fetch(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al buscar la partida.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function editar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$consulta = $conexion->prepare("
|
||||
UPDATE partida
|
||||
SET
|
||||
nombrePartida=:nombrePartida,
|
||||
idUsuario=:idUsuario
|
||||
WHERE idPartida=:idPartida
|
||||
");
|
||||
$consulta->bindParam(":idPartida", $this->idPartida);
|
||||
$consulta->bindParam(":nombrePartida", $this->nombrePartida);
|
||||
$consulta->bindParam(":idUsuario", $this->idUsuario);
|
||||
$consulta->execute();
|
||||
return [
|
||||
"exito" => "La partida se editó correctamente.",
|
||||
"exito_tecnico" => $this->idPartida
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al editar la partida.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function eliminar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$consulta = $conexion->prepare("
|
||||
DELETE FROM partida
|
||||
WHERE idPartida=:idPartida
|
||||
");
|
||||
$consulta->bindParam(":idPartida", $this->idPartida);
|
||||
$consulta->execute();
|
||||
return [
|
||||
"exito" => "La partida se eliminó correctamente.",
|
||||
"exito_tecnico" => $this->idPartida
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "No se pudo eliminar la partida.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve las preguntas asignadas a la partida, junto con el
|
||||
* idPartidaxPregunta (necesario para guardar respuestas después).
|
||||
*/
|
||||
public function getPreguntas()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$consulta = $conexion->prepare("
|
||||
SELECT
|
||||
pxp.idPartidaxPregunta,
|
||||
p.*
|
||||
FROM partidaxpregunta pxp
|
||||
INNER JOIN pregunta p
|
||||
ON pxp.idPregunta=p.idPregunta
|
||||
WHERE pxp.idPartida=:idPartida
|
||||
ORDER BY pxp.idPartidaxPregunta
|
||||
");
|
||||
$consulta->bindParam(":idPartida", $this->idPartida);
|
||||
$consulta->execute();
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al recuperar las preguntas de la partida.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asocia una pregunta ya existente a esta partida.
|
||||
*/
|
||||
public function asignarPregunta($idPregunta)
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$consulta = $conexion->prepare("
|
||||
INSERT INTO partidaxpregunta
|
||||
(idPartida,idPregunta)
|
||||
VALUES
|
||||
(:idPartida,:idPregunta)
|
||||
");
|
||||
$consulta->bindParam(":idPartida", $this->idPartida);
|
||||
$consulta->bindParam(":idPregunta", $idPregunta);
|
||||
$consulta->execute();
|
||||
return [
|
||||
"exito" => "La pregunta se asignó correctamente.",
|
||||
"exito_tecnico" => $conexion->lastInsertId()
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al asignar la pregunta.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
//Cuenta cuántas preguntas tiene la partida en total. Es la primera mitad de la comprobación "¿ha terminado el usuario de jugar?".
|
||||
public function contarPreguntasAsignadas()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$consulta = $conexion->prepare("
|
||||
SELECT COUNT(*) AS total
|
||||
FROM partidaxpregunta
|
||||
WHERE idPartida=:idPartida
|
||||
");
|
||||
$consulta->bindParam(":idPartida", $this->idPartida);
|
||||
$consulta->execute();
|
||||
$fila = $consulta->fetch(PDO::FETCH_ASSOC);
|
||||
return (int)$fila["total"];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al contar las preguntas.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function contarRespuestasUsuario($idUsuario)
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$consulta = $conexion->prepare("
|
||||
SELECT COUNT(*) AS total
|
||||
FROM respuestaalmacenada ra
|
||||
INNER JOIN partidaxpregunta pxp
|
||||
ON ra.idPartidaxPregunta=pxp.idPartidaxPregunta
|
||||
WHERE pxp.idPartida=:idPartida
|
||||
AND ra.idUsuario=:idUsuario
|
||||
");
|
||||
$consulta->bindParam(":idPartida", $this->idPartida);
|
||||
$consulta->bindParam(":idUsuario", $idUsuario);
|
||||
$consulta->execute();
|
||||
$fila = $consulta->fetch(PDO::FETCH_ASSOC);
|
||||
return (int)$fila["total"];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al contar las respuestas del usuario.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sustituye al antiguo campo `terminada`: compara cuántas preguntas
|
||||
* tiene la partida contra cuántas ha respondido este usuario.
|
||||
*/
|
||||
public function estaFinalizadaParaUsuario($idUsuario)
|
||||
{
|
||||
$totalPreguntas = $this->contarPreguntasAsignadas();
|
||||
if (is_array($totalPreguntas)) {
|
||||
return $totalPreguntas;
|
||||
}
|
||||
$totalRespondidas = $this->contarRespuestasUsuario($idUsuario);
|
||||
if (is_array($totalRespondidas)) {
|
||||
return $totalRespondidas;
|
||||
}
|
||||
return $totalPreguntas > 0 && $totalPreguntas === $totalRespondidas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Partidas creadas por un usuario, de más reciente a más antigua.
|
||||
*/
|
||||
public function listarDelUsuario()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$consulta = $conexion->prepare("
|
||||
SELECT *
|
||||
FROM partida
|
||||
WHERE idUsuario=:idUsuario
|
||||
ORDER BY idPartida DESC
|
||||
");
|
||||
$consulta->bindParam(":idUsuario", $this->idUsuario);
|
||||
$consulta->execute();
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al recuperar las partidas del usuario.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function preguntaAsignada($idPregunta)
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
$consulta = $conexion->prepare("
|
||||
SELECT COUNT(*) AS total
|
||||
FROM partidaxpregunta
|
||||
WHERE idPartida=:idPartida
|
||||
AND idPregunta=:idPregunta
|
||||
");
|
||||
|
||||
$consulta->bindParam(":idPartida", $this->idPartida);
|
||||
$consulta->bindParam(":idPregunta", $idPregunta);
|
||||
$consulta->execute();
|
||||
|
||||
$fila = $consulta->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
return (int)$fila["total"] > 0;
|
||||
} catch (PDOException $error) {
|
||||
|
||||
return [
|
||||
"error" => "Ocurrió un error al comprobar la pregunta.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Vincula un equipo a esta partida en la tabla intermedia 'equipoxpartida'.
|
||||
* Permite registrar qué grupos están participando en este torneo.
|
||||
*/
|
||||
public function registrarEquipoEnPartida($idEquipo)
|
||||
{
|
||||
$conexion = conexionBD(); // Obtenemos la conexión modular del proyecto
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion; // Si hay error en la conexión, lo devuelve
|
||||
}
|
||||
|
||||
try {
|
||||
// Preparamos la consulta para insertar la relación en la tabla intermedia real
|
||||
$consulta = $conexion->prepare("
|
||||
INSERT INTO equipoxpartida
|
||||
(idPartida, idEquipo)
|
||||
VALUES
|
||||
(:idPartida, :idEquipo)
|
||||
");
|
||||
|
||||
// Vinculamos los parámetros con el objeto de la partida actual y el equipo recibido
|
||||
$consulta->bindParam(":idPartida", $this->idPartida);
|
||||
$consulta->bindParam(":idEquipo", $idEquipo);
|
||||
$consulta->execute();
|
||||
|
||||
return [
|
||||
"exito" => "El equipo se vinculó a la partida correctamente.",
|
||||
"exito_tecnico" => $conexion->lastInsertId()
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
// Capturamos el error extrayendo solo el mensaje de texto limpio
|
||||
return [
|
||||
"error" => "Ocurrió un error al asignar el equipo a la partida.",
|
||||
"error_tecnico" => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene todos los equipos que están compitiendo en esta partida.
|
||||
* Es útil para mostrar la lista de rivales antes de empezar a responder.
|
||||
*/
|
||||
public function getEquiposParticipantes()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
// Hacemos un INNER JOIN para traer los nombres de los equipos desde la tabla intermedia
|
||||
$consulta = $conexion->prepare("
|
||||
SELECT
|
||||
exp.idEquipoxPartida,
|
||||
e.idEquipo,
|
||||
e.nombreEquipo
|
||||
FROM equipoxpartida exp
|
||||
INNER JOIN equipo e
|
||||
ON exp.idEquipo = e.idEquipo
|
||||
WHERE exp.idPartida = :idPartida
|
||||
ORDER BY e.nombreEquipo ASC
|
||||
");
|
||||
|
||||
$consulta->bindParam(":idPartida", $this->idPartida);
|
||||
$consulta->execute();
|
||||
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC); // Devuelve el array con los equipos rivales
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al recuperar los equipos de la partida.",
|
||||
"error_tecnico" => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene todos los jugadores reales (Usuarios) que están jugando en esta partida.
|
||||
* Utiliza la tabla 'equipoxusuario' en SQL para cruzar los datos.
|
||||
*/
|
||||
public function getJugadoresDeLaPartida()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$consulta = $conexion->prepare("
|
||||
SELECT DISTINCT
|
||||
u.idUsuario,
|
||||
u.nombreUsuario,
|
||||
u.email,
|
||||
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
|
||||
|
||||
ORDER BY e.nombreEquipo ASC,
|
||||
u.nombreUsuario ASC
|
||||
");
|
||||
|
||||
$consulta->bindParam(
|
||||
":idPartida",
|
||||
$this->idPartida
|
||||
);
|
||||
|
||||
$consulta->execute();
|
||||
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $error) {
|
||||
|
||||
return [
|
||||
"error" =>
|
||||
"Ocurrió un error al obtener la lista de jugadores.",
|
||||
|
||||
"error_tecnico" =>
|
||||
$error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
-98
@@ -1,115 +1,113 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
|
||||
|
||||
// Definición de la clase Pregunta que representará las preguntas de la trivia
|
||||
class Pregunta {
|
||||
// ATRIBUTOS (Propiedades privadas para encapsular el estado de cada pregunta)
|
||||
private ?int $id_pregunta; // El ID de la pregunta (autoincremental en la BD)
|
||||
private int $id_categoria; // El ID de la categoría a la que pertenece la pregunta
|
||||
private string $texto_pregunta; // El enunciado de la pregunta
|
||||
private array $respuestas; // Array que guardará la lista de respuestas posibles asociadas a esta pregunta
|
||||
private PDO $db; // La conexión a la base de datos mediante PDO
|
||||
private ?int $idPregunta;
|
||||
private int $idCategoria;
|
||||
private string $nombrePregunta;
|
||||
private array $respuestas;
|
||||
|
||||
// CONSTRUCTOR: Inicializa una nueva instancia de la clase Pregunta
|
||||
public function __construct(PDO $db, int $id_categoria = 0, string $texto_pregunta = "", ?int $id_pregunta = null) {
|
||||
$this->db = $db; // Asigna la conexión a la base de datos
|
||||
$this->id_pregunta = $id_pregunta; // Asigna el ID (null si es una nueva pregunta que no se ha guardado)
|
||||
$this->id_categoria = $id_categoria; // Asigna la categoría correspondiente
|
||||
$this->texto_pregunta = $texto_pregunta; // Asigna el texto de la pregunta
|
||||
$this->respuestas = []; // Inicializa el contenedor de respuestas como un array vacío
|
||||
public function __construct(int $idCategoria = 0, string $nombrePregunta = "", ?int $idPregunta = null) {
|
||||
$this->idPregunta = $idPregunta;
|
||||
$this->idCategoria = $idCategoria;
|
||||
$this->nombrePregunta = $nombrePregunta;
|
||||
$this->respuestas = [];
|
||||
}
|
||||
|
||||
// --- GETTERS Y SETTERS ---
|
||||
|
||||
// Getter para obtener el ID de la pregunta (solo lectura)
|
||||
public function getIdPregunta(): ?int {
|
||||
return $this->id_pregunta;
|
||||
}
|
||||
public function getIdPregunta(): ?int { return $this->idPregunta; }
|
||||
|
||||
// Getter para obtener el ID de la categoría
|
||||
public function getIdCategoria(): int {
|
||||
return $this->id_categoria;
|
||||
}
|
||||
|
||||
// Setter para cambiar la categoría de la pregunta
|
||||
public function setIdCategoria(int $id_categoria): void {
|
||||
$this->id_categoria = $id_categoria;
|
||||
}
|
||||
public function getIdCategoria(): int { return $this->idCategoria; }
|
||||
public function setIdCategoria(int $idCategoria): void { $this->idCategoria = $idCategoria; }
|
||||
|
||||
// Getter para obtener el texto de la pregunta
|
||||
public function getTextoPregunta(): string {
|
||||
return $this->texto_pregunta;
|
||||
}
|
||||
|
||||
// Setter para cambiar el texto de la pregunta
|
||||
public function setTextoPregunta(string $texto_pregunta): void {
|
||||
$this->texto_pregunta = $texto_pregunta;
|
||||
}
|
||||
public function getNombrePregunta(): string { return $this->nombrePregunta; }
|
||||
public function setNombrePregunta(string $nombrePregunta): void { $this->nombrePregunta = $nombrePregunta; }
|
||||
|
||||
// Getter para obtener el array con todas las respuestas cargadas de esta pregunta
|
||||
public function getRespuestas(): array {
|
||||
return $this->respuestas;
|
||||
}
|
||||
public function getRespuestas(): array { return $this->respuestas; }
|
||||
|
||||
// --- MÉTODOS DE BASE DE DATOS ---
|
||||
public function guardar() {
|
||||
$conexion = conexionBD();
|
||||
|
||||
// Método para guardar una nueva pregunta en la base de datos
|
||||
public function guardar(): bool {
|
||||
// Preparamos la consulta SQL para insertar la categoría y el texto de la pregunta
|
||||
$sql = "INSERT INTO pregunta (id_categoria, texto_pregunta) VALUES (:id_cat, :texto)";
|
||||
$stmt = $this->db->prepare($sql);
|
||||
|
||||
// Ejecutamos la consulta asociando los atributos actuales del objeto a los marcadores SQL
|
||||
$resultado = $stmt->execute([
|
||||
':id_cat' => $this->id_categoria,
|
||||
':texto' => $this->texto_pregunta
|
||||
]);
|
||||
|
||||
// Si se guardó correctamente, actualizamos el atributo id_pregunta del objeto con el ID generado en la BD
|
||||
if ($resultado) {
|
||||
$this->id_pregunta = (int)$this->db->lastInsertId();
|
||||
return true; // Retorna verdadero si la operación tuvo éxito
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
return false; // Retorna falso si falló el guardado
|
||||
}
|
||||
|
||||
// Método para buscar y cargar en memoria todas las respuestas asociadas a esta pregunta concreta
|
||||
public function cargarRespuestas(): void {
|
||||
// Si la pregunta aún no está guardada en la BD (su ID es null), no podemos buscar sus respuestas
|
||||
if ($this->id_pregunta === null) return;
|
||||
|
||||
// Consulta SQL para traer las respuestas vinculadas al ID de esta pregunta
|
||||
$sql = "SELECT id_respuesta, texto_respuesta, es_correcta FROM respuesta WHERE id_pregunta = :id_preg";
|
||||
$stmt = $this->db->prepare($sql);
|
||||
$stmt->execute([':id_preg' => $this->id_pregunta]);
|
||||
|
||||
// Guardamos todas las filas encontradas directamente dentro del array de respuestas del objeto
|
||||
$this->respuestas = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
// Método estático para obtener un listado de preguntas aleatorias filtradas por una categoría
|
||||
public static function obtenerPorCategoria(PDO $db, int $id_categoria, int $limite = 10): array {
|
||||
// Consulta SQL que filtra por categoría, desordena los resultados al azar (RAND()) y limita la cantidad
|
||||
$sql = "SELECT * FROM pregunta WHERE id_categoria = :id_cat ORDER BY RAND() LIMIT :limite";
|
||||
$stmt = $db->prepare($sql);
|
||||
|
||||
// Vinculamos los parámetros asegurando que el límite sea interpretado estrictamente como un número entero (PARAM_INT)
|
||||
$stmt->bindValue(':id_cat', $id_categoria, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':limite', $limite, PDO::PARAM_INT);
|
||||
$stmt->execute(); // Ejecutamos la consulta
|
||||
|
||||
$preguntas = []; // Array donde amontonaremos los objetos Pregunta resultantes
|
||||
|
||||
// Recorremos fila por fila los resultados devueltos por la base de datos
|
||||
while ($datos = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
// Creamos un nuevo objeto Pregunta con los datos de la fila actual
|
||||
$preg = new Pregunta($db, $datos['id_categoria'], $datos['texto_pregunta'], $datos['id_pregunta']);
|
||||
try {
|
||||
$sql = "INSERT INTO pregunta (idCategoria, nombrePregunta) VALUES (:idCat, :texto)";
|
||||
$stmt = $conexion->prepare($sql);
|
||||
|
||||
// Llamamos al método interno del objeto para que busque y le pegue sus opciones de respuesta correspondientes
|
||||
$preg->cargarRespuestas();
|
||||
|
||||
// Añadimos el objeto completamente armado al array final
|
||||
$preguntas[] = $preg;
|
||||
$stmt->execute([
|
||||
':idCat' => $this->idCategoria,
|
||||
':texto' => $this->nombrePregunta
|
||||
]);
|
||||
|
||||
$this->idPregunta = (int)$conexion->lastInsertId();
|
||||
|
||||
return [
|
||||
'exito' => 'Pregunta guardada correctamente',
|
||||
'exito_tecnico' => $this->idPregunta
|
||||
];
|
||||
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al guardar la pregunta.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function cargarRespuestas() {
|
||||
if ($this->idPregunta === null) return;
|
||||
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
$sql = "SELECT idRespuesta, nombreRespuesta, correcta FROM respuesta WHERE idPregunta = :idPreg";
|
||||
$stmt = $conexion->prepare($sql);
|
||||
$stmt->execute([':idPreg' => $this->idPregunta]);
|
||||
|
||||
$this->respuestas = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al cargar las respuestas.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public static function obtenerPorCategoria(int $idCategoria, int $limite = 10) {
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
$sql = "SELECT * FROM pregunta WHERE idCategoria = :idCat ORDER BY RAND() LIMIT :limite";
|
||||
$stmt = $conexion->prepare($sql);
|
||||
|
||||
$stmt->bindValue(':idCat', $idCategoria, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':limite', $limite, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
|
||||
$preguntas = [];
|
||||
while ($datos = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$preg = new Pregunta((int)$datos['idCategoria'], $datos['nombrePregunta'], (int)$datos['idPregunta']);
|
||||
$preg->cargarRespuestas();
|
||||
$preguntas[] = $preg;
|
||||
}
|
||||
return $preguntas;
|
||||
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al obtener las preguntas aleatorias.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
return $preguntas; // Devolvemos la lista de objetos Pregunta listos para jugar
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once $_SERVER['DOCUMENT_ROOT'].'/includes/conexionBD.php';
|
||||
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
|
||||
class Respuesta{
|
||||
public $idRespuesta;
|
||||
public $idPregunta;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
|
||||
// Clase encargada de registrar las respuestas de los jugadores en tiempo real durante la partida
|
||||
class RespuestaAlmacenada {
|
||||
public $idRespuestaAlmacenada;
|
||||
public $idPartidaxPregunta;
|
||||
public $idUsuario;
|
||||
public $idRespuesta;
|
||||
|
||||
public function __construct($idRespuestaAlmacenada = null, $idPartidaxPregunta = null, $idUsuario = null, $idRespuesta = null) {
|
||||
$this->idRespuestaAlmacenada = $idRespuestaAlmacenada;
|
||||
$this->idPartidaxPregunta = $idPartidaxPregunta;
|
||||
$this->idUsuario = $idUsuario;
|
||||
$this->idRespuesta = $idRespuesta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guarda la respuesta que ha seleccionado un usuario en una pregunta de la partida.
|
||||
*/
|
||||
public function guardarRespuesta() {
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) return $conexion;
|
||||
|
||||
try {
|
||||
$sql = "INSERT INTO respuestaalmacenada (idPartidaxPregunta, idUsuario, idRespuesta)
|
||||
VALUES (:idPartidaxPregunta, :idUsuario, :idRespuesta)";
|
||||
$consulta = $conexion->prepare($sql);
|
||||
|
||||
$consulta->bindParam(':idPartidaxPregunta', $this->idPartidaxPregunta);
|
||||
$consulta->bindParam(':idUsuario', $this->idUsuario);
|
||||
$consulta->bindParam(':idRespuesta', $this->idRespuesta);
|
||||
$consulta->execute();
|
||||
|
||||
return [
|
||||
'exito' => 'Respuesta del usuario almacenada correctamente.',
|
||||
'exito_tecnico' => $conexion->lastInsertId()
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al guardar la respuesta del jugador.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene los aciertos totales de un usuario en una partida específica.
|
||||
* Útil para calcular las estadísticas individuales al terminar el juego.
|
||||
*/
|
||||
public static function obtenerAciertosUsuarioEnPartida($idPartida, $idUsuario) {
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) return $conexion;
|
||||
|
||||
try {
|
||||
$sql = "SELECT COUNT(*) AS aciertos
|
||||
FROM respuestaalmacenada ra
|
||||
INNER JOIN partidaxpregunta pxp ON ra.idPartidaxPregunta = pxp.idPartidaxPregunta
|
||||
INNER JOIN respuesta r ON ra.idRespuesta = r.idRespuesta
|
||||
WHERE pxp.idPartida = :idPartida AND ra.idUsuario = :idUsuario AND r.correcta = 1";
|
||||
|
||||
$consulta = $conexion->prepare($sql);
|
||||
$consulta->bindParam(':idPartida', $idPartida);
|
||||
$consulta->bindParam(':idUsuario', $idUsuario);
|
||||
$consulta->execute();
|
||||
|
||||
$resultado = $consulta->fetch(PDO::FETCH_ASSOC);
|
||||
return (int)$resultado['aciertos'];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al calcular los aciertos.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
+452
-80
@@ -1,102 +1,474 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
|
||||
// Definición de la clase Usuario que representará a los usuarios del sistema
|
||||
class Usuario {
|
||||
// ATRIBUTOS (Propiedades privadas para proteger los datos de accesos directos externos)
|
||||
private ?int $id_usuario; // El ID del usuario (puede ser null si aún no se ha guardado en la base de datos)
|
||||
private string $nombre_usuario; // El nombre de usuario en texto
|
||||
private string $contrasena; // La contraseña (normalmente encriptada)
|
||||
private string $email; // El correo electrónico del usuario
|
||||
private PDO $db; // La conexión a la base de datos mediante el objeto PDO
|
||||
class Usuario
|
||||
{
|
||||
private ?int $idUsuario;
|
||||
private string $nombreUsuario;
|
||||
private string $contrasena;
|
||||
private string $email;
|
||||
private ?string $avatar;
|
||||
private ?string $cookie;
|
||||
private int $aciertos;
|
||||
private int $victorias;
|
||||
private int $derrotas;
|
||||
|
||||
// CONSTRUCTOR: Se ejecuta automáticamente al crear un nuevo objeto (ej: new Usuario($db, "Juan", ...))
|
||||
public function __construct(PDO $db, string $nombre_usuario = "", string $contrasena = "", string $email = "", ?int $id_usuario = null) {
|
||||
$this->db = $db; // Asigna la conexión a la base de datos al atributo interno
|
||||
$this->id_usuario = $id_usuario; // Asigna el ID (por defecto es null si es un registro nuevo)
|
||||
$this->nombre_usuario = $nombre_usuario; // Asigna el nombre de usuario recibido
|
||||
$this->contrasena = $contrasena; // Asigna la contraseña recibida
|
||||
$this->email = $email; // Asigna el email recibido
|
||||
public function __construct(
|
||||
string $nombreUsuario = "",
|
||||
string $contrasena = "",
|
||||
string $email = "",
|
||||
?string $avatar = null,
|
||||
?string $cookie = null,
|
||||
int $aciertos = 0,
|
||||
int $victorias = 0,
|
||||
int $derrotas = 0,
|
||||
?int $idUsuario = null
|
||||
) {
|
||||
$this->idUsuario = $idUsuario;
|
||||
$this->nombreUsuario = $nombreUsuario;
|
||||
$this->contrasena = $contrasena;
|
||||
$this->email = $email;
|
||||
$this->avatar = $avatar;
|
||||
$this->cookie = $cookie;
|
||||
$this->aciertos = $aciertos;
|
||||
$this->victorias = $victorias;
|
||||
$this->derrotas = $derrotas;
|
||||
}
|
||||
|
||||
// --- GETTERS Y SETTERS (Métodos públicos para acceder y modificar los datos privados de forma segura) ---
|
||||
|
||||
// Getter para obtener el ID del usuario (es de solo lectura, no tiene setter)
|
||||
public function getIdUsuario(): ?int {
|
||||
return $this->id_usuario;
|
||||
}
|
||||
|
||||
// Getter para obtener el nombre de usuario
|
||||
public function getNombreUsuario(): string {
|
||||
return $this->nombre_usuario;
|
||||
}
|
||||
|
||||
// Setter para cambiar el nombre de usuario desde fuera de la clase
|
||||
public function setNombreUsuario(string $nombre_usuario): void {
|
||||
$this->nombre_usuario = $nombre_usuario;
|
||||
public function getIdUsuario(): ?int
|
||||
{
|
||||
return $this->idUsuario;
|
||||
}
|
||||
|
||||
// Getter para obtener la contraseña
|
||||
public function getContrasena(): string {
|
||||
return $this->contrasena;
|
||||
public function getNombreUsuario(): string
|
||||
{
|
||||
return $this->nombreUsuario;
|
||||
}
|
||||
|
||||
// Setter para cambiar la contraseña desde fuera de la clase
|
||||
public function setContrasena(string $contrasena): void {
|
||||
$this->contrasena = $contrasena;
|
||||
public function setNombreUsuario(string $nombreUsuario): void
|
||||
{
|
||||
$this->nombreUsuario = $nombreUsuario;
|
||||
}
|
||||
|
||||
// Getter para obtener el correo electrónico
|
||||
public function getEmail(): string {
|
||||
return $this->email;
|
||||
public function getContrasena(): string
|
||||
{
|
||||
return $this->contrasena;
|
||||
}
|
||||
|
||||
// Setter para cambiar el correo electrónico desde fuera de la clase
|
||||
public function setEmail(string $email): void {
|
||||
$this->email = $email;
|
||||
public function setContrasena(string $contrasena): void
|
||||
{
|
||||
$this->contrasena = $contrasena;
|
||||
}
|
||||
|
||||
// --- MÉTODOS DE BASE DE DATOS (Lógica de negocio e interacción con SQL) ---
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
public function setEmail(string $email): void
|
||||
{
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
// Método para registrar/insertar el usuario actual en la base de datos
|
||||
public function registrar(): bool {
|
||||
// Preparamos la consulta SQL usando marcadores (:nombre, :pass, :email) para evitar inyecciones SQL
|
||||
$sql = "INSERT INTO usuario (nombre_usuario, contrasena, email) VALUES (:nombre, :pass, :email)";
|
||||
$stmt = $this->db->prepare($sql); // Prepara la consulta en el servidor de la base de datos
|
||||
|
||||
// Encriptamos la contraseña con el algoritmo BCRYPT antes de guardarla por seguridad
|
||||
$passHash = password_hash($this->contrasena, PASSWORD_BCRYPT);
|
||||
public function getAvatar(): ?string
|
||||
{
|
||||
return $this->avatar;
|
||||
}
|
||||
public function setAvatar(?string $avatar): void
|
||||
{
|
||||
$this->avatar = $avatar;
|
||||
}
|
||||
|
||||
// Ejecutamos la consulta pasando los valores reales que sustituirán a los marcadores
|
||||
$resultado = $stmt->execute([
|
||||
':nombre' => $this->nombre_usuario,
|
||||
':pass' => $passHash, // Guardamos la contraseña ya encriptada
|
||||
':email' => $this->email
|
||||
]);
|
||||
public function getCookie(): ?string
|
||||
{
|
||||
return $this->cookie;
|
||||
}
|
||||
public function setCookie(?string $cookie): void
|
||||
{
|
||||
$this->cookie = $cookie;
|
||||
}
|
||||
|
||||
// Si la inserción fue exitosa, recuperamos el ID generado por la base de datos y lo asignamos al objeto
|
||||
if ($resultado) {
|
||||
$this->id_usuario = (int)$this->db->lastInsertId();
|
||||
return true; // Devuelve verdadero indicando que se registró correctamente
|
||||
public function getAciertos(): int
|
||||
{
|
||||
return $this->aciertos;
|
||||
}
|
||||
public function setAciertos(int $aciertos): void
|
||||
{
|
||||
$this->aciertos = $aciertos;
|
||||
}
|
||||
|
||||
public function getVictorias(): int
|
||||
{
|
||||
return $this->victorias;
|
||||
}
|
||||
public function setVictorias(int $victorias): void
|
||||
{
|
||||
$this->victorias = $victorias;
|
||||
}
|
||||
|
||||
public function getDerrotas(): int
|
||||
{
|
||||
return $this->derrotas;
|
||||
}
|
||||
public function setDerrotas(int $derrotas): void
|
||||
{
|
||||
$this->derrotas = $derrotas;
|
||||
}
|
||||
|
||||
public function registrar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
return false; // Devuelve falso si hubo algún error en la inserción
|
||||
}
|
||||
|
||||
// Método estático para buscar un usuario por su ID sin necesidad de instanciar el objeto previamente
|
||||
public static function buscarPorId(PDO $db, int $id): ?Usuario {
|
||||
// Preparamos la consulta SQL filtrando por el ID recibido
|
||||
$sql = "SELECT * FROM usuario WHERE id_usuario = :id";
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->execute([':id' => $id]); // Ejecutamos la consulta
|
||||
|
||||
// Obtenemos el registro en forma de array asociativo
|
||||
$datos = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
try {
|
||||
$sql = "INSERT INTO usuario (nombreUsuario, contrasena, email, avatar, cookie, aciertos, victorias, derrotas)
|
||||
VALUES (:nombre, :pass, :email, :avatar, :cookie, :aciertos, :victorias, :derrotas)";
|
||||
$stmt = $conexion->prepare($sql);
|
||||
|
||||
// Si el usuario existe en la base de datos, creamos y devolvemos un nuevo objeto Usuario con sus datos
|
||||
if ($datos) {
|
||||
return new Usuario($db, $datos['nombre_usuario'], $datos['contrasena'], $datos['email'], $datos['id_usuario']);
|
||||
$passHash = password_hash($this->contrasena, PASSWORD_BCRYPT);
|
||||
|
||||
$stmt->execute([
|
||||
':nombre' => $this->nombreUsuario,
|
||||
':pass' => $passHash,
|
||||
':email' => $this->email,
|
||||
':avatar' => $this->avatar,
|
||||
':cookie' => $this->cookie,
|
||||
':aciertos' => $this->aciertos,
|
||||
':victorias' => $this->victorias,
|
||||
':derrotas' => $this->derrotas
|
||||
]);
|
||||
|
||||
$this->idUsuario = (int)$conexion->lastInsertId();
|
||||
|
||||
return [
|
||||
'exito' => 'Usuario registrado correctamente',
|
||||
'exito_tecnico' => $this->idUsuario
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al registrar el usuario.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
return null; // Si no se encuentra el usuario, devolvemos null
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
public static function buscarPorId($id)
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
$sql = "SELECT * FROM usuario WHERE idUsuario = :id";
|
||||
$stmt = $conexion->prepare($sql);
|
||||
$stmt->execute([':id' => $id]);
|
||||
|
||||
$datos = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($datos) {
|
||||
return new Usuario(
|
||||
$datos['nombreUsuario'],
|
||||
$datos['contrasena'],
|
||||
$datos['email'],
|
||||
$datos['avatar'],
|
||||
$datos['cookie'],
|
||||
(int)$datos['aciertos'],
|
||||
(int)$datos['victorias'],
|
||||
(int)$datos['derrotas'],
|
||||
(int)$datos['idUsuario']
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
'error' => 'No se encontró ningún usuario con ese ID.'
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al buscar el usuario.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public static function buscarPorEmail($email)
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
$sql = "SELECT * FROM usuario WHERE email = :email";
|
||||
$stmt = $conexion->prepare($sql);
|
||||
$stmt->execute([':email' => $email]);
|
||||
|
||||
$datos = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($datos) {
|
||||
return new Usuario(
|
||||
$datos['nombreUsuario'],
|
||||
$datos['contrasena'],
|
||||
$datos['email'],
|
||||
$datos['avatar'],
|
||||
$datos['cookie'],
|
||||
(int)$datos['aciertos'],
|
||||
(int)$datos['victorias'],
|
||||
(int)$datos['derrotas'],
|
||||
(int)$datos['idUsuario']
|
||||
);
|
||||
}
|
||||
|
||||
return null; // No existe usuario con ese email
|
||||
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al buscar el usuario por email.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public static function login($email, $contrasena)
|
||||
{
|
||||
$usuario = self::buscarPorEmail($email);
|
||||
|
||||
// El usuario no existe
|
||||
if (!($usuario instanceof Usuario)) {
|
||||
|
||||
// Limpiamos posibles datos de sesión anteriores
|
||||
unset($_SESSION['idUsuario']);
|
||||
unset($_SESSION['email']);
|
||||
unset($_SESSION['nombreUsuario']);
|
||||
unset($_SESSION['avatar']);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Comprobamos la contraseña
|
||||
if (password_verify($contrasena, $usuario->getContrasena())) {
|
||||
|
||||
// Usuario validado correctamente
|
||||
$_SESSION['idUsuario'] = $usuario->getIdUsuario();
|
||||
$_SESSION['email'] = $usuario->getEmail();
|
||||
$_SESSION['nombreUsuario'] = $usuario->getNombreUsuario();
|
||||
$_SESSION['avatar'] = $usuario->getAvatar();
|
||||
|
||||
// Devolvemos el usuario como hasta ahora
|
||||
return $usuario;
|
||||
}
|
||||
|
||||
// Contraseña incorrecta
|
||||
unset($_SESSION['idUsuario']);
|
||||
unset($_SESSION['email']);
|
||||
unset($_SESSION['nombreUsuario']);
|
||||
unset($_SESSION['avatar']);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Cookies
|
||||
|
||||
public static function guardarCookieToken($idUsuario, $token)
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) return false;
|
||||
|
||||
try {
|
||||
$sql = "UPDATE usuario SET cookie = :token WHERE idUsuario = :id";
|
||||
$stmt = $conexion->prepare($sql);
|
||||
return $stmt->execute([
|
||||
':token' => $token,
|
||||
':id' => $idUsuario
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function buscarPorCookie($token)
|
||||
{
|
||||
if (empty($token)) return null;
|
||||
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) return null;
|
||||
|
||||
try {
|
||||
$sql = "SELECT * FROM usuario WHERE cookie = :token AND cookie IS NOT NULL";
|
||||
$stmt = $conexion->prepare($sql);
|
||||
$stmt->execute([':token' => $token]);
|
||||
|
||||
$datos = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($datos) {
|
||||
return new Usuario(
|
||||
$datos['nombreUsuario'],
|
||||
$datos['contrasena'],
|
||||
$datos['email'],
|
||||
$datos['avatar'],
|
||||
$datos['cookie'],
|
||||
(int)$datos['aciertos'],
|
||||
(int)$datos['victorias'],
|
||||
(int)$datos['derrotas'],
|
||||
(int)$datos['idUsuario']
|
||||
);
|
||||
}
|
||||
return null;
|
||||
} catch (PDOException $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function cambiarNombre($nuevoNombre)
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$sql = "UPDATE usuario
|
||||
SET nombreUsuario = :nombre
|
||||
WHERE idUsuario = :id";
|
||||
|
||||
$stmt = $conexion->prepare($sql);
|
||||
|
||||
$stmt->execute([
|
||||
':nombre' => $nuevoNombre,
|
||||
':id' => $this->idUsuario
|
||||
]);
|
||||
|
||||
// Actualizamos también el objeto actual
|
||||
$this->nombreUsuario = $nuevoNombre;
|
||||
|
||||
return [
|
||||
'exito' => 'Nombre actualizado correctamente.'
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
|
||||
return [
|
||||
'error' => 'Ocurrió un error al actualizar el nombre.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function cambiarAvatar($archivo)
|
||||
{
|
||||
$carpeta = __DIR__ . '/../img/avatars/';
|
||||
|
||||
// Creamos la carpeta si no existe
|
||||
if (!is_dir($carpeta)) {
|
||||
mkdir($carpeta, 0755, true);
|
||||
}
|
||||
|
||||
// Obtenemos la extensión según el tipo MIME
|
||||
$tipo = mime_content_type($archivo['tmp_name']);
|
||||
|
||||
$extensiones = [
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/png' => 'png',
|
||||
'image/gif' => 'gif',
|
||||
'image/webp' => 'webp'
|
||||
];
|
||||
|
||||
if (!isset($extensiones[$tipo])) {
|
||||
|
||||
return [
|
||||
'error' => 'Formato de imagen no permitido.'
|
||||
];
|
||||
}
|
||||
|
||||
$extension = $extensiones[$tipo];
|
||||
|
||||
// Nombre único para evitar conflictos
|
||||
$nombreArchivo = 'avatar_' . $this->idUsuario . '.' . $extension;
|
||||
|
||||
$rutaCompleta = $carpeta . $nombreArchivo;
|
||||
|
||||
// Guardamos la imagen
|
||||
if (!move_uploaded_file($archivo['tmp_name'], $rutaCompleta)) {
|
||||
|
||||
return [
|
||||
'error' => 'No se pudo guardar la imagen.'
|
||||
];
|
||||
}
|
||||
|
||||
// Ruta que utilizará el HTML
|
||||
$rutaAvatar = 'img/avatars/' . $nombreArchivo;
|
||||
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$sql = "UPDATE usuario
|
||||
SET avatar = :avatar
|
||||
WHERE idUsuario = :id";
|
||||
|
||||
$stmt = $conexion->prepare($sql);
|
||||
|
||||
$stmt->execute([
|
||||
':avatar' => $rutaAvatar,
|
||||
':id' => $this->idUsuario
|
||||
]);
|
||||
|
||||
// Actualizamos también el objeto actual
|
||||
$this->avatar = $rutaAvatar;
|
||||
|
||||
return [
|
||||
'exito' => 'Avatar actualizado correctamente.',
|
||||
'avatar' => $rutaAvatar
|
||||
];
|
||||
} catch (PDOException $error) {
|
||||
|
||||
return [
|
||||
'error' => 'Ocurrió un error al actualizar el avatar.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public static function obtenerRanking($limite = 10)
|
||||
{
|
||||
try {
|
||||
$conexion = conexionBD();
|
||||
|
||||
if (is_array($conexion)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT
|
||||
idUsuario,
|
||||
nombreUsuario,
|
||||
avatar,
|
||||
aciertos,
|
||||
victorias,
|
||||
derrotas,
|
||||
CASE
|
||||
WHEN (victorias + derrotas) > 0
|
||||
THEN ROUND((victorias / (victorias + derrotas)) * 100, 0)
|
||||
ELSE 0
|
||||
END AS porcentajeVictoria
|
||||
FROM usuario
|
||||
ORDER BY victorias DESC, aciertos DESC
|
||||
LIMIT " . (int)$limite;
|
||||
|
||||
$stmt = $conexion->prepare($sql);
|
||||
$stmt->execute();
|
||||
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,332 +0,0 @@
|
||||
<?php
|
||||
require_once '../includes/conexion.php';
|
||||
|
||||
class Partida{
|
||||
|
||||
public $idPartida;
|
||||
public $nombrePartida;
|
||||
public $idUsuario;
|
||||
|
||||
public function __construct(
|
||||
$idPartida=null,
|
||||
$nombrePartida=null,
|
||||
$idUsuario=null
|
||||
){
|
||||
$this->idPartida=$idPartida;
|
||||
$this->nombrePartida=$nombrePartida;
|
||||
$this->idUsuario=$idUsuario;
|
||||
}
|
||||
|
||||
public function insertar(){
|
||||
$conexion=conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
try{
|
||||
$consulta=$conexion->prepare("
|
||||
INSERT INTO partida
|
||||
(nombrePartida,idUsuario)
|
||||
VALUES
|
||||
(:nombrePartida,:idUsuario)
|
||||
");
|
||||
$consulta->bindParam(":nombrePartida",$this->nombrePartida);
|
||||
$consulta->bindParam(":idUsuario",$this->idUsuario);
|
||||
$consulta->execute();
|
||||
return[
|
||||
"exito"=>"La partida se creó correctamente.",
|
||||
"exito_tecnico"=>$conexion->lastInsertId()
|
||||
];
|
||||
}catch(PDOException $error){
|
||||
return[
|
||||
"error"=>"Ocurrió un error al guardar la partida.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function listar(){
|
||||
$conexion=conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
try{
|
||||
$consulta=$conexion->prepare("SELECT * FROM partida");
|
||||
$consulta->execute();
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
}catch(PDOException $error){
|
||||
return[
|
||||
"error"=>"Ocurrió un error al obtener el listado.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function buscar(){
|
||||
$conexion=conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
try{
|
||||
$consulta=$conexion->prepare("
|
||||
SELECT *
|
||||
FROM partida
|
||||
WHERE idPartida=:idPartida
|
||||
");
|
||||
$consulta->bindParam(":idPartida",$this->idPartida);
|
||||
$consulta->execute();
|
||||
return $consulta->fetch(PDO::FETCH_ASSOC);
|
||||
}catch(PDOException $error){
|
||||
return[
|
||||
"error"=>"Ocurrió un error al buscar la partida.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function editar(){
|
||||
$conexion=conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
try{
|
||||
$consulta=$conexion->prepare("
|
||||
UPDATE partida
|
||||
SET
|
||||
nombrePartida=:nombrePartida,
|
||||
idUsuario=:idUsuario
|
||||
WHERE idPartida=:idPartida
|
||||
");
|
||||
$consulta->bindParam(":idPartida",$this->idPartida);
|
||||
$consulta->bindParam(":nombrePartida",$this->nombrePartida);
|
||||
$consulta->bindParam(":idUsuario",$this->idUsuario);
|
||||
$consulta->execute();
|
||||
return[
|
||||
"exito"=>"La partida se editó correctamente.",
|
||||
"exito_tecnico"=>$this->idPartida
|
||||
];
|
||||
}catch(PDOException $error){
|
||||
return[
|
||||
"error"=>"Ocurrió un error al editar la partida.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function eliminar(){
|
||||
$conexion=conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
try{
|
||||
$consulta=$conexion->prepare("
|
||||
DELETE FROM partida
|
||||
WHERE idPartida=:idPartida
|
||||
");
|
||||
$consulta->bindParam(":idPartida",$this->idPartida);
|
||||
$consulta->execute();
|
||||
return[
|
||||
"exito"=>"La partida se eliminó correctamente.",
|
||||
"exito_tecnico"=>$this->idPartida
|
||||
];
|
||||
}catch(PDOException $error){
|
||||
return[
|
||||
"error"=>"No se pudo eliminar la partida.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve las preguntas asignadas a la partida, junto con el
|
||||
* idPartidaxPregunta (necesario para guardar respuestas después).
|
||||
*/
|
||||
public function getPreguntas(){
|
||||
$conexion=conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
try{
|
||||
$consulta=$conexion->prepare("
|
||||
SELECT
|
||||
pxp.idPartidaxPregunta,
|
||||
p.*
|
||||
FROM partidaxpregunta pxp
|
||||
INNER JOIN pregunta p
|
||||
ON pxp.idPregunta=p.idPregunta
|
||||
WHERE pxp.idPartida=:idPartida
|
||||
ORDER BY pxp.idPartidaxPregunta
|
||||
");
|
||||
$consulta->bindParam(":idPartida",$this->idPartida);
|
||||
$consulta->execute();
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
}catch(PDOException $error){
|
||||
return[
|
||||
"error"=>"Ocurrió un error al recuperar las preguntas de la partida.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asocia una pregunta ya existente a esta partida.
|
||||
*/
|
||||
public function asignarPregunta($idPregunta){
|
||||
$conexion=conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
try{
|
||||
$consulta=$conexion->prepare("
|
||||
INSERT INTO partidaxpregunta
|
||||
(idPartida,idPregunta)
|
||||
VALUES
|
||||
(:idPartida,:idPregunta)
|
||||
");
|
||||
$consulta->bindParam(":idPartida",$this->idPartida);
|
||||
$consulta->bindParam(":idPregunta",$idPregunta);
|
||||
$consulta->execute();
|
||||
return[
|
||||
"exito"=>"La pregunta se asignó correctamente.",
|
||||
"exito_tecnico"=>$conexion->lastInsertId()
|
||||
];
|
||||
}catch(PDOException $error){
|
||||
return[
|
||||
"error"=>"Ocurrió un error al asignar la pregunta.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Cuenta cuántas preguntas tiene la partida en total. Es la primera mitad de la comprobación "¿ha terminado el usuario de jugar?".
|
||||
public function contarPreguntasAsignadas(){
|
||||
$conexion=conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
try{
|
||||
$consulta=$conexion->prepare("
|
||||
SELECT COUNT(*) AS total
|
||||
FROM partidaxpregunta
|
||||
WHERE idPartida=:idPartida
|
||||
");
|
||||
$consulta->bindParam(":idPartida",$this->idPartida);
|
||||
$consulta->execute();
|
||||
$fila=$consulta->fetch(PDO::FETCH_ASSOC);
|
||||
return (int)$fila["total"];
|
||||
}catch(PDOException $error){
|
||||
return[
|
||||
"error"=>"Ocurrió un error al contar las preguntas.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function contarRespuestasUsuario($idUsuario){
|
||||
$conexion=conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
try{
|
||||
$consulta=$conexion->prepare("
|
||||
SELECT COUNT(*) AS total
|
||||
FROM respuestaalmacenada ra
|
||||
INNER JOIN partidaxpregunta pxp
|
||||
ON ra.idPartidaxPregunta=pxp.idPartidaxPregunta
|
||||
WHERE pxp.idPartida=:idPartida
|
||||
AND ra.idUsuario=:idUsuario
|
||||
");
|
||||
$consulta->bindParam(":idPartida",$this->idPartida);
|
||||
$consulta->bindParam(":idUsuario",$idUsuario);
|
||||
$consulta->execute();
|
||||
$fila=$consulta->fetch(PDO::FETCH_ASSOC);
|
||||
return (int)$fila["total"];
|
||||
}catch(PDOException $error){
|
||||
return[
|
||||
"error"=>"Ocurrió un error al contar las respuestas del usuario.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sustituye al antiguo campo `terminada`: compara cuántas preguntas
|
||||
* tiene la partida contra cuántas ha respondido este usuario.
|
||||
*/
|
||||
public function estaFinalizadaParaUsuario($idUsuario){
|
||||
$totalPreguntas=$this->contarPreguntasAsignadas();
|
||||
if(is_array($totalPreguntas)){
|
||||
return $totalPreguntas;
|
||||
}
|
||||
$totalRespondidas=$this->contarRespuestasUsuario($idUsuario);
|
||||
if(is_array($totalRespondidas)){
|
||||
return $totalRespondidas;
|
||||
}
|
||||
return $totalPreguntas>0 && $totalPreguntas===$totalRespondidas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Partidas creadas por un usuario, de más reciente a más antigua.
|
||||
*/
|
||||
public function listarDelUsuario(){
|
||||
$conexion=conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
try{
|
||||
$consulta=$conexion->prepare("
|
||||
SELECT *
|
||||
FROM partida
|
||||
WHERE idUsuario=:idUsuario
|
||||
ORDER BY idPartida DESC
|
||||
");
|
||||
$consulta->bindParam(":idUsuario",$this->idUsuario);
|
||||
$consulta->execute();
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
}catch(PDOException $error){
|
||||
return[
|
||||
"error"=>"Ocurrió un error al recuperar las partidas del usuario.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function preguntaAsignada($idPregunta){
|
||||
$conexion=conexionBD();
|
||||
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}
|
||||
|
||||
try{
|
||||
$consulta=$conexion->prepare("
|
||||
SELECT COUNT(*) AS total
|
||||
FROM partidaxpregunta
|
||||
WHERE idPartida=:idPartida
|
||||
AND idPregunta=:idPregunta
|
||||
");
|
||||
|
||||
$consulta->bindParam(":idPartida",$this->idPartida);
|
||||
$consulta->bindParam(":idPregunta",$idPregunta);
|
||||
$consulta->execute();
|
||||
|
||||
$fila=$consulta->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
return (int)$fila["total"] > 0;
|
||||
|
||||
}catch(PDOException $error){
|
||||
|
||||
return[
|
||||
"error"=>"Ocurrió un error al comprobar la pregunta.",
|
||||
"error_tecnico"=>$error
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once '../clases/ClaseCategoria.php';
|
||||
|
||||
switch ($_POST['orden']) {
|
||||
|
||||
case 'crearCategoria':
|
||||
|
||||
$nombreCategoria = trim($_POST['nombreCategoria'] ?? '');
|
||||
|
||||
if ($nombreCategoria == '') {
|
||||
echo json_encode(['error' => 'El nombre de la categoría es obligatorio']);
|
||||
break;
|
||||
}
|
||||
|
||||
$categoria = new Categoria(null, $nombreCategoria);
|
||||
$resultado = $categoria->crear();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'listarCategorias':
|
||||
|
||||
$categoria = new Categoria();
|
||||
$resultado = $categoria->listar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'buscarCategoria':
|
||||
|
||||
$idCategoria = intval($_POST['idCategoria'] ?? 0);
|
||||
|
||||
$categoria = new Categoria($idCategoria);
|
||||
$resultado = $categoria->buscar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'borrarCategoria':
|
||||
|
||||
$idCategoria = intval($_POST['idCategoria'] ?? 0);
|
||||
|
||||
$categoria = new Categoria($idCategoria);
|
||||
$resultado = $categoria->borrar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once '../clases/ClaseEquipo.php';
|
||||
|
||||
switch ($_POST['orden']) {
|
||||
|
||||
case 'crearEquipo':
|
||||
|
||||
$nombreEquipo = trim($_POST['nombreEquipo'] ?? '');
|
||||
|
||||
if ($nombreEquipo == '') {
|
||||
echo json_encode(['error' => 'El nombre del equipo es obligatorio']);
|
||||
break;
|
||||
}
|
||||
|
||||
$equipo = new Equipo(null, $nombreEquipo);
|
||||
$resultado = $equipo->crear();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'listarEquipos':
|
||||
|
||||
$equipo = new Equipo();
|
||||
$resultado = $equipo->listar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'buscarEquipo':
|
||||
|
||||
$idEquipo = intval($_POST['idEquipo'] ?? 0);
|
||||
|
||||
$equipo = new Equipo($idEquipo);
|
||||
$resultado = $equipo->buscar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'borrarEquipo':
|
||||
|
||||
$idEquipo = intval($_POST['idEquipo'] ?? 0);
|
||||
|
||||
$equipo = new Equipo($idEquipo);
|
||||
$resultado = $equipo->borrar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once '../clases/ClaseEquipoxUsuario.php';
|
||||
|
||||
switch ($_POST['orden']) {
|
||||
|
||||
case 'registrarUsuarioEnEquipo':
|
||||
|
||||
if (!isset($_SESSION['idUsuario'])) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'No hay una sesión activa de usuario. Por favor, inicie sesión.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$idUsuario = $_SESSION['idUsuario'];
|
||||
|
||||
$idEquipo = intval($_POST['idEquipo'] ?? 0);
|
||||
|
||||
if ($idEquipo <= 0) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'El ID del equipo proporcionado no es válido.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$equipoxusuario = new EquipoxUsuario(
|
||||
null,
|
||||
$idUsuario,
|
||||
$idEquipo
|
||||
);
|
||||
$resultado = $equipoxusuario->registrarUsuarioEnEquipo();
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'listarUsuariosPorEquipo':
|
||||
$idEquipo = intval($_POST['idEquipo'] ?? 0);
|
||||
|
||||
if ($idEquipo <= 0) {
|
||||
echo json_encode(['error' => 'ID de equipo no válido']);
|
||||
break;
|
||||
}
|
||||
$equipoxusuario = new EquipoxUsuario();
|
||||
$listado = $equipoxusuario->listarUsuariosPorEquipo($idEquipo);
|
||||
//break;
|
||||
echo json_encode($listado);
|
||||
break;
|
||||
|
||||
case 'obtenerSalaUsuario':
|
||||
|
||||
if (!isset($_SESSION['idUsuario'])) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'No hay una sesión activa de usuario.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$idUsuario = $_SESSION['idUsuario'];
|
||||
|
||||
$equipoxusuario = new EquipoxUsuario();
|
||||
|
||||
$resultado =
|
||||
$equipoxusuario->obtenerSalaUsuario($idUsuario);
|
||||
|
||||
echo json_encode($resultado);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'salirDeSala':
|
||||
if (!isset($_SESSION['idUsuario'])) {
|
||||
echo json_encode(['error' => 'Usuario no autenticado']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$idUsuario = $_SESSION['idUsuario'];
|
||||
$respuesta = EquipoxUsuario::salirDeSala($idUsuario);
|
||||
|
||||
echo json_encode($respuesta);
|
||||
break;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once '../clases/ClasePregunta.php';
|
||||
require_once '../clases/ClaseRespuesta.php';
|
||||
|
||||
switch ($_POST['orden']) {
|
||||
|
||||
case 'crearPregunta':
|
||||
|
||||
$idCategoria = intval($_POST['idCategoria'] ?? 0);
|
||||
$nombrePregunta = trim($_POST['nombrePregunta'] ?? '');
|
||||
|
||||
$respuestaCorrecta = trim($_POST['respuestaCorrecta'] ?? '');
|
||||
$respuestaIncorrecta1 = trim($_POST['respuestaIncorrecta1'] ?? '');
|
||||
$respuestaIncorrecta2 = trim($_POST['respuestaIncorrecta2'] ?? '');
|
||||
$respuestaIncorrecta3 = trim($_POST['respuestaIncorrecta3'] ?? '');
|
||||
|
||||
// Comprobamos los datos
|
||||
if (
|
||||
$idCategoria <= 0 ||
|
||||
$nombrePregunta === '' ||
|
||||
$respuestaCorrecta === '' ||
|
||||
$respuestaIncorrecta1 === '' ||
|
||||
$respuestaIncorrecta2 === '' ||
|
||||
$respuestaIncorrecta3 === ''
|
||||
) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'La categoría, la pregunta y todas las respuestas son obligatorias.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ==========================================
|
||||
* 1. CREAMOS LA PREGUNTA
|
||||
* ==========================================
|
||||
*/
|
||||
|
||||
$pregunta = new Pregunta(
|
||||
$idCategoria,
|
||||
$nombrePregunta
|
||||
);
|
||||
|
||||
$resultadoPregunta = $pregunta->guardar();
|
||||
|
||||
|
||||
if (isset($resultadoPregunta['error'])) {
|
||||
|
||||
echo json_encode($resultadoPregunta);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Obtenemos el ID de la pregunta creada
|
||||
$idPregunta = (int)$resultadoPregunta['exito_tecnico'];
|
||||
|
||||
|
||||
/*
|
||||
* ==========================================
|
||||
* 2. CREAMOS LAS RESPUESTAS
|
||||
* ==========================================
|
||||
*/
|
||||
|
||||
$respuestas = [
|
||||
[
|
||||
'texto' => $respuestaCorrecta,
|
||||
'correcta' => 1
|
||||
],
|
||||
[
|
||||
'texto' => $respuestaIncorrecta1,
|
||||
'correcta' => 0
|
||||
],
|
||||
[
|
||||
'texto' => $respuestaIncorrecta2,
|
||||
'correcta' => 0
|
||||
],
|
||||
[
|
||||
'texto' => $respuestaIncorrecta3,
|
||||
'correcta' => 0
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
foreach ($respuestas as $respuesta) {
|
||||
|
||||
$objRespuesta = new Respuesta(
|
||||
null,
|
||||
$idPregunta,
|
||||
$respuesta['texto'],
|
||||
$respuesta['correcta']
|
||||
);
|
||||
|
||||
|
||||
$resultadoRespuesta = $objRespuesta->insertar();
|
||||
|
||||
|
||||
if (isset($resultadoRespuesta['error'])) {
|
||||
|
||||
echo json_encode($resultadoRespuesta);
|
||||
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ==========================================
|
||||
* 3. TODO CORRECTO
|
||||
* ==========================================
|
||||
*/
|
||||
|
||||
echo json_encode([
|
||||
'exito' => 'Pregunta creada correctamente.',
|
||||
'idPregunta' => $idPregunta
|
||||
]);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 'obtenerPreguntasPorCategoria':
|
||||
|
||||
$idCategoria = intval($_POST['idCategoria'] ?? 0);
|
||||
$limite = intval($_POST['limite'] ?? 10);
|
||||
|
||||
$preguntas = Pregunta::obtenerPorCategoria($idCategoria, $limite);
|
||||
|
||||
// Si ha devuelto un array de errores (formato ['error'=>...]) lo mandamos tal cual
|
||||
if (isset($preguntas['error'])) {
|
||||
echo json_encode($preguntas);
|
||||
break;
|
||||
}
|
||||
|
||||
// Convertimos cada objeto Pregunta en un array simple para poder mandarlo en JSON
|
||||
$listado = [];
|
||||
foreach ($preguntas as $p) {
|
||||
$listado[] = [
|
||||
'idPregunta' => $p->getIdPregunta(),
|
||||
'idCategoria' => $p->getIdCategoria(),
|
||||
'nombrePregunta' => $p->getNombrePregunta(),
|
||||
'respuestas' => $p->getRespuestas()
|
||||
];
|
||||
}
|
||||
|
||||
echo json_encode($listado);
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once '../clases/ClaseRespuesta.php';
|
||||
|
||||
switch ($_POST['orden']) {
|
||||
|
||||
case 'crearRespuesta':
|
||||
|
||||
$idPregunta = intval($_POST['idPregunta'] ?? 0);
|
||||
$nombreRespuesta = trim($_POST['nombreRespuesta'] ?? '');
|
||||
$correcta = intval($_POST['correcta'] ?? 0);
|
||||
|
||||
if ($idPregunta <= 0 || $nombreRespuesta == '') {
|
||||
echo json_encode(['error' => 'La pregunta y el texto de la respuesta son obligatorios']);
|
||||
break;
|
||||
}
|
||||
|
||||
$respuesta = new Respuesta(null, $idPregunta, $nombreRespuesta, $correcta);
|
||||
$resultado = $respuesta->insertar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'listarRespuestas':
|
||||
|
||||
$respuesta = new Respuesta();
|
||||
$resultado = $respuesta->listar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'listarRespuestasPorPregunta':
|
||||
|
||||
$idPregunta = intval($_POST['idPregunta'] ?? 0);
|
||||
|
||||
$respuesta = new Respuesta(null, $idPregunta);
|
||||
$resultado = $respuesta->listarPorPregunta();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'editarRespuesta':
|
||||
|
||||
$idRespuesta = intval($_POST['idRespuesta'] ?? 0);
|
||||
$idPregunta = intval($_POST['idPregunta'] ?? 0);
|
||||
$nombreRespuesta = trim($_POST['nombreRespuesta'] ?? '');
|
||||
$correcta = intval($_POST['correcta'] ?? 0);
|
||||
|
||||
$respuesta = new Respuesta($idRespuesta, $idPregunta, $nombreRespuesta, $correcta);
|
||||
$resultado = $respuesta->editar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
|
||||
case 'borrarRespuesta':
|
||||
|
||||
$idRespuesta = intval($_POST['idRespuesta'] ?? 0);
|
||||
|
||||
$respuesta = new Respuesta($idRespuesta);
|
||||
$resultado = $respuesta->eliminar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once '../clases/ClaseRespuestaAlmacenada.php';
|
||||
|
||||
switch ($_POST['orden']) {
|
||||
|
||||
case 'guardarRespuesta':
|
||||
|
||||
// Comprobamos que haya una sesión iniciada
|
||||
if (isset($_SESSION['idUsuario'])) {
|
||||
|
||||
$respuestaAlmacenada = new RespuestaAlmacenada();
|
||||
|
||||
// Recogemos los datos de la respuesta
|
||||
$respuestaAlmacenada->idPartidaxPregunta = $_POST['idPartidaxPregunta'];
|
||||
$respuestaAlmacenada->idUsuario = $_SESSION['idUsuario'];
|
||||
$respuestaAlmacenada->idRespuesta = $_POST['idRespuesta'];
|
||||
|
||||
// Guardamos la respuesta
|
||||
$respuesta = $respuestaAlmacenada->guardarRespuesta();
|
||||
|
||||
} else {
|
||||
|
||||
$respuesta = [
|
||||
'error' => 'No hay ninguna sesión iniciada.'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
echo json_encode($respuesta);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'obtenerAciertosUsuarioEnPartida':
|
||||
|
||||
// Comprobamos que haya una sesión iniciada
|
||||
if (isset($_SESSION['idUsuario'])) {
|
||||
|
||||
$idPartida = $_POST['idPartida'];
|
||||
$idUsuario = $_SESSION['idUsuario'];
|
||||
|
||||
// Obtenemos los aciertos del usuario en esa partida
|
||||
$respuesta = RespuestaAlmacenada::obtenerAciertosUsuarioEnPartida(
|
||||
$idPartida,
|
||||
$idUsuario
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
$respuesta = [
|
||||
'error' => 'No hay ninguna sesión iniciada.'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
echo json_encode($respuesta);
|
||||
|
||||
break;
|
||||
|
||||
}//fin switch
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,308 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once '../clases/ClaseUsuario.php';
|
||||
|
||||
switch ($_POST['orden']) {
|
||||
|
||||
case 'registrarUsuario':
|
||||
|
||||
$nombreUsuario = trim($_POST['nombreUsuario'] ?? '');
|
||||
$email = trim($_POST['email'] ?? '');
|
||||
$contrasena = $_POST['contrasena'] ?? '';
|
||||
|
||||
if ($nombreUsuario == '' || $email == '' || $contrasena == '') {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'Todos los campos son obligatorios'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$usuarioExistente = Usuario::buscarPorEmail($email);
|
||||
|
||||
if ($usuarioExistente instanceof Usuario) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'Ya existe una cuenta con ese correo electrónico'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$usuario = new Usuario(
|
||||
$nombreUsuario,
|
||||
$contrasena,
|
||||
$email,
|
||||
'img/avatars/defaultProfile.jpeg'
|
||||
);
|
||||
|
||||
$resultado = $usuario->registrar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'comprobarUsuario':
|
||||
|
||||
$email = trim($_POST['email'] ?? '');
|
||||
$contrasena = $_POST['contrasena'] ?? '';
|
||||
$recuerdame = isset($_POST['recuerdame']) && ($_POST['recuerdame'] === 'true' || $_POST['recuerdame'] === true);
|
||||
|
||||
$resultado = Usuario::login($email, $contrasena);
|
||||
|
||||
if ($resultado instanceof Usuario) {
|
||||
|
||||
// Guardamos la sesión
|
||||
$_SESSION['idUsuario'] = $resultado->getIdUsuario();
|
||||
$_SESSION['nombreUsuario'] = $resultado->getNombreUsuario();
|
||||
$_SESSION['email'] = $resultado->getEmail();
|
||||
$_SESSION['avatar'] = $resultado->getAvatar();
|
||||
|
||||
// Si ha marcado "Recuérdame durante 10 días"
|
||||
if ($recuerdame) {
|
||||
$token = bin2hex(random_bytes(32)); // Token único de 64 caracteres
|
||||
$duracion = time() + (10 * 24 * 60 * 60); // 10 días
|
||||
setcookie('recuerdame_token', $token, $duracion, "/");
|
||||
Usuario::guardarCookieToken($resultado->getIdUsuario(), $token);
|
||||
} else {
|
||||
// Si entra sin marcar recuérdame, limpiamos la cookie
|
||||
if (isset($_COOKIE['recuerdame_token'])) {
|
||||
setcookie('recuerdame_token', '', time() - 3600, "/");
|
||||
}
|
||||
Usuario::guardarCookieToken($resultado->getIdUsuario(), null);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'exito' => 'Login correcto',
|
||||
'idUsuario' => $resultado->getIdUsuario(),
|
||||
'nombreUsuario' => $resultado->getNombreUsuario(),
|
||||
'avatar' => $resultado->getAvatar()
|
||||
]);
|
||||
} else {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'Usuario o contraseña incorrectos'
|
||||
]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'cerrarSesion':
|
||||
|
||||
// Si el usuario tenía token en la BD, lo eliminamos
|
||||
if (isset($_SESSION['idUsuario'])) {
|
||||
Usuario::guardarCookieToken($_SESSION['idUsuario'], null);
|
||||
}
|
||||
|
||||
// Borramos la cookie del navegador
|
||||
if (isset($_COOKIE['recuerdame_token'])) {
|
||||
setcookie('recuerdame_token', '', time() - 3600, "/");
|
||||
}
|
||||
|
||||
// Limpiamos las variables de sesión
|
||||
unset($_SESSION['idUsuario']);
|
||||
unset($_SESSION['email']);
|
||||
unset($_SESSION['nombreUsuario']);
|
||||
unset($_SESSION['avatar']);
|
||||
|
||||
// Destruimos la sesión
|
||||
session_destroy();
|
||||
|
||||
echo json_encode([
|
||||
'exito' => 'Sesión cerrada'
|
||||
]);
|
||||
|
||||
break;
|
||||
|
||||
case 'mostrarEstadisticas':
|
||||
|
||||
$usuario = Usuario::buscarPorId($_SESSION['idUsuario']);
|
||||
|
||||
if ($usuario instanceof Usuario) {
|
||||
|
||||
echo json_encode([
|
||||
'victorias' => $usuario->getVictorias(),
|
||||
'derrotas' => $usuario->getDerrotas(),
|
||||
'aciertos' => $usuario->getAciertos()
|
||||
]);
|
||||
} else {
|
||||
|
||||
echo json_encode($usuario);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'cambiarNombre':
|
||||
|
||||
if (!isset($_SESSION['idUsuario'])) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'No hay ningún usuario conectado.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$nuevoNombre = trim($_POST['nombreUsuario'] ?? '');
|
||||
|
||||
if ($nuevoNombre === '') {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'El nombre no puede estar vacío.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$usuario = Usuario::buscarPorId($_SESSION['idUsuario']);
|
||||
|
||||
if (!($usuario instanceof Usuario)) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'No se encontró el usuario.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$resultado = $usuario->cambiarNombre($nuevoNombre);
|
||||
|
||||
if (isset($resultado['error'])) {
|
||||
|
||||
echo json_encode($resultado);
|
||||
} else {
|
||||
|
||||
// Actualizamos también la sesión
|
||||
$_SESSION['nombreUsuario'] = $nuevoNombre;
|
||||
|
||||
echo json_encode([
|
||||
'exito' => 'Nombre actualizado correctamente.',
|
||||
'nombreUsuario' => $nuevoNombre
|
||||
]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'cambiarAvatar':
|
||||
|
||||
if (!isset($_SESSION['idUsuario'])) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'No hay ningún usuario conectado.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isset($_FILES['avatar']) || $_FILES['avatar']['error'] !== UPLOAD_ERR_OK) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'No se ha recibido ninguna imagen.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$archivo = $_FILES['avatar'];
|
||||
|
||||
$tipo = mime_content_type($archivo['tmp_name']);
|
||||
|
||||
$tiposPermitidos = [
|
||||
'image/jpeg',
|
||||
'image/png',
|
||||
'image/gif',
|
||||
'image/webp'
|
||||
];
|
||||
|
||||
if (!in_array($tipo, $tiposPermitidos)) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'El formato de imagen no es válido.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$usuario = Usuario::buscarPorId($_SESSION['idUsuario']);
|
||||
|
||||
if (!($usuario instanceof Usuario)) {
|
||||
|
||||
echo json_encode([
|
||||
'error' => 'No se encontró el usuario.'
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$resultado = $usuario->cambiarAvatar($archivo);
|
||||
|
||||
if (isset($resultado['error'])) {
|
||||
|
||||
echo json_encode($resultado);
|
||||
} else {
|
||||
|
||||
// Actualizamos también la sesión
|
||||
$_SESSION['avatar'] = $resultado['avatar'];
|
||||
|
||||
echo json_encode($resultado);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'obtenerRanking':
|
||||
$ranking = Usuario::obtenerRanking(5); //Cambiar para mostrar X jugadores en index
|
||||
echo json_encode([
|
||||
'exito' => true,
|
||||
'ranking' => $ranking
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'comprobarSesion':
|
||||
|
||||
//Si hay sesión:
|
||||
|
||||
if (isset($_SESSION['idUsuario']) && !empty($_SESSION['idUsuario'])) {
|
||||
echo json_encode([
|
||||
'activa' => true,
|
||||
'usuario' => [
|
||||
'idUsuario' => $_SESSION['idUsuario'],
|
||||
'nombreUsuario' => $_SESSION['nombreUsuario'] ?? '',
|
||||
'avatar' => $_SESSION['avatar'] ?? ''
|
||||
]
|
||||
]);
|
||||
break;
|
||||
}
|
||||
|
||||
// Si no hay sesión, comprobamos si hay cookie:
|
||||
|
||||
if (isset($_COOKIE['recuerdame_token'])) {
|
||||
$usuarioCookie = Usuario::buscarPorCookie($_COOKIE['recuerdame_token']);
|
||||
|
||||
if ($usuarioCookie instanceof Usuario) {
|
||||
|
||||
$_SESSION['idUsuario'] = $usuarioCookie->getIdUsuario();
|
||||
$_SESSION['email'] = $usuarioCookie->getEmail();
|
||||
$_SESSION['nombreUsuario'] = $usuarioCookie->getNombreUsuario();
|
||||
$_SESSION['avatar'] = $usuarioCookie->getAvatar();
|
||||
|
||||
echo json_encode([
|
||||
'activa' => true,
|
||||
'usuario' => [
|
||||
'idUsuario' => $usuarioCookie->getIdUsuario(),
|
||||
'nombreUsuario' => $usuarioCookie->getNombreUsuario(),
|
||||
'avatar' => $usuarioCookie->getAvatar()
|
||||
]
|
||||
]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//No hay sesión ni hay cookie:
|
||||
echo json_encode(['activa' => false]);
|
||||
break;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
.btn-crear-sala {
|
||||
width: auto;
|
||||
min-width: 280px;
|
||||
padding: 18px 35px;
|
||||
font-size: 1.6rem;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.sala {
|
||||
background-color: white;
|
||||
border-radius: 20px;
|
||||
border: none;
|
||||
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.sala-header {
|
||||
background-color: var(--kahoot-purple);
|
||||
color: white;
|
||||
padding: 15px 20px;
|
||||
font-weight: 700;
|
||||
font-size: 1.2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sala-body {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.equipos {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.equipo {
|
||||
width: 50%;
|
||||
padding: 15px;
|
||||
border-radius: 15px;
|
||||
background-color: #f7f7f7;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.equipo h6 {
|
||||
text-align: center;
|
||||
font-weight: 700;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.jugadores {
|
||||
flex-grow: 1;
|
||||
min-height: 80px;
|
||||
}
|
||||
|
||||
.jugador {
|
||||
background-color: white;
|
||||
border-radius: 10px;
|
||||
padding: 7px 10px;
|
||||
margin-bottom: 6px;
|
||||
font-size: 0.9rem;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.avatar {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.btn-unirse {
|
||||
border: none;
|
||||
border-bottom: 3px solid #0c4891;
|
||||
background-color: var(--kahoot-blue);
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
border-radius: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.btn-unirse:hover {
|
||||
background-color: #0f56ab;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.input-kahoot {
|
||||
border: 2px solid #ddd;
|
||||
border-radius: 10px;
|
||||
padding: 10px 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.input-kahoot:focus {
|
||||
border-color: var(--kahoot-purple);
|
||||
box-shadow: 0 0 0 3px rgba(70, 23, 143, 0.15);
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
:root {
|
||||
--kahoot-purple: #46178f;
|
||||
--kahoot-blue: #1368ce;
|
||||
--kahoot-red: #e21b3c;
|
||||
--kahoot-yellow: #ffa602;
|
||||
--kahoot-green: #26890c;
|
||||
--kahoot-green-hover: #1f6f09;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Fredoka', sans-serif;
|
||||
background-color: #f2f2f2;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.navbar-kahoot {
|
||||
background-color: var(--kahoot-purple);
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-weight: 700;
|
||||
font-size: 1.8rem;
|
||||
color: #fff !important;
|
||||
letter-spacing: 1px;
|
||||
text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.btn-kahoot-login {
|
||||
background-color: var(--kahoot-blue);
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
border-bottom: 4px solid #0c4891;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-kahoot-login:hover {
|
||||
background-color: #0f56ab;
|
||||
color: white;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.btn-kahoot-register {
|
||||
background-color: var(--kahoot-green);
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
border-bottom: 4px solid var(--kahoot-green-hover);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-kahoot-register:hover {
|
||||
background-color: #2bb00f;
|
||||
color: white;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.user-dropdown-btn {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
border: 2px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 50px;
|
||||
padding: 8px 18px;
|
||||
font-weight: 600;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.user-dropdown-btn:hover,
|
||||
.user-dropdown-btn:focus,
|
||||
.user-dropdown-btn.show {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
color: white;
|
||||
border-color: #fff;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.user-dropdown-menu {
|
||||
border-radius: 15px;
|
||||
border: none;
|
||||
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
||||
padding: 10px;
|
||||
min-width: 200px;
|
||||
margin-top: 10px !important;
|
||||
}
|
||||
|
||||
.user-dropdown-menu .dropdown-item {
|
||||
border-radius: 10px;
|
||||
font-weight: 600;
|
||||
padding: 10px 15px;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.user-dropdown-menu .dropdown-item:hover {
|
||||
background-color: #f0eafb;
|
||||
color: var(--kahoot-purple);
|
||||
}
|
||||
|
||||
.user-dropdown-menu .dropdown-item.logout-item {
|
||||
color: var(--kahoot-red);
|
||||
}
|
||||
|
||||
.user-dropdown-menu .dropdown-item.logout-item:hover {
|
||||
background-color: #fde8ea;
|
||||
color: var(--kahoot-red);
|
||||
}
|
||||
|
||||
.btn-play-kahoot {
|
||||
background-color: var(--kahoot-green);
|
||||
color: white;
|
||||
font-size: 2.2rem;
|
||||
font-weight: 700;
|
||||
width: 100%;
|
||||
padding: 30px 20px;
|
||||
border-radius: 20px;
|
||||
border: none;
|
||||
border-bottom: 8px solid var(--kahoot-green-hover);
|
||||
box-shadow: 0 8px 15px rgba(0,0,0,0.2);
|
||||
transition: all 0.1s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.btn-play-kahoot:hover {
|
||||
background-color: #2bb00f;
|
||||
color: white;
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 12px 20px rgba(0,0,0,0.25);
|
||||
}
|
||||
|
||||
.btn-play-kahoot:active {
|
||||
transform: translateY(4px);
|
||||
border-bottom: 2px solid var(--kahoot-green-hover);
|
||||
}
|
||||
|
||||
.ranking-card {
|
||||
border-radius: 20px;
|
||||
border: none;
|
||||
box-shadow: 0 8px 20px rgba(0,0,0,0.08);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ranking-header {
|
||||
background-color: var(--kahoot-yellow);
|
||||
color: #333;
|
||||
padding: 15px 20px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.trophy-icon {
|
||||
font-size: 3rem;
|
||||
color: var(--kahoot-yellow);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* Estilos modales */
|
||||
.modal-content {
|
||||
border-radius: 20px;
|
||||
overflow: hidden;
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #f2f2f2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
justify-content: space-between;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* Área de la Pregunta */
|
||||
.question-container {
|
||||
background-color: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
flex-grow: 0;
|
||||
}
|
||||
|
||||
/* Cuadrícula de Respuestas */
|
||||
.answers-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 15px;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
/* Botones de Respuesta Básicos */
|
||||
.btn-answer {
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
color: white;
|
||||
font-size: 22px;
|
||||
font-weight: bold;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 20px;
|
||||
cursor: pointer;
|
||||
transition: transform 0.1s ease, filter 0.1s ease;
|
||||
box-shadow: 0 6px 0 rgba(0,0,0,0.2);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.btn-answer:active {
|
||||
transform: translateY(4px);
|
||||
box-shadow: 0 2px 0 rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
/* Variaciones de Color y Formas */
|
||||
.red {
|
||||
background-color: #e21b3c;
|
||||
}
|
||||
.red:hover { filter: brightness(1.1); }
|
||||
|
||||
.blue {
|
||||
background-color: #1368ce;
|
||||
}
|
||||
.blue:hover { filter: brightness(1.1); }
|
||||
|
||||
.yellow {
|
||||
background-color: #d89e00;
|
||||
}
|
||||
.yellow:hover { filter: brightness(1.1); }
|
||||
|
||||
.green {
|
||||
background-color: #26890c;
|
||||
}
|
||||
.green:hover { filter: brightness(1.1); }
|
||||
|
||||
/* Iconos Geométricos Simulados con CSS */
|
||||
.shape {
|
||||
display: inline-block;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-right: 20px;
|
||||
flex-shrink: 0;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.triangle {
|
||||
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
|
||||
}
|
||||
|
||||
.diamond {
|
||||
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
|
||||
}
|
||||
|
||||
.circle {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.square {
|
||||
/* Por defecto es un cuadrado */
|
||||
}
|
||||
|
||||
/* Adaptabilidad para Móviles */
|
||||
@media (max-width: 768px) {
|
||||
.answers-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.question-container {
|
||||
font-size: 20px;
|
||||
padding: 20px;
|
||||
}
|
||||
.btn-answer {
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
+403
@@ -0,0 +1,403 @@
|
||||
/* ========================================= */
|
||||
/* PERFIL */
|
||||
/* ========================================= */
|
||||
|
||||
.perfil-container {
|
||||
width: 100%;
|
||||
max-width: 1050px;
|
||||
|
||||
margin: 0 auto;
|
||||
|
||||
padding: 40px 20px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* TARJETA DEL PERFIL */
|
||||
/* ========================================= */
|
||||
|
||||
.perfil-card {
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 20px;
|
||||
|
||||
box-shadow:
|
||||
0 8px 20px rgba(0, 0, 0, 0.08);
|
||||
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* CABECERA DEL PERFIL */
|
||||
/* ========================================= */
|
||||
|
||||
.perfil-header {
|
||||
background-color: var(--kahoot-purple);
|
||||
|
||||
color: white;
|
||||
|
||||
padding: 20px;
|
||||
|
||||
text-align: center;
|
||||
|
||||
font-size: 2rem;
|
||||
|
||||
font-weight: 700;
|
||||
|
||||
text-shadow:
|
||||
2px 2px 0 rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* CONTENIDO */
|
||||
/* ========================================= */
|
||||
|
||||
.perfil-content {
|
||||
padding: 45px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* NOMBRE */
|
||||
/* ========================================= */
|
||||
|
||||
.nombre {
|
||||
color: var(--kahoot-purple);
|
||||
|
||||
font-size: 2.5rem;
|
||||
|
||||
font-weight: 700;
|
||||
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* FOTO */
|
||||
/* ========================================= */
|
||||
|
||||
.foto-container {
|
||||
position: relative;
|
||||
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
|
||||
.avatar {
|
||||
width: 180px;
|
||||
height: 180px;
|
||||
|
||||
object-fit: cover;
|
||||
|
||||
border: 6px solid white;
|
||||
|
||||
box-shadow:
|
||||
0 5px 15px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* BOTÓN CAMBIAR FOTO */
|
||||
/* ========================================= */
|
||||
|
||||
.btn-foto {
|
||||
position: absolute;
|
||||
|
||||
right: -5px;
|
||||
bottom: 5px;
|
||||
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
|
||||
border: none;
|
||||
|
||||
border-radius: 50%;
|
||||
|
||||
background-color: var(--kahoot-blue);
|
||||
|
||||
color: white;
|
||||
|
||||
border-bottom: 5px solid #0c4891;
|
||||
|
||||
font-size: 24px;
|
||||
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
|
||||
.btn-foto:hover {
|
||||
background-color: #0f56ab;
|
||||
|
||||
color: white;
|
||||
|
||||
transform: translateY(-3px);
|
||||
|
||||
box-shadow:
|
||||
0 5px 10px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
|
||||
.btn-foto:active {
|
||||
transform: translateY(3px);
|
||||
|
||||
border-bottom: 2px solid #0c4891;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* FORMULARIO NOMBRE */
|
||||
/* ========================================= */
|
||||
|
||||
.formulario-nombre {
|
||||
background-color: #f2f2f2;
|
||||
|
||||
border-radius: 20px;
|
||||
|
||||
padding: 20px;
|
||||
|
||||
max-width: 400px;
|
||||
|
||||
margin: 25px auto 0;
|
||||
|
||||
box-shadow:
|
||||
0 5px 12px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
|
||||
.formulario-nombre label {
|
||||
color: var(--kahoot-purple);
|
||||
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* INPUT */
|
||||
/* ========================================= */
|
||||
|
||||
.formulario-nombre .form-control {
|
||||
border-radius: 12px;
|
||||
|
||||
padding: 11px 15px;
|
||||
|
||||
border: 2px solid #ddd;
|
||||
}
|
||||
|
||||
|
||||
.formulario-nombre .form-control:focus {
|
||||
border-color: var(--kahoot-blue);
|
||||
|
||||
box-shadow:
|
||||
0 0 0 3px rgba(19, 104, 206, 0.15);
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* BOTÓN CAMBIAR NOMBRE */
|
||||
/* ========================================= */
|
||||
|
||||
.btn-perfil-cambiar {
|
||||
background-color: var(--kahoot-green);
|
||||
|
||||
color: white;
|
||||
|
||||
font-weight: 700;
|
||||
|
||||
border: none;
|
||||
|
||||
border-bottom: 5px solid var(--kahoot-green-hover);
|
||||
|
||||
border-radius: 12px;
|
||||
|
||||
padding: 10px 18px;
|
||||
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
|
||||
.btn-perfil-cambiar:hover {
|
||||
background-color: #2bb00f;
|
||||
|
||||
color: white;
|
||||
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
|
||||
.btn-perfil-cambiar:active {
|
||||
transform: translateY(3px);
|
||||
|
||||
border-bottom-width: 2px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* BOTÓN BORRAR */
|
||||
/* ========================================= */
|
||||
|
||||
.btn-perfil-borrar {
|
||||
background-color: var(--kahoot-red);
|
||||
|
||||
color: white;
|
||||
|
||||
font-weight: 700;
|
||||
|
||||
border: none;
|
||||
|
||||
border-bottom: 5px solid #a9142d;
|
||||
|
||||
border-radius: 12px;
|
||||
|
||||
padding: 10px 18px;
|
||||
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
|
||||
.btn-perfil-borrar:hover {
|
||||
background-color: #c91635;
|
||||
|
||||
color: white;
|
||||
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
|
||||
.btn-perfil-borrar:active {
|
||||
transform: translateY(3px);
|
||||
|
||||
border-bottom-width: 2px;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* ESTADÍSTICAS */
|
||||
/* ========================================= */
|
||||
|
||||
.estadisticas {
|
||||
background-color: var(--kahoot-purple);
|
||||
|
||||
color: white;
|
||||
|
||||
border-radius: 20px;
|
||||
|
||||
padding: 30px;
|
||||
|
||||
min-height: 350px;
|
||||
|
||||
box-shadow:
|
||||
0 8px 20px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
|
||||
.estadisticas h2 {
|
||||
font-size: 2rem;
|
||||
|
||||
font-weight: 700;
|
||||
|
||||
text-align: center;
|
||||
|
||||
margin-bottom: 30px;
|
||||
|
||||
text-shadow:
|
||||
2px 2px 0 rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* ESTADÍSTICAS INDIVIDUALES */
|
||||
/* ========================================= */
|
||||
|
||||
.estadistica {
|
||||
display: flex;
|
||||
|
||||
justify-content: space-between;
|
||||
|
||||
align-items: center;
|
||||
|
||||
border-radius: 12px;
|
||||
|
||||
padding: 15px;
|
||||
|
||||
margin-bottom: 15px;
|
||||
|
||||
font-size: 1.2rem;
|
||||
|
||||
font-weight: 600;
|
||||
|
||||
box-shadow:
|
||||
0 4px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
|
||||
.estadistica-victorias {
|
||||
background-color: var(--kahoot-green);
|
||||
}
|
||||
|
||||
|
||||
.estadistica-derrotas {
|
||||
background-color: var(--kahoot-red);
|
||||
}
|
||||
|
||||
|
||||
.estadistica-aciertos {
|
||||
background-color: var(--kahoot-yellow);
|
||||
|
||||
color: #333;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================= */
|
||||
/* RESPONSIVE */
|
||||
/* ========================================= */
|
||||
|
||||
@media (max-width: 768px) {
|
||||
|
||||
.perfil-container {
|
||||
padding: 25px 15px;
|
||||
}
|
||||
|
||||
|
||||
.perfil-content {
|
||||
padding: 30px 20px;
|
||||
}
|
||||
|
||||
|
||||
.nombre {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
|
||||
.avatar {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
|
||||
.estadisticas {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
|
||||
.formulario-nombre {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.btn-perfil-cambiar,
|
||||
.btn-perfil-borrar {
|
||||
padding: 9px 12px;
|
||||
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 8.6 KiB |
@@ -1,12 +1,54 @@
|
||||
<?php
|
||||
include 'cabecera.php';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="es-ES">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Proyecto Trivial</title>
|
||||
<title>Triviagmático</title>
|
||||
<script src="js/jquery-4.0.0.min.js"></script>
|
||||
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<div class="container my-5">
|
||||
<div class="row justify-content-center align-items-center g-4">
|
||||
|
||||
<!-- Botón Jugar (oculto por defecto, JS lo muestra si hay sesión) -->
|
||||
<div class="col-12 col-lg-5 col-xl-4 d-none" id="colBotonJugar">
|
||||
<a href="buscadorSala.php" class="btn btn-play-kahoot" id="btnJugar">
|
||||
<i class="fa-solid fa-play"></i>
|
||||
<span>¡JUGAR!</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Ranking -->
|
||||
<div class="col-12 col-lg-8" id="colRanking">
|
||||
<div class="card ranking-card">
|
||||
<div class="ranking-header">
|
||||
<h3 class="m-0"><i class="fa-solid fa-trophy me-2"></i> RANKING GLOBAL DE JUGADORES</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<!-- Div datos de ranking -->
|
||||
<div id="ranking-container" class="ranking-placeholder text-center p-4">
|
||||
<i class="fa-solid fa-medal trophy-icon"></i>
|
||||
<h4 class="fw-bold text-secondary">Cargando clasificación...</h4>
|
||||
<p class="text-muted mb-0">Los mejores equipos y jugadores aparecerán aquí pronto.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- JS de Bootstrap -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="js/index.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,380 @@
|
||||
let usuarioYaEstaEnEquipo = false;
|
||||
|
||||
$(document).ready(function () {
|
||||
comprobarSalaUsuario();
|
||||
});
|
||||
|
||||
// 1. Comprobar si el usuario actual ya pertenece a una sala
|
||||
function comprobarSalaUsuario() {
|
||||
$("#cargandoSalas").remove();
|
||||
|
||||
$.ajax({
|
||||
url: "controladores/ControladorEquipoxUsuario.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { orden: "obtenerSalaUsuario" },
|
||||
success: function (respuesta) {
|
||||
if (respuesta.error || !respuesta.asociado) {
|
||||
usuarioYaEstaEnEquipo = false;
|
||||
$("#contenedorCrearSala").show();
|
||||
cargarSalas();
|
||||
} else {
|
||||
usuarioYaEstaEnEquipo = true;
|
||||
$("#contenedorCrearSala").hide(); // Ocultar "Crear Sala" si ya pertenece a una
|
||||
cargarSalaUsuario(respuesta.idPartida);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error al comprobar la sala del usuario:", error);
|
||||
usuarioYaEstaEnEquipo = false;
|
||||
cargarSalas();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 2. Cargar únicamente la sala en la que está metido el usuario
|
||||
function cargarSalaUsuario(idPartida) {
|
||||
$.ajax({
|
||||
url: "controladores/controladorPartida.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { orden: "buscar", idPartida: idPartida },
|
||||
success: function (partida) {
|
||||
if (partida.error) {
|
||||
console.error(partida.error);
|
||||
return;
|
||||
}
|
||||
$("#contenedorSalas").empty();
|
||||
cargarInformacionSala(partida);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error al obtener la sala del usuario:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 3. Cargar la lista completa de todas las salas
|
||||
function cargarSalas() {
|
||||
$.ajax({
|
||||
url: "controladores/controladorPartida.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { orden: "listar" },
|
||||
success: function (partidas) {
|
||||
const contenedor = $("#contenedorSalas");
|
||||
contenedor.empty();
|
||||
|
||||
if (!Array.isArray(partidas) || partidas.length === 0) {
|
||||
contenedor.html(`
|
||||
<div class="col-12 text-center">
|
||||
<p class="text-muted">No hay salas disponibles actualmente.</p>
|
||||
</div>
|
||||
`);
|
||||
return;
|
||||
}
|
||||
|
||||
partidas.forEach(function (partida) {
|
||||
cargarInformacionSala(partida);
|
||||
});
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error al obtener las partidas:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 4. Obtener equipos y jugadores asociados a una sala concreta
|
||||
function cargarInformacionSala(partida) {
|
||||
$.ajax({
|
||||
url: "controladores/controladorPartida.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { orden: "getEquipos", idPartida: partida.idPartida },
|
||||
success: function (equipos) {
|
||||
$.ajax({
|
||||
url: "controladores/controladorPartida.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { orden: "getJugadores", idPartida: partida.idPartida },
|
||||
success: function (jugadores) {
|
||||
mostrarSala(partida, equipos, jugadores);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error al obtener jugadores:", error);
|
||||
},
|
||||
});
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error al obtener equipos:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 5. Renderizar el HTML de la sala y botones según estado
|
||||
function mostrarSala(partida, equipos, jugadores) {
|
||||
const contenedor = $("#contenedorSalas");
|
||||
let equiposHTML = "";
|
||||
|
||||
equipos.forEach(function (equipo) {
|
||||
const jugadoresEquipo = jugadores.filter(function (jugador) {
|
||||
return jugador.idEquipo == equipo.idEquipo;
|
||||
});
|
||||
|
||||
let jugadoresHTML = "";
|
||||
if (jugadoresEquipo.length > 0) {
|
||||
jugadoresEquipo.forEach(function (jugador) {
|
||||
jugadoresHTML += `
|
||||
<div class="jugador">
|
||||
<span class="avatar">👤</span>
|
||||
${escapeHTML(jugador.nombreUsuario)}
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
} else {
|
||||
jugadoresHTML = `<div class="text-muted small">Sin jugadores</div>`;
|
||||
}
|
||||
|
||||
// Botón "Unirse" solo visible si NO pertenece a ningún equipo
|
||||
let botonUnirseHTML = "";
|
||||
if (!usuarioYaEstaEnEquipo) {
|
||||
botonUnirseHTML = `
|
||||
<button type="button" class="btn btn-unirse w-100 btn-unirse-equipo mt-2"
|
||||
data-id-partida="${partida.idPartida}"
|
||||
data-id-equipo="${equipo.idEquipo}">
|
||||
Unirse
|
||||
</button>
|
||||
`;
|
||||
}
|
||||
|
||||
equiposHTML += `
|
||||
<div class="equipo me-2 ms-2 p-3 border rounded">
|
||||
<h6>${escapeHTML(equipo.nombreEquipo)}</h6>
|
||||
<div class="jugadores mb-2">
|
||||
${jugadoresHTML}
|
||||
</div>
|
||||
${botonUnirseHTML}
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
// Acciones disponibles si el usuario YA ESTÁ dentro de esta sala
|
||||
let accionesSalaHTML = "";
|
||||
if (usuarioYaEstaEnEquipo) {
|
||||
accionesSalaHTML = `
|
||||
<div class="sala-acciones text-center mt-4 pt-3 border-top d-flex justify-content-center gap-3">
|
||||
<button type="button" class="btn btn-outline-danger btn-abandonar-sala" data-id-partida="${partida.idPartida}">
|
||||
Abandonar sala
|
||||
</button>
|
||||
<a href="juego.php?idPartida=${partida.idPartida}" class="btn btn-success btn-lg px-4">
|
||||
🎮 ¡Iniciar Partida!
|
||||
</a>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
const salaHTML = `
|
||||
<div class="col-12 col-md-10 col-lg-8">
|
||||
<div class="sala card p-3 shadow-sm mb-4">
|
||||
<div class="sala-header h4 text-center mb-3">
|
||||
${escapeHTML(partida.nombrePartida)}
|
||||
</div>
|
||||
<div class="sala-body">
|
||||
<div class="equipos d-flex justify-content-around">
|
||||
${equiposHTML}
|
||||
</div>
|
||||
${accionesSalaHTML}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
contenedor.append(salaHTML);
|
||||
}
|
||||
|
||||
// 6. Evento: Unirse a un Equipo
|
||||
$(document).on("click", ".btn-unirse-equipo", function () {
|
||||
const boton = $(this);
|
||||
const idEquipo = boton.data("id-equipo");
|
||||
const idPartida = boton.data("id-partida");
|
||||
|
||||
boton.prop("disabled", true).text("Uniéndose...");
|
||||
|
||||
$.ajax({
|
||||
url: "controladores/ControladorEquipoxUsuario.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {
|
||||
orden: "registrarUsuarioEnEquipo",
|
||||
idEquipo: idEquipo,
|
||||
},
|
||||
success: function (respuesta) {
|
||||
if (respuesta.error) {
|
||||
alert(respuesta.error);
|
||||
boton.prop("disabled", false).text("Unirse");
|
||||
return;
|
||||
}
|
||||
|
||||
usuarioYaEstaEnEquipo = true;
|
||||
$("#contenedorCrearSala").hide();
|
||||
$("#contenedorSalas").empty();
|
||||
cargarSalaUsuario(idPartida);
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error al unirse al equipo:", error);
|
||||
alert("No se ha podido unir al equipo.");
|
||||
boton.prop("disabled", false).text("Unirse");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// 7. Evento: Abandonar Sala
|
||||
// Guardamos temporalmente el botón presionado
|
||||
let botonAbandonarReferencia = null;
|
||||
|
||||
// A. Al hacer clic en el botón "Abandonar sala" de la tarjeta, abrimos el modal
|
||||
$(document).on("click", ".btn-abandonar-sala", function () {
|
||||
botonAbandonarReferencia = $(this);
|
||||
const modal = new bootstrap.Modal(document.getElementById('modalAbandonarSala'));
|
||||
modal.show();
|
||||
});
|
||||
|
||||
// B. Al hacer clic en "Sí, salir" dentro del modal Kahoot
|
||||
$(document).on("click", "#btnConfirmarAbandonar", function () {
|
||||
const modalEl = document.getElementById('modalAbandonarSala');
|
||||
const modalInstance = bootstrap.Modal.getInstance(modalEl);
|
||||
|
||||
const btnConfirmar = $(this);
|
||||
btnConfirmar.prop("disabled", true).text("Saliendo...");
|
||||
|
||||
$.ajax({
|
||||
url: "controladores/ControladorEquipoxUsuario.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: { orden: "salirDeSala" },
|
||||
success: function (respuesta) {
|
||||
btnConfirmar.prop("disabled", false).text("Sí, salir");
|
||||
|
||||
if (modalInstance) {
|
||||
modalInstance.hide();
|
||||
}
|
||||
|
||||
if (respuesta.error) {
|
||||
alert(respuesta.error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Restablecemos la interfaz a la lista completa de salas
|
||||
usuarioYaEstaEnEquipo = false;
|
||||
$("#contenedorCrearSala").show();
|
||||
cargarSalas();
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error al salir de la sala:", error);
|
||||
alert("No se pudo salir de la sala.");
|
||||
btnConfirmar.prop("disabled", false).text("Sí, salir");
|
||||
if (modalInstance) {
|
||||
modalInstance.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
// 8. Evento: Crear Sala
|
||||
$("#btnCrearSala").on("click", function () {
|
||||
const nombreSala = $("#nombreSala").val().trim();
|
||||
const nombreEquipo1 = $("#nombreEquipo1").val().trim();
|
||||
const nombreEquipo2 = $("#nombreEquipo2").val().trim();
|
||||
|
||||
let valido = true;
|
||||
$(".mensaje-error-sala").remove();
|
||||
$(".input-kahoot").removeClass("is-invalid");
|
||||
|
||||
if (nombreSala === "" || nombreSala.length < 3) {
|
||||
mostrarError(
|
||||
"#nombreSala",
|
||||
"El nombre de la sala debe tener al menos 3 caracteres.",
|
||||
);
|
||||
valido = false;
|
||||
}
|
||||
|
||||
if (nombreEquipo1 === "" || nombreEquipo1.length < 2) {
|
||||
mostrarError(
|
||||
"#nombreEquipo1",
|
||||
"El nombre del equipo debe tener al menos 2 caracteres.",
|
||||
);
|
||||
valido = false;
|
||||
}
|
||||
|
||||
if (nombreEquipo2 === "" || nombreEquipo2.length < 2) {
|
||||
mostrarError(
|
||||
"#nombreEquipo2",
|
||||
"El nombre del equipo debe tener al menos 2 caracteres.",
|
||||
);
|
||||
valido = false;
|
||||
}
|
||||
|
||||
if (
|
||||
nombreEquipo1 !== "" &&
|
||||
nombreEquipo2 !== "" &&
|
||||
nombreEquipo1.toLowerCase() === nombreEquipo2.toLowerCase()
|
||||
) {
|
||||
mostrarError(
|
||||
"#nombreEquipo2",
|
||||
"Los dos equipos deben tener nombres diferentes.",
|
||||
);
|
||||
valido = false;
|
||||
}
|
||||
|
||||
if (!valido) return;
|
||||
|
||||
const boton = $("#btnCrearSala");
|
||||
boton.prop("disabled", true).text("Creando sala...");
|
||||
|
||||
$.ajax({
|
||||
url: "controladores/controladorPartida.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {
|
||||
orden: "crear",
|
||||
nombrePartida: nombreSala,
|
||||
nombreEquipo1: nombreEquipo1,
|
||||
nombreEquipo2: nombreEquipo2,
|
||||
},
|
||||
success: function (respuesta) {
|
||||
if (respuesta.error) {
|
||||
alert(respuesta.error);
|
||||
boton.prop("disabled", false).text("Crear sala");
|
||||
return;
|
||||
}
|
||||
|
||||
if (respuesta.exito) {
|
||||
$("#modalCrearSala").modal("hide");
|
||||
location.reload();
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error al crear la sala:", error);
|
||||
alert("No se ha podido crear la sala.");
|
||||
boton.prop("disabled", false).text("Crear sala");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// Auxiliares
|
||||
function escapeHTML(texto) {
|
||||
return $("<div>")
|
||||
.text(texto ?? "")
|
||||
.html();
|
||||
}
|
||||
|
||||
function mostrarError(selector, mensaje) {
|
||||
const input = $(selector);
|
||||
input.addClass("is-invalid");
|
||||
input.after(
|
||||
`<div class="mensaje-error-sala text-danger mt-1 small">${mensaje}</div>`,
|
||||
);
|
||||
}
|
||||
|
||||
$(document).on("input", ".input-kahoot", function () {
|
||||
$(this).removeClass("is-invalid");
|
||||
$(this).next(".mensaje-error-sala").remove();
|
||||
});
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
$(document).ready(function () {
|
||||
comprobarSesion();
|
||||
});
|
||||
|
||||
// Función auxiliar para escapar texto HTML
|
||||
function escapeHTML(str) {
|
||||
return $("<div>")
|
||||
.text(str ?? "")
|
||||
.html();
|
||||
}
|
||||
|
||||
// Comprobar estado de sesión al cargar la página
|
||||
function comprobarSesion() {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: { orden: "comprobarSesion" },
|
||||
}).done(function (respuesta) {
|
||||
try {
|
||||
if (typeof respuesta === "string") {
|
||||
respuesta = JSON.parse(respuesta);
|
||||
}
|
||||
|
||||
const contenedor = $("#contenedorUsuarioCabecera");
|
||||
contenedor.empty();
|
||||
|
||||
if (respuesta.activa && respuesta.usuario) {
|
||||
// Obtenemos la ruta del avatar o la de por defecto
|
||||
const avatarUrl =
|
||||
respuesta.usuario.avatar || "img/avatars/defaultProfile.jpeg";
|
||||
|
||||
// Usuario autenticado: Mostrar Menú Dropdown con el avatar
|
||||
const htmlUsuario = `
|
||||
<div class="dropdown">
|
||||
<button class="btn user-dropdown-btn dropdown-toggle d-flex align-items-center gap-2"
|
||||
type="button" id="userDropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<img src="${escapeHTML(avatarUrl)}" alt="Avatar" class="rounded-circle" style="width: 32px; height: 32px; object-fit: cover;">
|
||||
<span>${escapeHTML(respuesta.usuario.nombreUsuario)}</span>
|
||||
</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">
|
||||
<i class="fa-solid fa-user text-primary"></i> Perfil
|
||||
</a>
|
||||
</li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li>
|
||||
<a class="dropdown-item logout-item d-flex align-items-center gap-2" href="#" id="botonCerrarSesion">
|
||||
<i class="fa-solid fa-right-from-bracket"></i> Cerrar Sesión
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
contenedor.html(htmlUsuario);
|
||||
|
||||
// Si estamos en la página principal, mostramos el botón JUGAR
|
||||
if ($("#colBotonJugar").length) {
|
||||
$("#colBotonJugar").removeClass("d-none");
|
||||
$("#colRanking")
|
||||
.removeClass("col-lg-8")
|
||||
.addClass("col-lg-7 col-xl-8");
|
||||
}
|
||||
} else {
|
||||
// No hay sesión: Mostrar botones de Login y Registro
|
||||
const htmlInvitado = `
|
||||
<button type="button" class="btn btn-kahoot-login rounded-pill px-4" data-bs-toggle="modal" data-bs-target="#modalLogin">
|
||||
<i class="fa-solid fa-right-to-bracket me-1"></i> Iniciar Sesión
|
||||
</button>
|
||||
<button type="button" class="btn btn-kahoot-register rounded-pill px-4" data-bs-toggle="modal" data-bs-target="#modalRegistro">
|
||||
<i class="fa-solid fa-user-plus me-1"></i> Registrarse
|
||||
</button>
|
||||
`;
|
||||
contenedor.html(htmlInvitado);
|
||||
|
||||
// Si estamos en la página principal, ocultamos el botón JUGAR
|
||||
if ($("#colBotonJugar").length) {
|
||||
$("#colBotonJugar").addClass("d-none");
|
||||
$("#colRanking")
|
||||
.removeClass("col-lg-7 col-xl-8")
|
||||
.addClass("col-lg-8");
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Error al procesar la respuesta de la sesión:", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Registro
|
||||
$("#botonAceptarRegistro").click(function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let nombreUsuario = $("#regNombre").val().trim();
|
||||
let email = $("#regEmail").val().trim();
|
||||
let contrasena = $("#regPassword").val();
|
||||
let contrasenaConfirmacion = $("#regPasswordConfirm").val();
|
||||
|
||||
$("#regNombre").removeClass("is-invalid");
|
||||
$("#regEmail").removeClass("is-invalid");
|
||||
$("#regPassword").removeClass("is-invalid");
|
||||
$("#regPasswordConfirm").removeClass("is-invalid");
|
||||
$("#errorRegistro").text("");
|
||||
|
||||
if (contrasena !== contrasenaConfirmacion) {
|
||||
$("#regPassword").addClass("is-invalid");
|
||||
$("#regPasswordConfirm").addClass("is-invalid");
|
||||
$("#errorRegistro").text("Las contraseñas no coinciden.");
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: {
|
||||
nombreUsuario: nombreUsuario,
|
||||
email: email,
|
||||
contrasena: contrasena,
|
||||
orden: "registrarUsuario",
|
||||
},
|
||||
}).done(function (respuesta) {
|
||||
if (typeof respuesta === "string") respuesta = JSON.parse(respuesta);
|
||||
|
||||
if (respuesta.error) {
|
||||
$("#errorRegistro").text(respuesta.error);
|
||||
$("#regNombre").addClass("is-invalid");
|
||||
$("#regEmail").addClass("is-invalid");
|
||||
} else {
|
||||
$("#errorRegistro")
|
||||
.removeClass("text-danger")
|
||||
.addClass("text-success")
|
||||
.text(respuesta.exito);
|
||||
|
||||
$("#formRegistro")[0].reset();
|
||||
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Login
|
||||
$("#botonAceptarLogin").click(function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let email = $("#loginEmail").val().trim();
|
||||
let contrasena = $("#loginPassword").val();
|
||||
let recuerdame = $("#recordar").is(":checked");
|
||||
|
||||
$("#loginEmail").removeClass("is-invalid");
|
||||
$("#loginPassword").removeClass("is-invalid");
|
||||
$("#errorLogin").text("");
|
||||
|
||||
if (email === "" || contrasena === "") {
|
||||
$("#errorLogin").text("Todos los campos son obligatorios.");
|
||||
if (email === "") $("#loginEmail").addClass("is-invalid");
|
||||
if (contrasena === "") $("#loginPassword").addClass("is-invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: {
|
||||
email: email,
|
||||
contrasena: contrasena,
|
||||
recuerdame: recuerdame,
|
||||
orden: "comprobarUsuario",
|
||||
},
|
||||
}).done(function (respuesta) {
|
||||
if (typeof respuesta === "string") respuesta = JSON.parse(respuesta);
|
||||
|
||||
if (respuesta.error) {
|
||||
$("#loginEmail").addClass("is-invalid");
|
||||
$("#loginPassword").addClass("is-invalid");
|
||||
$("#errorLogin").text(respuesta.error);
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Cerrar sesión
|
||||
$(document).on("click", "#botonCerrarSesion", function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: { orden: "cerrarSesion" },
|
||||
}).done(function (respuesta) {
|
||||
if (typeof respuesta === "string") respuesta = JSON.parse(respuesta);
|
||||
|
||||
if (respuesta.error) {
|
||||
console.log(respuesta.error);
|
||||
} else {
|
||||
window.location.href = "index.php";
|
||||
}
|
||||
});
|
||||
});
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
$(document).ready(function () {
|
||||
cargarRanking();
|
||||
});
|
||||
|
||||
function cargarRanking() {
|
||||
$.ajax({
|
||||
url: "controladores/controladorUsuario.php",
|
||||
type: "POST",
|
||||
data: { orden: "obtenerRanking" },
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
if (response.exito && response.ranking.length > 0) {
|
||||
renderizarTablaRanking(response.ranking);
|
||||
} else {
|
||||
$("#ranking-container").html(`
|
||||
<div class="alert alert-info my-3">
|
||||
<i class="fa-solid fa-info-circle me-2"></i>Aún no hay partidas registradas para mostrar el ranking.
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$("#ranking-container").html(`
|
||||
<div class="alert alert-danger my-3">
|
||||
<i class="fa-solid fa-exclamation-triangle me-2"></i>Error al cargar la clasificación.
|
||||
</div>
|
||||
`);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function renderizarTablaRanking(jugadores) {
|
||||
let html = `
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover align-middle mb-0 text-center">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th scope="col" style="width: 10%;">#</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>
|
||||
`;
|
||||
|
||||
jugadores.forEach((jugador, index) => {
|
||||
let posicion = index + 1;
|
||||
let medalla = "";
|
||||
|
||||
// Medallas para el Top 3
|
||||
if (posicion === 1) {
|
||||
medalla =
|
||||
'<i class="fa-solid fa-medal text-warning fa-lg" title="1º Puesto"></i>';
|
||||
} else if (posicion === 2) {
|
||||
medalla =
|
||||
'<i class="fa-solid fa-medal text-secondary fa-lg" title="2º Puesto"></i>';
|
||||
} else if (posicion === 3) {
|
||||
medalla =
|
||||
'<i class="fa-solid fa-medal text-brown fa-lg" style="color: #cd7f32;" title="3º Puesto"></i>';
|
||||
} else {
|
||||
medalla = `<span class="fw-bold text-muted">${posicion}</span>`;
|
||||
}
|
||||
|
||||
let avatarImg = jugador.avatar
|
||||
? jugador.avatar
|
||||
: "img/avatars/defaultProfile.jpeg";
|
||||
|
||||
html += `
|
||||
<tr>
|
||||
<td class="fw-bold fs-5">${medalla}</td>
|
||||
<td class="text-start fw-bold">
|
||||
<img src="${avatarImg}" alt="Avatar" class="rounded-circle me-2 border" style="width: 32px; height: 32px; object-fit: cover;">
|
||||
${escapeHtml(jugador.nombreUsuario)}
|
||||
</td>
|
||||
<td><span class="badge bg-success rounded-pill px-3 py-2 fs-6">${jugador.victorias}</span></td>
|
||||
<td><span class="badge bg-danger rounded-pill px-3 py-2 fs-6">${jugador.derrotas}</span></td>
|
||||
<td class="fw-bold text-primary fs-6">${jugador.aciertos}</td>
|
||||
<td>
|
||||
<span class="badge bg-info text-dark rounded-pill px-2 py-1">${jugador.porcentajeVictoria}%</span>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
html += `
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`;
|
||||
|
||||
$("#ranking-container")
|
||||
.removeClass("text-center p-4 ranking-placeholder")
|
||||
.html(html);
|
||||
}
|
||||
|
||||
function escapeHtml(texto) {
|
||||
return $("<div>").text(texto).html();
|
||||
}
|
||||
Vendored
+2
File diff suppressed because one or more lines are too long
@@ -0,0 +1,210 @@
|
||||
// ============================================
|
||||
// DATOS DE PRUEBA
|
||||
// ============================================
|
||||
|
||||
const salas = [
|
||||
{
|
||||
id: 1,
|
||||
nombre: "Sala Principal",
|
||||
equipos: [
|
||||
{
|
||||
id: 1,
|
||||
nombre: "Equipo 1",
|
||||
jugadores: [
|
||||
"Carlos",
|
||||
"María"
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
nombre: "Equipo 2",
|
||||
jugadores: [
|
||||
"Jorge"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
id: 2,
|
||||
nombre: "Los Trivialeros",
|
||||
equipos: [
|
||||
{
|
||||
id: 3,
|
||||
nombre: "Equipo Rojo",
|
||||
jugadores: [
|
||||
"Ana",
|
||||
"Pedro",
|
||||
"Lucía"
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
nombre: "Equipo Azul",
|
||||
jugadores: [
|
||||
"David",
|
||||
"Laura"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
id: 3,
|
||||
nombre: "Partida rápida",
|
||||
equipos: [
|
||||
{
|
||||
id: 5,
|
||||
nombre: "Equipo 1",
|
||||
jugadores: [
|
||||
"Miguel"
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
nombre: "Equipo 2",
|
||||
jugadores: []
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
id: 4,
|
||||
nombre: "Noche de Trivial",
|
||||
equipos: [
|
||||
{
|
||||
id: 7,
|
||||
nombre: "Los quesitos",
|
||||
jugadores: [
|
||||
"Pablo",
|
||||
"Sara"
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
nombre: "Los cerebritos",
|
||||
jugadores: [
|
||||
"Mario",
|
||||
"Elena",
|
||||
"Álvaro"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
// ============================================
|
||||
// MOSTRAR SALAS
|
||||
// ============================================
|
||||
|
||||
function mostrarSalas(salas) {
|
||||
|
||||
const contenedor = document.getElementById("contenedorSalas");
|
||||
|
||||
contenedor.innerHTML = "";
|
||||
|
||||
salas.forEach(sala => {
|
||||
|
||||
const columna = document.createElement("div");
|
||||
|
||||
columna.className = "col-12 col-md-6 col-xl-5";
|
||||
|
||||
|
||||
columna.innerHTML = `
|
||||
|
||||
<div class="sala">
|
||||
|
||||
<div class="sala-header">
|
||||
${sala.nombre}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="sala-body">
|
||||
|
||||
<div class="equipos">
|
||||
|
||||
${crearEquipo(sala, sala.equipos[0])}
|
||||
|
||||
${crearEquipo(sala, sala.equipos[1])}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
`;
|
||||
|
||||
contenedor.appendChild(columna);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ============================================
|
||||
// CREAR EQUIPO
|
||||
// ============================================
|
||||
|
||||
function crearEquipo(sala, equipo) {
|
||||
|
||||
let jugadoresHTML = "";
|
||||
|
||||
equipo.jugadores.forEach(jugador => {
|
||||
|
||||
jugadoresHTML += `
|
||||
<div class="jugador">
|
||||
<span class="avatar">👤</span>
|
||||
${jugador}
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
|
||||
return `
|
||||
|
||||
<div class="equipo">
|
||||
|
||||
<h6>
|
||||
${equipo.nombre}
|
||||
</h6>
|
||||
|
||||
<div class="jugadores">
|
||||
|
||||
${jugadoresHTML}
|
||||
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-unirse"
|
||||
onclick="unirseEquipo(${sala.id}, ${equipo.id})">
|
||||
|
||||
Unirse
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
`;
|
||||
}
|
||||
|
||||
function unirseEquipo(idSala, idEquipo) {
|
||||
|
||||
console.log("Sala:", idSala);
|
||||
console.log("Equipo:", idEquipo);
|
||||
|
||||
alert(
|
||||
"Has pulsado unirse al equipo " +
|
||||
idEquipo +
|
||||
" de la sala " +
|
||||
idSala
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ============================================
|
||||
// CARGAR DATOS DE PRUEBA
|
||||
// ============================================
|
||||
|
||||
mostrarSalas(salas);
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
// =========================
|
||||
// MOSTRAR ESTADISTICAS
|
||||
// =========================
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: {
|
||||
orden: "mostrarEstadisticas",
|
||||
},
|
||||
}).done(function (respuesta) {
|
||||
console.log(respuesta);
|
||||
respuesta = JSON.parse(respuesta);
|
||||
if (respuesta.error) {
|
||||
console.log(respuesta.error);
|
||||
} else {
|
||||
$("#victorias").text(respuesta.victorias);
|
||||
$("#derrotas").text(respuesta.derrotas);
|
||||
$("#aciertos").text(respuesta.aciertos);
|
||||
}
|
||||
});
|
||||
|
||||
// =========================
|
||||
// CAMBIAR NOMBRE
|
||||
// =========================
|
||||
function cambiarNombre() {
|
||||
let nuevoNombre = $("#nuevoNombre").val().trim();
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: {
|
||||
nombreUsuario: nuevoNombre,
|
||||
orden: "cambiarNombre",
|
||||
},
|
||||
}).done(function (respuesta) {
|
||||
console.log(respuesta);
|
||||
respuesta = JSON.parse(respuesta);
|
||||
if (respuesta.error) {
|
||||
console.log(respuesta.error);
|
||||
} else {
|
||||
// Actualizamos el nombre mostrado en la página
|
||||
$("#nombre").text(respuesta.nombreUsuario);
|
||||
|
||||
// Limpiamos el input
|
||||
$("#nuevoNombre").val("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// =========================
|
||||
// BORRAR NOMBRE
|
||||
// =========================
|
||||
|
||||
function borrarNombre() {
|
||||
document.getElementById("nuevoNombre").value = "";
|
||||
}
|
||||
|
||||
// =========================
|
||||
// CAMBIAR FOTO
|
||||
// =========================
|
||||
|
||||
function seleccionarFoto() {
|
||||
$("#inputFoto").click();
|
||||
}
|
||||
|
||||
$("#inputFoto").change(function () {
|
||||
let archivo = this.files[0];
|
||||
|
||||
if (!archivo) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprobamos que sea una imagen
|
||||
if (!archivo.type.startsWith("image/")) {
|
||||
alert("El archivo seleccionado no es una imagen.");
|
||||
|
||||
$("#inputFoto").val("");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let datos = new FormData();
|
||||
|
||||
datos.append("avatar", archivo);
|
||||
datos.append("orden", "cambiarAvatar");
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: datos,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
}).done(function (respuesta) {
|
||||
console.log(respuesta);
|
||||
respuesta = JSON.parse(respuesta);
|
||||
if (respuesta.error) {
|
||||
alert(respuesta.error);
|
||||
} else {
|
||||
// Actualizamos la imagen sin recargar la página
|
||||
$("#fotoPerfil").attr(
|
||||
"src",
|
||||
respuesta.avatar + "?t=" + new Date().getTime(),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// =========================
|
||||
// RECOGER CATEGORIAS
|
||||
// ====
|
||||
|
||||
$("#modalCrearPregunta").on("show.bs.modal", function () {
|
||||
const selectCategoria = $("#idCategoria");
|
||||
|
||||
// Limpiamos las categorías anteriores
|
||||
selectCategoria.empty();
|
||||
|
||||
// Opción inicial
|
||||
selectCategoria.append('<option value="">Selecciona una categoría</option>');
|
||||
|
||||
$.ajax({
|
||||
url: "controladores/controladorCategoria.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
|
||||
data: {
|
||||
orden: "listarCategorias",
|
||||
},
|
||||
|
||||
success: function (respuesta) {
|
||||
console.log("Categorías:", respuesta);
|
||||
|
||||
if (respuesta.error) {
|
||||
alert(respuesta.error);
|
||||
return;
|
||||
}
|
||||
|
||||
$.each(respuesta, function (index, categoria) {
|
||||
selectCategoria.append(
|
||||
$("<option>", {
|
||||
value: categoria.idCategoria,
|
||||
text: categoria.nombreCategoria,
|
||||
}),
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error al cargar las categorías:", error);
|
||||
|
||||
console.error("Respuesta del servidor:", xhr.responseText);
|
||||
|
||||
alert("No se han podido cargar las categorías.");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// =========================
|
||||
// CREAR PREGUNTA
|
||||
// ====
|
||||
|
||||
$("#formCrearPregunta").on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const boton = $("#btnCrearPregunta");
|
||||
|
||||
const pregunta = $("#pregunta").val().trim();
|
||||
const respuestaCorrecta = $("#respuestaCorrecta").val().trim();
|
||||
const respuestaIncorrecta1 = $("#respuestaIncorrecta1").val().trim();
|
||||
const respuestaIncorrecta2 = $("#respuestaIncorrecta2").val().trim();
|
||||
const respuestaIncorrecta3 = $("#respuestaIncorrecta3").val().trim();
|
||||
|
||||
// Comprobamos que no haya campos vacíos
|
||||
if (
|
||||
pregunta === "" ||
|
||||
respuestaCorrecta === "" ||
|
||||
respuestaIncorrecta1 === "" ||
|
||||
respuestaIncorrecta2 === "" ||
|
||||
respuestaIncorrecta3 === ""
|
||||
) {
|
||||
alert("Todos los campos son obligatorios.");
|
||||
return;
|
||||
}
|
||||
|
||||
boton.prop("disabled", true);
|
||||
boton.text("Creando pregunta...");
|
||||
|
||||
$.ajax({
|
||||
url: "controladores/controladorPregunta.php",
|
||||
|
||||
type: "POST",
|
||||
|
||||
dataType: "json",
|
||||
|
||||
data: {
|
||||
orden: "crearPregunta",
|
||||
|
||||
idCategoria: $("#idCategoria").val(),
|
||||
|
||||
nombrePregunta: pregunta,
|
||||
|
||||
respuestaCorrecta: respuestaCorrecta,
|
||||
|
||||
respuestaIncorrecta1: respuestaIncorrecta1,
|
||||
|
||||
respuestaIncorrecta2: respuestaIncorrecta2,
|
||||
|
||||
respuestaIncorrecta3: respuestaIncorrecta3,
|
||||
},
|
||||
|
||||
success: function (respuesta) {
|
||||
console.log("Respuesta del servidor:", respuesta);
|
||||
|
||||
if (respuesta.error) {
|
||||
alert(respuesta.error);
|
||||
|
||||
boton.prop("disabled", false);
|
||||
boton.text("Crear pregunta");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (respuesta.exito) {
|
||||
console.log("Pregunta creada:", respuesta.idPregunta);
|
||||
|
||||
// Cerramos el modal
|
||||
$("#modalCrearPregunta").modal("hide");
|
||||
|
||||
// Limpiamos el formulario
|
||||
$("#formCrearPregunta")[0].reset();
|
||||
|
||||
// Volvemos a activar el botón
|
||||
boton.prop("disabled", false);
|
||||
boton.text("Crear pregunta");
|
||||
|
||||
// Si tienes que actualizar la lista de preguntas:
|
||||
// cargarPreguntas();
|
||||
}
|
||||
},
|
||||
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Error al crear la pregunta:", error);
|
||||
|
||||
console.error("Respuesta del servidor:", xhr.responseText);
|
||||
|
||||
alert("No se ha podido crear la pregunta.");
|
||||
|
||||
boton.prop("disabled", false);
|
||||
boton.text("Crear pregunta");
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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">
|
||||
<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>
|
||||
|
||||
<!-- Contenedor de la Pregunta -->
|
||||
<div class="question-container">
|
||||
¿Cuál es el planeta más grande de nuestro sistema solar?
|
||||
</div>
|
||||
|
||||
<!-- Contenedor de Respuestas (Estilo Kahoot) -->
|
||||
<div class="answers-grid">
|
||||
<button class="btn-answer red" onclick="checkAnswer('Marte')">
|
||||
<span class="shape triangle"></span>
|
||||
Marte
|
||||
</button>
|
||||
|
||||
<button class="btn-answer blue" onclick="checkAnswer('Júpiter')">
|
||||
<span class="shape diamond"></span>
|
||||
Júpiter
|
||||
</button>
|
||||
|
||||
<button class="btn-answer yellow" onclick="checkAnswer('Saturno')">
|
||||
<span class="shape circle"></span>
|
||||
Saturno
|
||||
</button>
|
||||
|
||||
<button class="btn-answer green" onclick="checkAnswer('Tierra')">
|
||||
<span class="shape square"></span>
|
||||
Tierra
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 120 KiB |
@@ -1,474 +0,0 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.2.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: localhost:3307
|
||||
-- Generation Time: Sep 18, 2026 at 11:39 AM
|
||||
-- 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_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Database: `trivial`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `preguntas`
|
||||
--
|
||||
|
||||
CREATE TABLE `preguntas` (
|
||||
`idPregunta` int NOT NULL,
|
||||
`idDificultad` int DEFAULT NULL,
|
||||
`idCategoria` int DEFAULT NULL,
|
||||
`pregunta` varchar(200) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `preguntas`
|
||||
--
|
||||
|
||||
INSERT INTO `preguntas` (`idPregunta`, `idDificultad`, `idCategoria`, `pregunta`) VALUES
|
||||
(2140, 1, 4, '¿En qué año llegó Cristóbal Colón a América?'),
|
||||
(2141, 1, 5, '¿Cuál es la capital de Francia?'),
|
||||
(2142, 1, 6, '¿Qué planeta es conocido como el planeta rojo?'),
|
||||
(2143, 1, 7, '¿Quién pintó la Mona Lisa?'),
|
||||
(2144, 1, 5, '¿Cuál es el océano más grande del planeta?'),
|
||||
(2145, 1, 6, '¿Cuál es el símbolo químico del oro?'),
|
||||
(2146, 1, 8, '¿Quién escribió Don Quijote de la Mancha?'),
|
||||
(2147, 1, 9, '¿Cuántos jugadores tiene un equipo de fútbol en el campo?'),
|
||||
(2148, 1, 10, '¿Cuál es la estrella más cercana a la Tierra?'),
|
||||
(2149, 1, 11, '¿Cuál es el animal terrestre más grande?'),
|
||||
(2150, 2, 4, '¿Quién fue el primer emperador romano?'),
|
||||
(2151, 1, 5, '¿Cuál es la capital de España?'),
|
||||
(2152, 1, 6, '¿Qué gas es imprescindible para la respiración humana?'),
|
||||
(2153, 1, 12, '¿Cómo se llama el protagonista de la saga cinematográfica Indiana Jones?'),
|
||||
(2154, 1, 13, '¿Qué instrumento musical tiene teclas blancas y negras?'),
|
||||
(2155, 2, 5, '¿Cuál es la montaña más alta del mundo?'),
|
||||
(2156, 1, 4, '¿Qué civilización construyó las pirámides de Egipto?'),
|
||||
(2157, 2, 6, '¿Cuál es la fórmula química del agua?'),
|
||||
(2158, 2, 8, '¿Quién escribió Cien años de soledad?'),
|
||||
(2159, 1, 9, '¿Cada cuántos años se celebran los Juegos Olímpicos?'),
|
||||
(2160, 1, 14, '¿Qué significan las siglas CPU?'),
|
||||
(2161, 1, 10, '¿Cuántos planetas tiene actualmente el sistema solar?'),
|
||||
(2162, 1, 11, '¿Cuál es el animal más grande del planeta?'),
|
||||
(2163, 2, 7, '¿Qué movimiento artístico fue desarrollado por Picasso y Braque?'),
|
||||
(2164, 1, 15, '¿Cuántos días tiene un año bisiesto?'),
|
||||
(2165, 2, 5, '¿Cuál es el país más grande del mundo por superficie?'),
|
||||
(2166, 2, 4, '¿Quién fue conocido como el Libertador de gran parte de Sudamérica?'),
|
||||
(2167, 2, 6, '¿Cuál es la unidad básica de la vida?'),
|
||||
(2168, 2, 13, '¿Quién compuso la Novena Sinfonía?'),
|
||||
(2169, 1, 9, '¿En qué deporte se utiliza una raqueta y una pelota amarilla?'),
|
||||
(2170, 2, 4, '¿Qué muro cayó en 1989 simbolizando el fin de la Guerra Fría?'),
|
||||
(2171, 1, 5, '¿Cuál es la capital de Japón?'),
|
||||
(2172, 1, 6, '¿Qué órgano humano se encarga principalmente de bombear la sangre?'),
|
||||
(2173, 1, 8, '¿Quién escribió Romeo y Julieta?'),
|
||||
(2174, 2, 12, '¿Qué película incluye al personaje Darth Vader?'),
|
||||
(2175, 1, 5, '¿Cuál es la capital de Italia?'),
|
||||
(2176, 1, 6, '¿Qué fuerza mantiene a los planetas orbitando alrededor del Sol?'),
|
||||
(2177, 2, 4, '¿Qué imperio construyó Machu Picchu?'),
|
||||
(2178, 1, 11, '¿Cuál es el felino más grande del mundo?'),
|
||||
(2179, 1, 14, '¿Qué dispositivo se utiliza para mover el cursor en un ordenador?'),
|
||||
(2180, 2, 10, '¿Cuál es el planeta más grande del sistema solar?'),
|
||||
(2181, 1, 13, '¿Qué cantante es conocido como el Rey del Pop?'),
|
||||
(2182, 2, 9, '¿En qué deporte destacó Michael Jordan?'),
|
||||
(2183, 2, 8, '¿Quién escribió La Odisea?'),
|
||||
(2184, 2, 7, '¿Quién pintó La noche estrellada?'),
|
||||
(2185, 2, 5, '¿En qué continente se encuentra Egipto?'),
|
||||
(2186, 2, 6, '¿Qué científico formuló la teoría de la relatividad?'),
|
||||
(2187, 1, 4, '¿Dónde nació la democracia antigua?'),
|
||||
(2188, 1, 16, '¿Cuál es el ingrediente principal del guacamole?'),
|
||||
(2189, 1, 15, '¿Cuántos continentes se reconocen habitualmente?'),
|
||||
(2190, 2, 4, '¿En qué país se encuentra la ciudad antigua de Petra?'),
|
||||
(2191, 1, 5, '¿Cuál es la capital de Portugal?'),
|
||||
(2192, 1, 6, '¿Qué parte de la planta realiza principalmente la fotosíntesis?'),
|
||||
(2193, 2, 12, '¿Quién dirigió la película Titanic?'),
|
||||
(2194, 2, 13, '¿Qué grupo británico lanzó la canción Bohemian Rhapsody?'),
|
||||
(2195, 1, 9, '¿En qué deporte se disputa el torneo de Wimbledon?'),
|
||||
(2196, 2, 14, '¿Qué lenguaje se utiliza principalmente para estructurar páginas web?'),
|
||||
(2197, 2, 10, '¿Cómo se llama nuestra galaxia?'),
|
||||
(2198, 2, 11, '¿Cuál es el animal terrestre más rápido?'),
|
||||
(2199, 1, 16, '¿De qué país es originaria la pizza moderna?'),
|
||||
(2200, 2, 4, '¿Quién fue el primer presidente de Estados Unidos?'),
|
||||
(2201, 2, 5, '¿Cuál es el desierto cálido más grande del mundo?'),
|
||||
(2202, 2, 6, '¿Qué científico propuso las leyes del movimiento y la gravitación universal?'),
|
||||
(2203, 2, 8, '¿Quién escribió El principito?'),
|
||||
(2204, 1, 7, '¿Qué artista pintó los frescos de la Capilla Sixtina?'),
|
||||
(2205, 1, 5, '¿Cuál es la capital de Alemania?'),
|
||||
(2206, 1, 6, '¿Qué vitamina produce principalmente el cuerpo con la exposición al sol?'),
|
||||
(2207, 2, 4, '¿Qué civilización desarrolló un calendario muy avanzado en Mesoamérica?'),
|
||||
(2208, 1, 12, '¿Qué personaje vive en una piña bajo el mar?'),
|
||||
(2209, 1, 13, '¿Qué instrumento toca normalmente un baterista?'),
|
||||
(2210, 2, 9, '¿En qué país nació el fútbol moderno?'),
|
||||
(2211, 1, 14, '¿Qué empresa creó el sistema operativo Windows?'),
|
||||
(2212, 1, 10, '¿Qué planeta es famoso por sus anillos?'),
|
||||
(2213, 1, 11, '¿Qué animal es conocido como el rey de la selva?'),
|
||||
(2214, 1, 16, '¿Cuál es el ingrediente principal del sushi tradicional?'),
|
||||
(2215, 2, 4, '¿Quién fue Napoleón Bonaparte?'),
|
||||
(2216, 1, 5, '¿Cuál es la capital de Argentina?'),
|
||||
(2217, 2, 6, '¿Qué elemento químico tiene el símbolo Fe?'),
|
||||
(2218, 2, 8, '¿Quién escribió La metamorfosis?'),
|
||||
(2219, 2, 7, '¿Qué artista español creó el personaje Don Quijote en ilustraciones famosas?'),
|
||||
(2220, 2, 5, '¿Cuál es la capital de Canadá?'),
|
||||
(2221, 1, 6, '¿Qué órgano del cuerpo humano permite respirar?'),
|
||||
(2222, 2, 4, '¿Qué famoso faraón fue enterrado en una tumba encontrada casi intacta en 1922?'),
|
||||
(2223, 1, 12, '¿Cómo se llama el ogro protagonista de una famosa saga de películas de animación?'),
|
||||
(2224, 2, 13, '¿Qué compositor creó la ópera La flauta mágica?'),
|
||||
(2225, 1, 9, '¿Cuántos puntos vale un triple en baloncesto?'),
|
||||
(2226, 2, 14, '¿Qué significa la sigla WWW?'),
|
||||
(2227, 2, 10, '¿Cuál es el planeta más cercano al Sol?'),
|
||||
(2228, 1, 11, '¿Qué animal produce lana?'),
|
||||
(2229, 2, 16, '¿Cuál es el ingrediente principal del hummus?'),
|
||||
(2230, 2, 4, '¿Qué pueblo antiguo creó la democracia ateniense?'),
|
||||
(2231, 1, 5, '¿Cuál es la capital de México?'),
|
||||
(2232, 2, 6, '¿Qué científico desarrolló la teoría de la evolución por selección natural?'),
|
||||
(2233, 2, 8, '¿Quién escribió Los viajes de Gulliver?'),
|
||||
(2234, 2, 7, '¿Qué pintor español creó el cuadro Guernica?'),
|
||||
(2235, 2, 5, '¿Cuál es la isla más grande del mundo?'),
|
||||
(2236, 1, 6, '¿Cuántos huesos tiene aproximadamente un adulto?'),
|
||||
(2237, 1, 4, '¿Quién fue Julio César?'),
|
||||
(2238, 2, 12, '¿Qué actor interpretó a Jack en Titanic?'),
|
||||
(2239, 1, 13, '¿Qué grupo musical formaron John Lennon y Paul McCartney?'),
|
||||
(2240, 1, 5, '¿Cuál es la capital de Brasil?'),
|
||||
(2241, 2, 6, '¿Qué parte del átomo tiene carga negativa?'),
|
||||
(2242, 2, 4, '¿En qué país surgió la Revolución Industrial?'),
|
||||
(2243, 1, 12, '¿Cómo se llama el ratón protagonista de Disney?'),
|
||||
(2244, 2, 13, '¿Qué cantante española es conocida por la canción Despechá?'),
|
||||
(2245, 2, 9, '¿Cuántos jugadores forman un equipo de baloncesto en pista?'),
|
||||
(2246, 1, 14, '¿Qué empresa desarrolló el buscador Google?'),
|
||||
(2247, 2, 10, '¿Cómo se llama el satélite natural de la Tierra?'),
|
||||
(2248, 1, 11, '¿Qué animal es conocido por cambiar de color?'),
|
||||
(2249, 1, 16, '¿Qué bebida se obtiene principalmente de la fermentación de la uva?'),
|
||||
(2250, 2, 4, '¿Qué reina egipcia tuvo relación con Julio César y Marco Antonio?'),
|
||||
(2251, 1, 5, '¿Cuál es la capital de Grecia?'),
|
||||
(2252, 2, 6, '¿Qué científico descubrió la radiactividad junto con Pierre Curie?'),
|
||||
(2253, 2, 8, '¿Quién escribió La Divina Comedia?'),
|
||||
(2254, 2, 7, '¿Qué artista español creó el surrealismo con obras como La persistencia de la memoria?'),
|
||||
(2255, 2, 5, '¿Cuál es el río que atraviesa Egipto?'),
|
||||
(2256, 1, 6, '¿Qué planeta habitamos los seres humanos?'),
|
||||
(2257, 2, 4, '¿Qué guerra enfrentó principalmente a Atenas y Esparta?'),
|
||||
(2258, 2, 14, '¿Qué significa la sigla USB?'),
|
||||
(2259, 1, 9, '¿En qué deporte se utiliza una portería y un balón con las manos?'),
|
||||
(2260, 2, 5, '¿Cuál es la capital de Australia?'),
|
||||
(2261, 2, 6, '¿Qué sangre circula por las arterias desde el corazón hacia el cuerpo?'),
|
||||
(2262, 2, 4, '¿Qué pueblo construyó el Coliseo de Roma?'),
|
||||
(2263, 2, 12, '¿Qué película cuenta la historia de un barco que choca contra un iceberg?'),
|
||||
(2264, 1, 13, '¿Qué instrumento tiene seis cuerdas normalmente?'),
|
||||
(2265, 2, 9, '¿En qué deporte se utiliza un bate y una pelota?'),
|
||||
(2266, 2, 14, '¿Qué empresa creó el iPhone?'),
|
||||
(2267, 2, 10, '¿Qué fenómeno ocurre cuando la Luna se interpone entre la Tierra y el Sol?'),
|
||||
(2268, 1, 11, '¿Qué animal es conocido por tener una trompa larga?'),
|
||||
(2269, 1, 16, '¿Cuál es el ingrediente principal de las tortillas mexicanas tradicionales?'),
|
||||
(2270, 2, 4, '¿Qué explorador llegó a América en 1492?'),
|
||||
(2271, 1, 5, '¿Cuál es la capital de Francia?'),
|
||||
(2272, 2, 6, '¿Qué científico descubrió la penicilina?'),
|
||||
(2273, 2, 8, '¿Quién escribió El Quijote?'),
|
||||
(2274, 1, 7, '¿Qué material utiliza principalmente un escultor que trabaja con mármol?'),
|
||||
(2275, 2, 5, '¿Cuál es el río más largo del mundo según muchas mediciones?'),
|
||||
(2276, 1, 6, '¿Qué sentido permite percibir los sonidos?'),
|
||||
(2277, 2, 4, '¿Qué civilización construyó las ciudades de Tikal y Palenque?'),
|
||||
(2278, 2, 12, '¿Qué director creó la trilogía de El Señor de los Anillos en cine?'),
|
||||
(2279, 1, 13, '¿Qué instrumento pertenece a la familia de viento?'),
|
||||
(2280, 2, 9, '¿Qué país ganó el Mundial de fútbol de 2022?'),
|
||||
(2281, 1, 14, '¿Qué dispositivo permite realizar llamadas y conectarse a internet?'),
|
||||
(2282, 2, 10, '¿Qué nombre recibe el conjunto formado por una estrella y los cuerpos que orbitan a su alrededor?'),
|
||||
(2283, 2, 11, '¿Cuál es el árbol que produce bellotas?'),
|
||||
(2284, 2, 16, '¿Cuál es el ingrediente principal del gazpacho tradicional?'),
|
||||
(2285, 2, 4, '¿Qué antigua ciudad fue sepultada por el volcán Vesubio?'),
|
||||
(2286, 1, 5, '¿En qué continente está España?'),
|
||||
(2287, 2, 6, '¿Qué parte del cerebro coordina principalmente el equilibrio?'),
|
||||
(2288, 1, 8, '¿Qué personaje literario vive en una casa de Baker Street?'),
|
||||
(2289, 2, 7, '¿Qué arquitecto diseñó la Sagrada Familia de Barcelona?'),
|
||||
(2290, 2, 5, '¿Cuál es el país más poblado del mundo actualmente?'),
|
||||
(2291, 1, 6, '¿Qué gas absorben las plantas durante la fotosíntesis?'),
|
||||
(2292, 2, 4, '¿Quién fue conocido como el Gran Alejandro?'),
|
||||
(2293, 1, 12, '¿Qué superhéroe tiene como identidad a Bruce Wayne?'),
|
||||
(2294, 2, 13, '¿Qué compositor perdió la audición al final de su vida?'),
|
||||
(2295, 1, 9, '¿Cuántos anillos tiene el símbolo olímpico?'),
|
||||
(2296, 2, 14, '¿Qué empresa creó el sistema operativo Android?'),
|
||||
(2297, 1, 10, '¿Qué estrella está en el centro del sistema solar?'),
|
||||
(2298, 2, 11, '¿Qué mamífero es capaz de volar?'),
|
||||
(2299, 1, 16, '¿Qué fruta se utiliza para hacer aceite de oliva?'),
|
||||
(2300, 2, 4, '¿Qué tratado puso fin oficialmente a la Primera Guerra Mundial?'),
|
||||
(2301, 2, 5, '¿Cuál es la capital de Turquía?'),
|
||||
(2302, 1, 6, '¿Qué parte de la célula contiene el material genético?'),
|
||||
(2303, 2, 8, '¿Quién escribió Frankenstein?'),
|
||||
(2304, 1, 12, '¿Qué personaje dice la frase \'Hasta la vista, baby\'?'),
|
||||
(2305, 2, 13, '¿Qué compositor creó Las cuatro estaciones?'),
|
||||
(2306, 2, 9, '¿En qué deporte se utiliza un volante o pluma?'),
|
||||
(2307, 2, 14, '¿Qué significa la sigla IA?'),
|
||||
(2308, 2, 10, '¿Cómo se llama la explosión final de una estrella masiva?'),
|
||||
(2309, 1, 11, '¿Qué animal es famoso por construir presas?'),
|
||||
(2310, 2, 16, '¿Qué país es famoso por el plato llamado paella?'),
|
||||
(2311, 2, 4, '¿Qué civilización utilizaba jeroglíficos?'),
|
||||
(2312, 1, 5, '¿Cuál es la capital de Italia?'),
|
||||
(2313, 2, 6, '¿Qué instrumento se utiliza para medir la temperatura?'),
|
||||
(2314, 2, 8, '¿Quién creó al personaje de Harry Potter?'),
|
||||
(2315, 2, 7, '¿Qué estilo artístico predominó en muchas catedrales medievales?'),
|
||||
(2316, 2, 5, '¿Cuál es la montaña más alta de África?'),
|
||||
(2317, 1, 6, '¿Cuántos sentidos tradicionales tiene el ser humano?'),
|
||||
(2318, 2, 4, '¿Quién fue conocido como el rey del Imperio francés?'),
|
||||
(2319, 1, 12, '¿Qué personaje es un ogro verde?'),
|
||||
(2320, 1, 13, '¿Qué cantante es conocido como el Rey del Rock and Roll?'),
|
||||
(2321, 2, 9, '¿Cuántos jugadores tiene un equipo de fútbol en el campo?'),
|
||||
(2322, 1, 14, '¿Qué aparato se usa para imprimir documentos?'),
|
||||
(2323, 2, 10, '¿Qué es un cometa?'),
|
||||
(2324, 1, 11, '¿Cuál es el animal terrestre más grande?'),
|
||||
(2325, 2, 16, '¿Qué país es famoso por el sushi?'),
|
||||
(2326, 2, 4, '¿Qué muro cayó en 1989 simbolizando el fin de la Guerra Fría?'),
|
||||
(2327, 2, 5, '¿Cuál es la capital de Japón?'),
|
||||
(2328, 2, 6, '¿Qué científico formuló la teoría de la evolución?'),
|
||||
(2329, 2, 8, '¿Quién escribió Romeo y Julieta?'),
|
||||
(2330, 2, 7, '¿Qué pintor creó la Mona Lisa?'),
|
||||
(2331, 1, 5, '¿Cuál es el océano más grande del planeta?'),
|
||||
(2332, 1, 6, '¿Qué planeta es conocido como el planeta rojo?'),
|
||||
(2333, 2, 4, '¿Qué civilización construyó las pirámides de Guiza?'),
|
||||
(2334, 2, 12, '¿Qué película de animación tiene personajes llamados Woody y Buzz Lightyear?'),
|
||||
(2335, 2, 13, '¿Qué instrumento tiene teclas blancas y negras?'),
|
||||
(2336, 2, 9, '¿En qué deporte destacó Rafael Nadal?'),
|
||||
(2337, 2, 14, '¿Qué red conecta ordenadores a nivel mundial?'),
|
||||
(2338, 2, 10, '¿Qué instrumento permite observar objetos lejanos en el espacio?'),
|
||||
(2339, 1, 11, '¿Qué ave no puede volar y vive en la Antártida?'),
|
||||
(2340, 1, 16, '¿Qué ingrediente se obtiene de la leche y se usa en muchos postres?'),
|
||||
(2341, 2, 4, '¿Quién fue el primer ser humano en pisar la Luna?'),
|
||||
(2342, 2, 5, '¿Cuál es la capital de Rusia?'),
|
||||
(2343, 2, 6, '¿Qué científico es considerado el padre de la física moderna?'),
|
||||
(2344, 1, 8, '¿Qué detective fue creado por Arthur Conan Doyle?'),
|
||||
(2345, 2, 7, '¿Qué movimiento artístico inició Pablo Picasso junto con Braque?'),
|
||||
(2346, 2, 5, '¿Cuál es el país más grande del mundo por superficie?'),
|
||||
(2347, 1, 6, '¿Qué órgano bombea la sangre por el cuerpo?'),
|
||||
(2348, 2, 4, '¿Qué antigua ciudad griega fue famosa por sus guerreros?'),
|
||||
(2349, 2, 12, '¿Qué saga cinematográfica incluye al personaje Darth Vader?'),
|
||||
(2350, 2, 13, '¿Qué cantante interpretó la canción Thriller?'),
|
||||
(2351, 2, 9, '¿Qué país ganó el Mundial de fútbol de 2010?'),
|
||||
(2352, 1, 14, '¿Qué aparato convierte documentos físicos en archivos digitales?'),
|
||||
(2353, 2, 10, '¿Cómo se llama la galaxia vecina más cercana a la Vía Láctea?'),
|
||||
(2354, 1, 11, '¿Qué insecto produce miel?'),
|
||||
(2355, 2, 16, '¿Qué especia es conocida como azafrán?'),
|
||||
(2356, 2, 4, '¿Qué imperio tuvo su capital en Constantinopla?'),
|
||||
(2357, 2, 5, '¿Cuál es la capital de Egipto?'),
|
||||
(2358, 2, 6, '¿Qué unidad se utiliza para medir la fuerza?'),
|
||||
(2359, 2, 8, '¿Qué escritor creó a Don Quijote de la Mancha?'),
|
||||
(2360, 1, 7, '¿Qué color se obtiene al mezclar azul y amarillo?'),
|
||||
(2361, 2, 5, '¿Cuál es la capital de Noruega?'),
|
||||
(2362, 2, 6, '¿Cuál es el símbolo químico del oro?'),
|
||||
(2363, 2, 4, '¿Qué faraón ordenó construir una de las mayores pirámides de Guiza?'),
|
||||
(2364, 2, 12, '¿Qué actor interpretó a Iron Man en el Universo Marvel?'),
|
||||
(2365, 2, 13, '¿Qué banda lanzó el álbum The Dark Side of the Moon?'),
|
||||
(2366, 1, 9, '¿En qué deporte se utiliza una raqueta y una pelota amarilla?'),
|
||||
(2367, 2, 14, '¿Qué significa la sigla CPU?'),
|
||||
(2368, 2, 10, '¿Qué planeta tiene la Gran Mancha Roja?'),
|
||||
(2369, 2, 11, '¿Cuál es el animal terrestre más alto?'),
|
||||
(2370, 1, 16, '¿Qué bebida se prepara con granos tostados y molidos?'),
|
||||
(2371, 2, 4, '¿Quién fue conocido como el Libertador de varios países sudamericanos?'),
|
||||
(2372, 2, 5, '¿Cuál es la capital de Irlanda?'),
|
||||
(2373, 1, 6, '¿Qué planeta está más cerca de la Tierra?'),
|
||||
(2374, 2, 8, '¿Quién escribió La isla del tesoro?'),
|
||||
(2375, 2, 7, '¿Qué artista pintó Las meninas?'),
|
||||
(2376, 1, 5, '¿Qué país tiene forma alargada en la costa oeste de Sudamérica?'),
|
||||
(2377, 2, 6, '¿Qué vitamina se asocia con los cítricos como la naranja?'),
|
||||
(2378, 2, 4, '¿Qué acontecimiento comenzó en 1939?'),
|
||||
(2379, 1, 12, '¿Cómo se llama el león protagonista de El Rey León?'),
|
||||
(2380, 2, 13, '¿Qué instrumento toca un violinista?'),
|
||||
(2381, 2, 9, '¿Qué piloto español ganó varios campeonatos de Fórmula 1?'),
|
||||
(2382, 2, 14, '¿Qué empresa creó la consola PlayStation?'),
|
||||
(2383, 1, 10, '¿Cuántos planetas tiene el sistema solar?'),
|
||||
(2384, 2, 11, '¿Qué animal es conocido por su gran inteligencia marina?'),
|
||||
(2385, 2, 16, '¿De qué país procede tradicionalmente el curry?'),
|
||||
(2386, 2, 4, '¿Qué reina española apoyó el viaje de Colón?'),
|
||||
(2387, 1, 5, '¿Cuál es la capital de España?'),
|
||||
(2388, 2, 6, '¿Qué instrumento permite ver objetos muy pequeños?'),
|
||||
(2389, 2, 8, '¿Quién escribió 20.000 leguas de viaje submarino?'),
|
||||
(2390, 2, 5, '¿Cuál es la capital de Canadá?'),
|
||||
(2391, 1, 6, '¿Qué planeta es famoso por sus anillos?'),
|
||||
(2392, 2, 4, '¿Quién fue el primer emperador romano?'),
|
||||
(2393, 2, 12, '¿Qué película ganó el Óscar a mejor película en 1998 y trata sobre un barco hundido?'),
|
||||
(2394, 1, 13, '¿Cuántas notas musicales básicas hay en la escala occidental?'),
|
||||
(2395, 2, 9, '¿En qué deporte destacó Michael Jordan?'),
|
||||
(2396, 1, 14, '¿Qué empresa creó Windows?'),
|
||||
(2397, 2, 10, '¿Qué planeta tarda aproximadamente 365 días en dar una vuelta al Sol?'),
|
||||
(2398, 1, 11, '¿Qué animal es conocido como el rey de la selva?'),
|
||||
(2399, 2, 16, '¿Qué ingrediente principal lleva el hummus tradicional?'),
|
||||
(2400, 2, 4, '¿Qué revolución comenzó en Francia en 1789?'),
|
||||
(2401, 2, 5, '¿Cuál es la capital de Portugal?'),
|
||||
(2402, 2, 6, '¿Qué científico formuló las leyes del movimiento y la gravedad?'),
|
||||
(2403, 2, 8, '¿Quién escribió El principito?'),
|
||||
(2404, 2, 7, '¿Qué escultor creó el David de Florencia?'),
|
||||
(2405, 1, 5, '¿En qué continente está Brasil?'),
|
||||
(2406, 1, 6, '¿Qué gas necesitamos para respirar?'),
|
||||
(2407, 2, 4, '¿Qué pueblo creó Machu Picchu?'),
|
||||
(2408, 2, 12, '¿Qué saga tiene como protagonista a Harry Potter?'),
|
||||
(2409, 2, 13, '¿Qué grupo británico cantaba Bohemian Rhapsody?'),
|
||||
(2410, 2, 9, '¿Qué país organizó los Juegos Olímpicos de 1992?'),
|
||||
(2411, 2, 14, '¿Qué lenguaje se utiliza habitualmente para crear páginas web junto con CSS y JavaScript?'),
|
||||
(2412, 2, 10, '¿Qué nombre recibe una agrupación de estrellas que forma una figura aparente?'),
|
||||
(2413, 2, 11, '¿Cuál es el animal terrestre más rápido?'),
|
||||
(2414, 2, 16, '¿De qué país es originaria la pizza tradicional?'),
|
||||
(2415, 2, 4, '¿Qué civilización inventó la democracia en Atenas?'),
|
||||
(2416, 1, 5, '¿Cuál es la capital de Alemania?'),
|
||||
(2417, 2, 6, '¿Cuál es la fórmula química del agua?'),
|
||||
(2418, 2, 8, '¿Quién escribió 1984?'),
|
||||
(2419, 2, 7, '¿En qué museo se encuentra la Mona Lisa?'),
|
||||
(2420, 1, 12, '¿Cómo se llama el muñeco vaquero de Toy Story?'),
|
||||
(2421, 2, 13, '¿Qué cantante fue conocido como el Rey del Pop?'),
|
||||
(2422, 1, 9, '¿Cuánto dura un partido de fútbol profesional normalmente?'),
|
||||
(2423, 1, 14, '¿Qué dispositivo se utiliza para mover el cursor del ordenador?'),
|
||||
(2424, 2, 10, '¿Qué planeta es el más grande del sistema solar?'),
|
||||
(2425, 1, 11, '¿Qué animal tiene rayas negras y blancas?'),
|
||||
(2426, 1, 16, '¿Qué alimento producen las abejas?'),
|
||||
(2427, 2, 4, '¿Quién fue el líder sudafricano que luchó contra el apartheid?'),
|
||||
(2428, 2, 5, '¿Cuál es la montaña más alta del mundo?'),
|
||||
(2429, 1, 6, '¿Qué órgano utilizamos principalmente para ver?'),
|
||||
(2430, 2, 8, '¿Quién escribió La metamorfosis?'),
|
||||
(2431, 2, 7, '¿Qué pintor español creó el cuadro Guernica?'),
|
||||
(2432, 2, 5, '¿Cuál es la capital de Australia?'),
|
||||
(2433, 2, 6, '¿Qué científico desarrolló la teoría de la relatividad?'),
|
||||
(2434, 2, 4, '¿Qué explorador llegó a América en 1492?'),
|
||||
(2435, 1, 12, '¿Cómo se llama el ogro protagonista de una famosa saga de animación?'),
|
||||
(2436, 2, 13, '¿Qué compositor creó la Novena Sinfonía?'),
|
||||
(2437, 2, 9, '¿En qué deporte se disputa el Tour de Francia?'),
|
||||
(2438, 2, 14, '¿Qué empresa desarrolló el buscador Google?'),
|
||||
(2439, 1, 10, '¿Qué cuerpo celeste orbita alrededor de la Tierra?'),
|
||||
(2440, 2, 11, '¿Cuál es el animal más grande conocido actualmente?'),
|
||||
(2441, 2, 16, '¿Qué plato español está hecho principalmente con arroz?'),
|
||||
(2442, 2, 4, '¿Qué imperio construyó una gran red de carreteras en América del Sur?'),
|
||||
(2443, 1, 5, '¿Cuál es la capital de Francia?'),
|
||||
(2444, 2, 6, '¿Qué fuerza mantiene a los planetas orbitando alrededor del Sol?'),
|
||||
(2445, 2, 8, '¿Quién escribió El señor de los anillos?'),
|
||||
(2446, 2, 7, '¿Qué movimiento artístico está asociado con Salvador Dalí?'),
|
||||
(2447, 2, 12, '¿Qué director creó la película E.T.?'),
|
||||
(2448, 2, 13, '¿Qué instrumento suele tener seis cuerdas?'),
|
||||
(2449, 2, 9, '¿Qué país inventó el judo?'),
|
||||
(2450, 1, 14, '¿Qué dispositivo almacena archivos digitales?'),
|
||||
(2451, 2, 10, '¿Qué planeta está más alejado del Sol?'),
|
||||
(2452, 2, 11, '¿Qué árbol produce piñas?'),
|
||||
(2453, 1, 16, '¿Qué fruta amarilla es rica en potasio?'),
|
||||
(2454, 2, 4, '¿Qué ciudad fue conocida como la capital del Imperio romano?'),
|
||||
(2455, 2, 5, '¿Cuál es el río más largo del mundo según muchas mediciones modernas?'),
|
||||
(2456, 2, 6, '¿Qué científico descubrió la penicilina?'),
|
||||
(2457, 2, 8, '¿Qué personaje vive aventuras junto a Sancho Panza?'),
|
||||
(2458, 2, 7, '¿Qué edificio famoso diseñó Gaudí en Barcelona?'),
|
||||
(2459, 1, 12, '¿Qué superhéroe lleva un escudo con una estrella?'),
|
||||
(2460, 2, 13, '¿Qué instrumento toca normalmente un pianista?'),
|
||||
(2461, 2, 9, '¿Cuántos jugadores forman un equipo de baloncesto en pista?'),
|
||||
(2462, 2, 14, '¿Qué significa la sigla USB?'),
|
||||
(2463, 2, 10, '¿Qué fenómeno ocurre cuando la Luna se interpone entre la Tierra y el Sol?'),
|
||||
(2464, 2, 11, '¿Qué animal es conocido por cambiar de color para camuflarse?'),
|
||||
(2465, 2, 16, '¿Cuál es el ingrediente principal del guacamole?'),
|
||||
(2466, 2, 4, '¿Qué civilización construyó el Coliseo de Roma?'),
|
||||
(2467, 1, 5, '¿Cuál es la capital de Italia?'),
|
||||
(2468, 2, 6, '¿Qué elemento químico tiene el símbolo Fe?'),
|
||||
(2469, 2, 8, '¿Qué escritor creó al personaje Sherlock Holmes?'),
|
||||
(2470, 2, 7, '¿Qué famoso museo está situado en Madrid y alberga obras de Velázquez y Goya?'),
|
||||
(2471, 2, 12, '¿Qué película de ciencia ficción presenta al personaje Neo?'),
|
||||
(2472, 2, 13, '¿Qué banda británica estaba formada por John Lennon, Paul McCartney, George Harrison y Ringo Starr?'),
|
||||
(2473, 1, 9, '¿Qué deporte practica un nadador?'),
|
||||
(2474, 2, 14, '¿Qué empresa creó el iPhone?'),
|
||||
(2475, 2, 10, '¿Cómo se llama nuestra galaxia?'),
|
||||
(2476, 1, 11, '¿Qué animal doméstico suele llamarse el mejor amigo del hombre?'),
|
||||
(2477, 2, 16, '¿Qué bebida se obtiene de las hojas del té?'),
|
||||
(2478, 2, 4, '¿Qué líder impulsó la independencia de la India mediante la resistencia no violenta?'),
|
||||
(2479, 2, 5, '¿Qué país tiene como capital Buenos Aires?'),
|
||||
(2480, 1, 6, '¿Qué parte de la planta absorbe agua del suelo?'),
|
||||
(2481, 2, 4, '¿Quién fue el emperador francés conocido por sus conquistas en Europa?'),
|
||||
(2482, 2, 5, '¿Cuál es el desierto cálido más grande del mundo?'),
|
||||
(2483, 2, 6, '¿Qué científico propuso la teoría de la evolución por selección natural?'),
|
||||
(2484, 2, 8, '¿Quién escribió Romeo y Julieta?'),
|
||||
(2485, 2, 7, '¿Qué pintor neerlandés creó La noche estrellada?'),
|
||||
(2486, 2, 12, '¿Cómo se llama el protagonista de la saga Indiana Jones?'),
|
||||
(2487, 2, 13, '¿Qué compositor fue conocido como el niño prodigio de la música clásica?'),
|
||||
(2488, 2, 9, '¿En qué deporte se utiliza un bate y una pelota?'),
|
||||
(2489, 1, 14, '¿Qué componente muestra imágenes en un ordenador?'),
|
||||
(2490, 2, 10, '¿Qué estrella está en el centro del sistema solar?'),
|
||||
(2491, 2, 11, '¿Qué mamífero pone huevos?'),
|
||||
(2492, 2, 16, '¿Qué pasta italiana tiene forma de tubos?'),
|
||||
(2493, 2, 4, '¿Qué muro cayó en Berlín en 1989?'),
|
||||
(2494, 1, 5, '¿En qué continente está Japón?'),
|
||||
(2495, 2, 6, '¿Qué parte del cuerpo humano contiene el cerebro?'),
|
||||
(2496, 2, 8, '¿Qué personaje literario es un vampiro creado por Bram Stoker?'),
|
||||
(2497, 2, 7, '¿Qué estilo arquitectónico tiene arcos apuntados y grandes vidrieras?'),
|
||||
(2498, 2, 12, '¿Qué actor interpretó a Jack Sparrow?'),
|
||||
(2499, 1, 13, '¿Qué instrumento tiene teclas blancas y negras?'),
|
||||
(2500, 2, 9, '¿Qué tenista español ganó múltiples Roland Garros?'),
|
||||
(2501, 2, 14, '¿Qué significa la palabra \'internet\' en relación con redes?'),
|
||||
(2502, 2, 10, '¿Qué objeto espacial es un fragmento rocoso que orbita alrededor del Sol?'),
|
||||
(2503, 1, 11, '¿Qué animal tiene una trompa larga?'),
|
||||
(2504, 2, 16, '¿Qué alimento se obtiene de las uvas fermentadas?'),
|
||||
(2505, 2, 4, '¿Quién fue conocido por la frase \'Tengo un sueño\'?'),
|
||||
(2506, 2, 5, '¿Cuál es la capital de Grecia?'),
|
||||
(2507, 2, 6, '¿Qué instrumento mide la temperatura?'),
|
||||
(2508, 2, 8, '¿Quién escribió La divina comedia?'),
|
||||
(2509, 2, 7, '¿Qué arquitecto diseñó la Casa Batlló de Barcelona?'),
|
||||
(2510, 2, 6, '¿Qué científico formuló la teoría heliocéntrica que situaba al Sol en el centro?'),
|
||||
(2511, 2, 4, '¿Qué antigua civilización construyó las pirámides de Egipto?'),
|
||||
(2512, 2, 5, '¿Cuál es la capital de México?'),
|
||||
(2513, 1, 6, '¿Qué estado del agua tiene forma sólida?'),
|
||||
(2514, 2, 8, '¿Qué detective fue creado por Agatha Christie?'),
|
||||
(2515, 2, 7, '¿Qué técnica artística utiliza pequeñas piezas de vidrio o piedra para crear imágenes?'),
|
||||
(2516, 2, 12, '¿Qué película animada tiene como protagonista a una princesa llamada Elsa?'),
|
||||
(2517, 2, 13, '¿Qué cantante es conocido como el Rey del Rock?'),
|
||||
(2518, 1, 9, '¿Cuántos anillos tiene el símbolo olímpico?'),
|
||||
(2519, 2, 14, '¿Qué sistema operativo utilizan muchos teléfonos móviles?'),
|
||||
(2520, 2, 10, '¿Cómo se llama el primer hombre que viajó al espacio?'),
|
||||
(2521, 1, 11, '¿Qué animal produce lana?'),
|
||||
(2522, 2, 16, '¿Qué ingrediente da picor a muchos platos mexicanos?'),
|
||||
(2523, 2, 4, '¿Qué documento inglés de 1215 limitó el poder del rey?'),
|
||||
(2524, 2, 5, '¿Cuál es la isla más grande del mundo?'),
|
||||
(2525, 2, 6, '¿Qué científico estudió la electricidad y los rayos con una cometa?'),
|
||||
(2526, 2, 8, '¿Qué novela comienza con un personaje llamado Gregor Samsa?'),
|
||||
(2527, 2, 7, '¿Qué material utiliza principalmente un escultor que trabaja con mármol?'),
|
||||
(2528, 2, 12, '¿Qué saga cinematográfica está ambientada en la Tierra Media?'),
|
||||
(2529, 2, 13, '¿Qué compositor creó Las cuatro estaciones?'),
|
||||
(2530, 2, 9, '¿En qué deporte se usa una raqueta y un volante?'),
|
||||
(2531, 2, 14, '¿Qué unidad se utiliza normalmente para medir almacenamiento digital?'),
|
||||
(2532, 2, 10, '¿Qué planeta es conocido como el planeta rojo?'),
|
||||
(2533, 2, 11, '¿Qué ave no puede volar y vive en la Antártida?'),
|
||||
(2534, 2, 16, '¿Qué dulce español se consume tradicionalmente en Navidad?');
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `preguntas`
|
||||
--
|
||||
ALTER TABLE `preguntas`
|
||||
ADD PRIMARY KEY (`idPregunta`),
|
||||
ADD KEY `idDificultad` (`idDificultad`),
|
||||
ADD KEY `idCategoria` (`idCategoria`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `preguntas`
|
||||
--
|
||||
ALTER TABLE `preguntas`
|
||||
MODIFY `idPregunta` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2535;
|
||||
|
||||
--
|
||||
-- Constraints for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Constraints for table `preguntas`
|
||||
--
|
||||
ALTER TABLE `preguntas`
|
||||
ADD CONSTRAINT `preguntas_ibfk_1` FOREIGN KEY (`idDificultad`) REFERENCES `dificultades` (`idDificultad`),
|
||||
ADD CONSTRAINT `preguntas_ibfk_2` FOREIGN KEY (`idCategoria`) REFERENCES `categorias` (`idCategoria`);
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,346 +0,0 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.2.3
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: localhost:3307
|
||||
-- Generation Time: Sep 23, 2026 at 12:02 PM
|
||||
-- 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_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Database: `triviagmatico`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `categoria`
|
||||
--
|
||||
|
||||
CREATE TABLE `categoria` (
|
||||
`idCategoria` int NOT NULL,
|
||||
`nombreCategoria` varchar(50) COLLATE utf8mb4_spanish_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `equipo`
|
||||
--
|
||||
|
||||
CREATE TABLE `equipo` (
|
||||
`idEquipo` int NOT NULL,
|
||||
`nombreEquipo` varchar(50) COLLATE utf8mb4_spanish_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `equipoxpartida`
|
||||
--
|
||||
|
||||
CREATE TABLE `equipoxpartida` (
|
||||
`idEquipoxPartida` int NOT NULL,
|
||||
`idPartida` int DEFAULT NULL,
|
||||
`idEquipo` int DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `equipoxusuario`
|
||||
--
|
||||
|
||||
CREATE TABLE `equipoxusuario` (
|
||||
`idEquipoxUsuario` int NOT NULL,
|
||||
`idUsuario` int NOT NULL,
|
||||
`idEquipo` int NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `partida`
|
||||
--
|
||||
|
||||
CREATE TABLE `partida` (
|
||||
`idPartida` int NOT NULL,
|
||||
`nombrePartida` varchar(100) COLLATE utf8mb4_spanish_ci NOT NULL,
|
||||
`idUsuario` int NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `partidaxpregunta`
|
||||
--
|
||||
|
||||
CREATE TABLE `partidaxpregunta` (
|
||||
`idPartidaxPregunta` int NOT NULL,
|
||||
`idPartida` int NOT NULL,
|
||||
`idPregunta` int NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `pregunta`
|
||||
--
|
||||
|
||||
CREATE TABLE `pregunta` (
|
||||
`idPregunta` int NOT NULL,
|
||||
`idCategoria` int NOT NULL,
|
||||
`nombrePregunta` varchar(255) COLLATE utf8mb4_spanish_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `respuesta`
|
||||
--
|
||||
|
||||
CREATE TABLE `respuesta` (
|
||||
`idRespuesta` int NOT NULL,
|
||||
`idPregunta` int NOT NULL,
|
||||
`nombreRespuesta` varchar(255) COLLATE utf8mb4_spanish_ci NOT NULL,
|
||||
`correcta` tinyint(1) DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `respuestaalmacenada`
|
||||
--
|
||||
|
||||
CREATE TABLE `respuestaalmacenada` (
|
||||
`idRespuestaAlmacenada` int NOT NULL,
|
||||
`idPartidaxPregunta` int NOT NULL,
|
||||
`idUsuario` int NOT NULL,
|
||||
`idRespuesta` int NOT NULL,
|
||||
`primero` tinyint(1) DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `usuario`
|
||||
--
|
||||
|
||||
CREATE TABLE `usuario` (
|
||||
`idUsuario` int NOT NULL,
|
||||
`nombreUsuario` varchar(50) COLLATE utf8mb4_spanish_ci NOT NULL,
|
||||
`contrasena` varchar(100) COLLATE utf8mb4_spanish_ci NOT NULL,
|
||||
`email` varchar(50) COLLATE utf8mb4_spanish_ci NOT NULL,
|
||||
`avatar` varchar(200) COLLATE utf8mb4_spanish_ci DEFAULT NULL,
|
||||
`cookie` varchar(200) COLLATE utf8mb4_spanish_ci DEFAULT NULL,
|
||||
`aciertos` int NOT NULL,
|
||||
`victorias` int NOT NULL,
|
||||
`derrotas` int NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci;
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `categoria`
|
||||
--
|
||||
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 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 for table `equipo`
|
||||
--
|
||||
ALTER TABLE `equipo`
|
||||
MODIFY `idEquipo` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `equipoxpartida`
|
||||
--
|
||||
ALTER TABLE `equipoxpartida`
|
||||
MODIFY `idEquipoxPartida` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `equipoxusuario`
|
||||
--
|
||||
ALTER TABLE `equipoxusuario`
|
||||
MODIFY `idEquipoxUsuario` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `partida`
|
||||
--
|
||||
ALTER TABLE `partida`
|
||||
MODIFY `idPartida` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `partidaxpregunta`
|
||||
--
|
||||
ALTER TABLE `partidaxpregunta`
|
||||
MODIFY `idPartidaxPregunta` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `pregunta`
|
||||
--
|
||||
ALTER TABLE `pregunta`
|
||||
MODIFY `idPregunta` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `respuesta`
|
||||
--
|
||||
ALTER TABLE `respuesta`
|
||||
MODIFY `idRespuesta` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `respuestaalmacenada`
|
||||
--
|
||||
ALTER TABLE `respuestaalmacenada`
|
||||
MODIFY `idRespuestaAlmacenada` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `usuario`
|
||||
--
|
||||
ALTER TABLE `usuario`
|
||||
MODIFY `idUsuario` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- Constraints for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Constraints for table `equipoxpartida`
|
||||
--
|
||||
ALTER TABLE `equipoxpartida`
|
||||
ADD CONSTRAINT `FK idEquipo tabla equipo` FOREIGN KEY (`idEquipo`) REFERENCES `equipo` (`idEquipo`) ON DELETE RESTRICT ON UPDATE RESTRICT,
|
||||
ADD CONSTRAINT `FK idPartida tabla partida` FOREIGN KEY (`idPartida`) REFERENCES `partida` (`idPartida`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
|
||||
--
|
||||
-- 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`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
|
||||
--
|
||||
-- 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_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
+307
@@ -0,0 +1,307 @@
|
||||
<?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">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
||||
|
||||
<title>Perfil</title>
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Bootstrap Icons -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
|
||||
<!-- Google Font: Fredoka -->
|
||||
<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">
|
||||
|
||||
<!-- Tu CSS -->
|
||||
<link rel="stylesheet" href="css/index.css">
|
||||
<link rel="stylesheet" href="css/perfil.css">
|
||||
<script src="js/jquery-4.0.0.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php include_once 'cabecera.php'; ?>
|
||||
|
||||
<div class="perfil-container">
|
||||
|
||||
<div class="perfil-card">
|
||||
|
||||
<!-- CABECERA -->
|
||||
<div class="perfil-header">
|
||||
<i class="bi bi-person-circle"></i>
|
||||
Mi perfil
|
||||
</div>
|
||||
|
||||
<div class="perfil-content">
|
||||
|
||||
<div class="row align-items-center g-5">
|
||||
|
||||
<!-- PERFIL -->
|
||||
<div class="col-md-6 text-center">
|
||||
|
||||
<!-- Nombre -->
|
||||
<h1 id="nombre" class="nombre">
|
||||
<?= $nombreUsuario ?>
|
||||
</h1>
|
||||
|
||||
<!-- FOTO DE PERFIL -->
|
||||
<div class="foto-container">
|
||||
|
||||
<img id="fotoPerfil"
|
||||
src="<?= $avatarUsuario ?>"
|
||||
alt="Foto de perfil"
|
||||
class="avatar rounded-circle">
|
||||
|
||||
<!-- Botón lápiz -->
|
||||
<button type="button"
|
||||
class="btn-foto"
|
||||
onclick="seleccionarFoto()"
|
||||
title="Cambiar foto de perfil"
|
||||
aria-label="Cambiar foto de perfil">
|
||||
<i class="bi bi-pencil-fill"></i>
|
||||
</button>
|
||||
|
||||
<!-- Input oculto -->
|
||||
<input type="file"
|
||||
id="inputFoto"
|
||||
accept="image/*"
|
||||
hidden>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- CAMBIAR NOMBRE -->
|
||||
<div class="formulario-nombre">
|
||||
|
||||
<label for="nuevoNombre" class="form-label">
|
||||
Cambia tu nombre
|
||||
</label>
|
||||
|
||||
<input type="text"
|
||||
id="nuevoNombre"
|
||||
class="form-control mb-3"
|
||||
placeholder="Escribe tu nuevo nombre">
|
||||
|
||||
<div class="d-flex justify-content-center gap-2">
|
||||
|
||||
<button type="button"
|
||||
class="btn-perfil-cambiar"
|
||||
onclick="cambiarNombre()">
|
||||
<i class="bi bi-check-lg"></i>
|
||||
Cambiar nombre
|
||||
</button>
|
||||
|
||||
<button type="button"
|
||||
class="btn-perfil-borrar"
|
||||
onclick="borrarNombre()">
|
||||
<i class="bi bi-x-lg"></i>
|
||||
Borrar
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ESTADÍSTICAS -->
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="estadisticas">
|
||||
|
||||
<h2>
|
||||
<i class="bi bi-bar-chart-fill"></i>
|
||||
Estadísticas
|
||||
</h2>
|
||||
|
||||
<div class="estadistica estadistica-victorias">
|
||||
<i class="bi bi-trophy-fill"></i>
|
||||
Victorias:
|
||||
<strong id="victorias">0</strong>
|
||||
</div>
|
||||
|
||||
<div class="estadistica estadistica-derrotas">
|
||||
<i class="bi bi-x-circle-fill"></i>
|
||||
Derrotas:
|
||||
<strong id="derrotas">0</strong>
|
||||
</div>
|
||||
|
||||
<div class="estadistica estadistica-aciertos">
|
||||
<i class="bi bi-bullseye"></i>
|
||||
Aciertos:
|
||||
<strong id="aciertos">0</strong>
|
||||
</div>
|
||||
|
||||
<!-- CREAR PREGUNTA -->
|
||||
<div class="text-center mt-4">
|
||||
<button type="button"
|
||||
class="btn btn-play-kahoot"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#modalCrearPregunta">
|
||||
<i class="bi bi-plus-circle-fill"></i>
|
||||
Crear pregunta
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- MODAL CREAR PREGUNTA -->
|
||||
<div class="modal fade"
|
||||
id="modalCrearPregunta"
|
||||
tabindex="-1"
|
||||
aria-labelledby="modalCrearPreguntaLabel"
|
||||
aria-hidden="true">
|
||||
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
|
||||
<div class="modal-content modal-kahoot">
|
||||
|
||||
<div class="modal-header modal-kahoot-header">
|
||||
<h5 class="modal-title" id="modalCrearPreguntaLabel">
|
||||
<i class="bi bi-question-circle-fill me-2"></i>
|
||||
Crear pregunta
|
||||
</h5>
|
||||
<button type="button"
|
||||
class="btn-close btn-close-white"
|
||||
data-bs-dismiss="modal"
|
||||
aria-label="Cerrar">
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body p-4">
|
||||
|
||||
<form id="formCrearPregunta">
|
||||
|
||||
<!-- PREGUNTA -->
|
||||
<div class="mb-4">
|
||||
<label for="pregunta" class="form-label fw-semibold">
|
||||
<i class="bi bi-question-lg me-1"></i>
|
||||
Pregunta
|
||||
</label>
|
||||
<textarea id="pregunta"
|
||||
name="pregunta"
|
||||
class="form-control input-kahoot"
|
||||
rows="3"
|
||||
placeholder="Escribe aquí la pregunta..."
|
||||
required></textarea>
|
||||
</div>
|
||||
|
||||
<!-- CATEGORÍA -->
|
||||
<div class="mb-4">
|
||||
<label for="idCategoria" class="form-label fw-semibold">
|
||||
<i class="bi bi-folder-fill me-1"></i>
|
||||
Categoría
|
||||
</label>
|
||||
<select id="idCategoria"
|
||||
name="idCategoria"
|
||||
class="form-select input-kahoot"
|
||||
required>
|
||||
<option value="">Selecciona una categoría</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- RESPUESTA CORRECTA -->
|
||||
<div class="mb-3">
|
||||
<label for="respuestaCorrecta" class="form-label fw-semibold text-success">
|
||||
<i class="bi bi-check-circle-fill me-1"></i>
|
||||
Respuesta correcta
|
||||
</label>
|
||||
<input type="text"
|
||||
id="respuestaCorrecta"
|
||||
name="respuestaCorrecta"
|
||||
class="form-control input-kahoot"
|
||||
placeholder="Escribe la respuesta correcta..."
|
||||
required>
|
||||
</div>
|
||||
|
||||
<!-- RESPUESTAS INCORRECTAS -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold text-danger">
|
||||
<i class="bi bi-x-circle-fill me-1"></i>
|
||||
Respuestas incorrectas
|
||||
</label>
|
||||
|
||||
<input type="text"
|
||||
id="respuestaIncorrecta1"
|
||||
name="respuestaIncorrecta1"
|
||||
class="form-control input-kahoot mb-2"
|
||||
placeholder="Respuesta incorrecta 1"
|
||||
required>
|
||||
|
||||
<input type="text"
|
||||
id="respuestaIncorrecta2"
|
||||
name="respuestaIncorrecta2"
|
||||
class="form-control input-kahoot mb-2"
|
||||
placeholder="Respuesta incorrecta 2"
|
||||
required>
|
||||
|
||||
<input type="text"
|
||||
id="respuestaIncorrecta3"
|
||||
name="respuestaIncorrecta3"
|
||||
class="form-control input-kahoot"
|
||||
placeholder="Respuesta incorrecta 3"
|
||||
required>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
|
||||
<i class="bi bi-x-lg me-1"></i>
|
||||
Cancelar
|
||||
</button>
|
||||
|
||||
<button type="submit" form="formCrearPregunta" class="btn btn-kahoot-login" id="btnCrearPregunta">
|
||||
<i class="bi bi-check-lg me-1"></i>
|
||||
Crear pregunta
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Tu JavaScript -->
|
||||
<script src="js/perfil.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,31 @@
|
||||
REQUISITOS CONTROLADORES
|
||||
|
||||
Orden “RegistrarUsuario“
|
||||
registrarUsuario(nombre, email, password) inserta un usuario en la bbdd, hay que comprobar que en la tabla usuario no hay una cuenta con el correo electronico
|
||||
|
||||
Orden “ComprobarUsuario“
|
||||
comprobarUsuario(email, password) comprueba si el usuario introducido se encuentra en la bbdd para poder iniciar sesion, hay que actualizar las variables de sesion para guardar su email y su id de la bbdd.
|
||||
|
||||
Orden “RankingGlobal“
|
||||
rankingGlobal() recupera los 5 usuarios con mas puntos ordenados por el maximo de puntos
|
||||
|
||||
Orden "CrearSala"
|
||||
crearSala(nombreSala, nombreEquipo1, nombreEquipo2) inserta en la bbdd una sala y asigna al usuario que la crea a equipo 1
|
||||
|
||||
Orden “BuscarSalas“
|
||||
buscarSala() recupera todas las salas activas a las que el usuario se puede unir, devuelve nombre de sala, nombre de equipo, **id equipo**(todos los equipos), nombre usuarios.
|
||||
|
||||
Orden “AsignarUsuario“
|
||||
asignarUsuario(**id equipo**, id usuario(variable de sesion)) cuando el usuario pulsa el boton de unirse asigna al equipo dicho usuario
|
||||
|
||||
Orden “BuscarSalaUsuarioActivo“
|
||||
buscarSalaUsuarioActivo(**id equipo)** recarga la pagina para solo mostrar la sala en la que se encuentra el usuario
|
||||
|
||||
Orden “CargarPreguntasyRespuestas“
|
||||
cargarPreguntasyRespuestas() recupera todas las preguntas de la partida (10 preguntas por partida), devuelve un json con las preguntas, las 4 respuestas
|
||||
|
||||
Orden ”ComprobarRespuesta”
|
||||
comprobarRespuesta(idRespuesta, idUsuario, tiempo) comprueba si el usuario ha pulsado sobre la respuesta correcta o incorrecta, devuelve si es correcta o incorrecta
|
||||
|
||||
Orden "ComprobarEquipoGanador"
|
||||
comprobarEquipoGanador() comprueba cual de los dos equipos gana, devuelve un json con la puntuacion global, nombre de equipos, nombre de usuarios y puntuacion de cada usuario, actualiza el ranking global de usuarios
|
||||
+291
@@ -0,0 +1,291 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Trivial - Resultado final</title>
|
||||
|
||||
<link rel="icon" type="image/svg+xml" href="img/favicon/favicon.svg">
|
||||
|
||||
<link
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet">
|
||||
|
||||
<!-- Bootstrap Icons -->
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap"
|
||||
rel="stylesheet">
|
||||
|
||||
<link rel="stylesheet" href="css/index.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
include_once("cabecera.php");
|
||||
?>
|
||||
|
||||
<main class="container py-5">
|
||||
|
||||
<!-- Título -->
|
||||
<div class="text-center mb-5">
|
||||
|
||||
<div class="trophy-icon">
|
||||
<i class="bi bi-trophy-fill"></i>
|
||||
</div>
|
||||
|
||||
<h1 class="fw-bold">
|
||||
¡Trivial terminado!
|
||||
</h1>
|
||||
|
||||
<p class="text-muted fs-5 mb-0">
|
||||
Estos son los resultados finales
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Equipo ganador -->
|
||||
<section class="row justify-content-center mb-5">
|
||||
|
||||
<div class="col-12 col-lg-8">
|
||||
|
||||
<div class="ranking-card">
|
||||
|
||||
<div class="ranking-header text-center">
|
||||
<i class="bi bi-trophy-fill me-2"></i>
|
||||
Equipo ganador
|
||||
</div>
|
||||
|
||||
<div class="card-body text-center p-4">
|
||||
|
||||
<h2 class="fw-bold mb-2">
|
||||
Los Cerebritos
|
||||
</h2>
|
||||
|
||||
<div class="display-3 fw-bold mb-3">
|
||||
850
|
||||
<span class="fs-4 text-muted">
|
||||
puntos
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p class="text-muted mb-0">
|
||||
<i class="bi bi-stars me-1"></i>
|
||||
¡Enhorabuena por la victoria!
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<!-- Resultados de los dos equipos -->
|
||||
<section class="row justify-content-center g-4">
|
||||
|
||||
<!-- EQUIPO GANADOR -->
|
||||
<div class="col-12 col-lg-6">
|
||||
|
||||
<div class="ranking-card h-100">
|
||||
|
||||
<div class="ranking-header d-flex justify-content-between align-items-center">
|
||||
|
||||
<span>
|
||||
Los Cerebritos
|
||||
</span>
|
||||
|
||||
<span>
|
||||
<i class="bi bi-trophy-fill"></i>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-body p-4">
|
||||
|
||||
<div class="text-center mb-4">
|
||||
|
||||
<div class="fs-1 fw-bold">
|
||||
850
|
||||
</div>
|
||||
|
||||
<div class="text-muted">
|
||||
puntos
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<h5 class="fw-bold mb-3">
|
||||
<i class="bi bi-people-fill me-2"></i>
|
||||
Jugadores
|
||||
</h5>
|
||||
|
||||
<ul class="list-group">
|
||||
|
||||
<li class="list-group-item">
|
||||
1. Carlos
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
2. Marta
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
3. Pablo
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
4. Laura
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
5. David
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
6. Ana
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
7. Sergio
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
8. Lucía
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
9. Miguel
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
10. Elena
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- EQUIPO PERDEDOR -->
|
||||
<div class="col-12 col-lg-6">
|
||||
|
||||
<div class="ranking-card h-100">
|
||||
|
||||
<!-- Cabecera plateada -->
|
||||
<div
|
||||
class="ranking-header d-flex justify-content-between align-items-center"
|
||||
style="background-color: #c0c0c0;">
|
||||
|
||||
<span>
|
||||
Los Campeones
|
||||
</span>
|
||||
|
||||
<span>
|
||||
<i class="bi bi-award-fill"></i>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-body p-4">
|
||||
|
||||
<div class="text-center mb-4">
|
||||
|
||||
<div class="fs-1 fw-bold">
|
||||
720
|
||||
</div>
|
||||
|
||||
<div class="text-muted">
|
||||
puntos
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<h5 class="fw-bold mb-3">
|
||||
<i class="bi bi-people-fill me-2"></i>
|
||||
Jugadores
|
||||
</h5>
|
||||
|
||||
<ul class="list-group">
|
||||
|
||||
<li class="list-group-item">
|
||||
1. Javier
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
2. Sofía
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
3. Diego
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
4. María
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
5. Alejandro
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
6. Paula
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
7. Álvaro
|
||||
</li>
|
||||
|
||||
<li class="list-group-item">
|
||||
8. Carmen
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
<!-- Volver al buscador -->
|
||||
<div class="text-center mt-5">
|
||||
|
||||
<a
|
||||
href="buscadorSala.php"
|
||||
class="btn btn-play-kahoot">
|
||||
|
||||
<i class="bi bi-arrow-left-circle-fill"></i>
|
||||
|
||||
Volver al buscador de salas
|
||||
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js">
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user