Compare commits
17 Commits
03715d621e
...
optimizar
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c679175c6 | |||
| b8581a611e | |||
| 6adcb9680c | |||
| 99a08b0a34 | |||
| 7661343572 | |||
| e97586b033 | |||
| 42cc1489e9 | |||
| a694f19667 | |||
| 3cc0dfb122 | |||
| 4efb831b7a | |||
| 22f38f924f | |||
| 01aa2643f6 | |||
| 07c1f79474 | |||
| 54b6b0d67b | |||
| 57e3dfc444 | |||
| 8c7958ad96 | |||
| bf2361ad43 |
+58
-156
@@ -4,200 +4,102 @@
|
||||
<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 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");
|
||||
?>
|
||||
<?php include_once("cabecera.php"); ?>
|
||||
|
||||
<main class="container py-5">
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<!-- 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>
|
||||
|
||||
<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 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>
|
||||
|
||||
<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">
|
||||
|
||||
<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">
|
||||
|
||||
<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">
|
||||
|
||||
<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>
|
||||
|
||||
<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" id="modalAbandonarSalaLabel">¿Abandonar la sala?</h4>
|
||||
<p class="text-dark-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.min.js"></script>
|
||||
|
||||
<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>
|
||||
</html>
|
||||
+10
-55
@@ -1,13 +1,3 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Comprobación de sesión
|
||||
$isLoggedIn = isset($_SESSION['idUsuario']) && !empty($_SESSION['idUsuario']);
|
||||
$username = $isLoggedIn ? $_SESSION['nombreUsuario'] : '';
|
||||
?>
|
||||
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- FontAwesome para iconos -->
|
||||
@@ -17,7 +7,6 @@ $username = $isLoggedIn ? $_SESSION['nombreUsuario'] : '';
|
||||
<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">
|
||||
@@ -32,44 +21,8 @@ $username = $isLoggedIn ? $_SESSION['nombreUsuario'] : '';
|
||||
<div class="collapse navbar-collapse" id="navbarContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0"></ul>
|
||||
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<?php if ($isLoggedIn): ?>
|
||||
<!-- Menú desplegable cuando la sesión está iniciada -->
|
||||
<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">
|
||||
<i class="fa-solid fa-circle-user fa-lg text-warning"></i>
|
||||
<span><?= htmlspecialchars($username) ?></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>
|
||||
<?php else: ?>
|
||||
<!-- Botones que abren los modales cuando NO hay sesión iniciada -->
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
<!-- Contenedor dinámico cargado por js/cabecera.js -->
|
||||
<div class="d-flex align-items-center gap-3" id="contenedorUsuarioCabecera">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -95,11 +48,6 @@ $username = $isLoggedIn ? $_SESSION['nombreUsuario'] : '';
|
||||
<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>
|
||||
@@ -139,7 +87,14 @@ $username = $isLoggedIn ? $_SESSION['nombreUsuario'] : '';
|
||||
<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">
|
||||
|
||||
<!-- Checkbox Recuérdame -->
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input border-dark" type="checkbox" value="" id="recuerdameCheck">
|
||||
<label class="form-check-label fw-semibold" for="recuerdameCheck">
|
||||
Recuérdame en 10 días
|
||||
</label>
|
||||
</div>
|
||||
</form>
|
||||
<div id="errorRegistro" class="text-danger fw-bold mt-2"></div>
|
||||
</div>
|
||||
|
||||
@@ -12,40 +12,6 @@ class Categoria{
|
||||
$this->nombreCategoria = $nombreCategoria;
|
||||
}
|
||||
|
||||
|
||||
function crear(){
|
||||
$conexion = conexionBD();
|
||||
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
$consulta = $conexion->prepare("INSERT INTO categoria (nombreCategoria) VALUES (:nombreCategoria)");
|
||||
|
||||
$consulta->bindParam(':nombreCategoria', $this->nombreCategoria);
|
||||
|
||||
$consulta->execute();
|
||||
|
||||
$respuesta = [
|
||||
'exito' => 'Categoría creada correctamente',
|
||||
'exito_tecnico' => $this->nombreCategoria
|
||||
];
|
||||
|
||||
return $respuesta;
|
||||
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al guardar la categoría.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
|
||||
$conexion = null;
|
||||
return $respuesta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function listar(){
|
||||
$conexion = conexionBD();
|
||||
|
||||
@@ -73,77 +39,6 @@ class Categoria{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function buscar(){
|
||||
$conexion = conexionBD();
|
||||
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
$consulta = $conexion->prepare("SELECT * FROM categoria WHERE idCategoria = :idCategoria");
|
||||
|
||||
$consulta->bindParam(':idCategoria', $this->idCategoria);
|
||||
|
||||
$consulta->execute();
|
||||
|
||||
$resultado = $consulta->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
return $resultado;
|
||||
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al buscar la categoría.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
|
||||
$conexion = null;
|
||||
return $respuesta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function borrar(){
|
||||
$conexion = conexionBD();
|
||||
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
$consulta = $conexion->prepare("DELETE FROM categoria WHERE idCategoria = :idCategoria");
|
||||
|
||||
$consulta->bindParam(':idCategoria', $this->idCategoria);
|
||||
|
||||
$consulta->execute();
|
||||
|
||||
if($consulta->rowCount() > 0){
|
||||
$respuesta = [
|
||||
'exito' => 'Se eliminó correctamente la categoría',
|
||||
'exito_tecnico' => $this->idCategoria
|
||||
];
|
||||
}else{
|
||||
$respuesta = [
|
||||
'error' => 'No existe ninguna categoría con ese ID.',
|
||||
'error_tecnico' => $this->idCategoria
|
||||
];
|
||||
}
|
||||
|
||||
return $respuesta;
|
||||
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al eliminar la categoría.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
|
||||
$conexion = null;
|
||||
return $respuesta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -118,4 +118,30 @@ class EquipoxUsuario
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
|
||||
@@ -466,4 +467,25 @@ class Partida
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function contar()
|
||||
{
|
||||
$conexion = conexionBD();
|
||||
if (is_array($conexion)) {
|
||||
return $conexion;
|
||||
}
|
||||
try {
|
||||
$sql="SELECT COUNT(*) AS total FROM partida";
|
||||
$consulta = $conexion->prepare($sql);
|
||||
$consulta->execute();
|
||||
return (int) $consulta->fetchColumn();
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
"error" => "Ocurrió un error al obtener el listado.",
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+11
-43
@@ -1,3 +1,4 @@
|
||||
|
||||
<?php
|
||||
require_once __DIR__ . '/../includes/conexionBD.php';
|
||||
|
||||
@@ -56,58 +57,25 @@ class Pregunta {
|
||||
}
|
||||
}
|
||||
|
||||
public function cargarRespuestas() {
|
||||
if ($this->idPregunta === null) return;
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getTodosIds()//devuelve solamente los id de todas las preguntas
|
||||
{
|
||||
$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);
|
||||
|
||||
$consulta = $conexion->prepare("SELECT idPregunta FROM pregunta");
|
||||
$consulta->execute();
|
||||
return $consulta->fetchAll(PDO::FETCH_COLUMN);
|
||||
} catch (PDOException $error) {
|
||||
return [
|
||||
'error' => 'Ocurrió un error al cargar las respuestas.',
|
||||
"error" => "Ocurrió un error al obtener el listado.",
|
||||
'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()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-125
@@ -39,131 +39,7 @@ class Respuesta{
|
||||
return $respuesta;
|
||||
}
|
||||
}
|
||||
}//fin método insertar
|
||||
|
||||
public function listar(){
|
||||
$conexion = conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
$consulta = $conexion->prepare("SELECT * FROM respuesta");
|
||||
$consulta->execute();
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al obtener el listado.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
$conexion = null;
|
||||
return $respuesta;
|
||||
}
|
||||
}
|
||||
}//fin método listar
|
||||
|
||||
public function eliminar(){
|
||||
$conexion = conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
$consulta = $conexion->prepare("DELETE FROM respuesta WHERE idRespuesta=:idRespuesta");
|
||||
$consulta->bindParam(':idRespuesta', $this->idRespuesta);
|
||||
$consulta->execute();
|
||||
$respuesta = [
|
||||
'exito' => 'La respuesta se eliminó correctamente.',
|
||||
'exito_tecnico' => $this->idRespuesta
|
||||
];
|
||||
return $respuesta;
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'No se pudo eliminar la respuesta.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
$conexion = null;
|
||||
return $respuesta;
|
||||
}
|
||||
}
|
||||
}//fin método eliminar
|
||||
|
||||
public function editar(){
|
||||
$conexion = conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
$consulta = $conexion->prepare("UPDATE respuesta SET idPregunta=:idPregunta, nombreRespuesta=:nombreRespuesta, correcta=:correcta WHERE idRespuesta=:idRespuesta");
|
||||
$consulta->bindParam(':idRespuesta', $this->idRespuesta);
|
||||
$consulta->bindParam(':idPregunta', $this->idPregunta);
|
||||
$consulta->bindParam(':nombreRespuesta', $this->nombreRespuesta);
|
||||
$consulta->bindParam(':correcta', $this->correcta);
|
||||
$consulta->execute();
|
||||
$respuesta = [
|
||||
'exito' => 'La respuesta se editó correctamente.',
|
||||
'exito_tecnico' => $this->idRespuesta
|
||||
];
|
||||
return $respuesta;
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al editar la respuesta.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
$conexion = null;
|
||||
return $respuesta;
|
||||
}
|
||||
}
|
||||
}//fin método editar
|
||||
|
||||
public function buscar(){
|
||||
$conexion = conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
$consulta = $conexion->prepare("SELECT * FROM respuesta WHERE idRespuesta=:idRespuesta");
|
||||
$consulta->bindParam(':idRespuesta', $this->idRespuesta);
|
||||
$consulta->execute();
|
||||
return $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al buscar la respuesta.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
$conexion = null;
|
||||
return $respuesta;
|
||||
}
|
||||
}
|
||||
}//fin método buscar
|
||||
|
||||
public function listarPorPregunta(){//trae todas las respuestas posibles de una pregunta
|
||||
$conexion = conexionBD();
|
||||
if(is_array($conexion)){
|
||||
return $conexion;
|
||||
}else{
|
||||
try{
|
||||
$consulta = $conexion->prepare("SELECT * FROM respuesta WHERE idPregunta=:idPregunta");
|
||||
$consulta->bindParam(':idPregunta', $this->idPregunta);
|
||||
$consulta->execute();
|
||||
$resultado = $consulta->fetchAll(PDO::FETCH_ASSOC);
|
||||
if(!isset($resultado[0])){
|
||||
$respuesta = [
|
||||
'error' => 'La pregunta no tiene respuestas.'
|
||||
];
|
||||
return $respuesta;
|
||||
}else{
|
||||
return $resultado;
|
||||
}
|
||||
}catch(PDOException $error){
|
||||
$respuesta = [
|
||||
'error' => 'Ocurrió un error al obtener las respuestas de la pregunta.',
|
||||
'error_tecnico' => $error->getMessage()
|
||||
];
|
||||
$conexion = null;
|
||||
return $respuesta;
|
||||
}
|
||||
}
|
||||
}//fin método listarPorPregunta
|
||||
|
||||
}//fin método insertar
|
||||
}//fin clase
|
||||
|
||||
?>
|
||||
@@ -6,22 +6,6 @@ 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();
|
||||
@@ -29,27 +13,4 @@ switch ($_POST['orden']) {
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<?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;
|
||||
|
||||
}
|
||||
@@ -75,4 +75,16 @@ switch ($_POST['orden']) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ require_once '../clases/ClasePartida.php';
|
||||
require_once '../clases/ClaseEquipo.php';
|
||||
require_once '../clases/ClaseEquipoxUsuario.php';
|
||||
require_once '../clases/ClaseEquipoxPartida.php';
|
||||
require_once '../clases/ClasePregunta.php';
|
||||
|
||||
|
||||
switch ($_POST['orden']) {
|
||||
@@ -119,6 +120,7 @@ switch ($_POST['orden']) {
|
||||
}
|
||||
|
||||
$idPartida = (int)$resultadoPartida['exito_tecnico'];
|
||||
$partida->idPartida = $idPartida;
|
||||
|
||||
|
||||
/*
|
||||
@@ -211,6 +213,42 @@ switch ($_POST['orden']) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ==========================================
|
||||
* 5. ASIGNAMOS 10 PREGUNTAS ALEATORIAS A LA PARTIDA
|
||||
* ==========================================
|
||||
*/
|
||||
|
||||
// Obtenemos todos los IDs de las preguntas
|
||||
|
||||
$listaPreguntas = Pregunta::getTodosIds();
|
||||
|
||||
$totalPreguntas = count($listaPreguntas);
|
||||
|
||||
// Guardamos las preguntas que ya hemos asignado
|
||||
$preguntasAsignadas = [];
|
||||
|
||||
// Generamos 10 posiciones aleatorias sin repetir
|
||||
while (count($preguntasAsignadas) < 10) {
|
||||
|
||||
// Generamos una posición aleatoria del array
|
||||
$posicionAleatoria = rand(0, $totalPreguntas - 1);
|
||||
|
||||
// Obtenemos el ID real de la pregunta
|
||||
$idPreguntaAleatoria = $listaPreguntas[$posicionAleatoria];
|
||||
|
||||
// Comprobamos que esa pregunta no haya sido asignada ya
|
||||
if (!in_array($idPreguntaAleatoria, $preguntasAsignadas)) {
|
||||
$preguntasAsignadas[] = $idPreguntaAleatoria;
|
||||
|
||||
// Asignamos el ID real de la pregunta a la partida
|
||||
$partida->asignarPregunta($idPreguntaAleatoria);
|
||||
}
|
||||
}//fin shile
|
||||
|
||||
|
||||
/*
|
||||
* ==========================================
|
||||
* TODO CORRECTO
|
||||
@@ -218,7 +256,7 @@ switch ($_POST['orden']) {
|
||||
*/
|
||||
|
||||
echo json_encode([
|
||||
'exito' => 'Sala creada correctamente.',
|
||||
'exito' => 'Sala creada correctamente. Preguntas preparadas.',
|
||||
'idPartida' => $resultadoPartida['exito_tecnico'],
|
||||
'idEquipo1' => $equipo1->idEquipo,
|
||||
'idEquipo2' => $equipo2->idEquipo
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
session_start();
|
||||
|
||||
require_once '../clases/ClasePregunta.php';
|
||||
require_once '../clases/ClaseRespuesta.php';
|
||||
|
||||
switch ($_POST['orden']) {
|
||||
|
||||
@@ -11,43 +12,113 @@ switch ($_POST['orden']) {
|
||||
$idCategoria = intval($_POST['idCategoria'] ?? 0);
|
||||
$nombrePregunta = trim($_POST['nombrePregunta'] ?? '');
|
||||
|
||||
if ($idCategoria <= 0 || $nombrePregunta == '') {
|
||||
echo json_encode(['error' => 'La categoría y el texto de la pregunta son obligatorios']);
|
||||
$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;
|
||||
}
|
||||
|
||||
$pregunta = new Pregunta($idCategoria, $nombrePregunta);
|
||||
$resultado = $pregunta->guardar();
|
||||
|
||||
echo json_encode($resultado);
|
||||
break;
|
||||
/*
|
||||
* ==========================================
|
||||
* 1. CREAMOS LA PREGUNTA
|
||||
* ==========================================
|
||||
*/
|
||||
|
||||
$pregunta = new Pregunta(
|
||||
$idCategoria,
|
||||
$nombrePregunta
|
||||
);
|
||||
|
||||
$resultadoPregunta = $pregunta->guardar();
|
||||
|
||||
|
||||
case 'obtenerPreguntasPorCategoria':
|
||||
if (isset($resultadoPregunta['error'])) {
|
||||
|
||||
$idCategoria = intval($_POST['idCategoria'] ?? 0);
|
||||
$limite = intval($_POST['limite'] ?? 10);
|
||||
echo json_encode($resultadoPregunta);
|
||||
|
||||
$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()
|
||||
];
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($listado);
|
||||
break;
|
||||
|
||||
/*
|
||||
* ==========================================
|
||||
* 3. TODO CORRECTO
|
||||
* ==========================================
|
||||
*/
|
||||
|
||||
echo json_encode([
|
||||
'exito' => 'Pregunta creada correctamente.',
|
||||
'idPregunta' => $idPregunta
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?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;
|
||||
|
||||
}
|
||||
@@ -47,7 +47,7 @@ switch ($_POST['orden']) {
|
||||
|
||||
|
||||
case 'comprobarUsuario':
|
||||
|
||||
|
||||
$email = trim($_POST['email'] ?? '');
|
||||
$contrasena = $_POST['contrasena'] ?? '';
|
||||
|
||||
@@ -55,6 +55,13 @@ switch ($_POST['orden']) {
|
||||
|
||||
if ($resultado instanceof Usuario) {
|
||||
|
||||
// === GUARDAR EN SESIÓN (incluido avatar)===
|
||||
$_SESSION['idUsuario'] = $resultado->getIdUsuario();
|
||||
$_SESSION['nombreUsuario'] = $resultado->getNombreUsuario();
|
||||
$_SESSION['email'] = $resultado->getEmail();
|
||||
$_SESSION['avatar'] = $resultado->getAvatar();
|
||||
// =================================================
|
||||
|
||||
echo json_encode([
|
||||
'exito' => 'Login correcto',
|
||||
'idUsuario' => $resultado->getIdUsuario(),
|
||||
@@ -77,6 +84,7 @@ switch ($_POST['orden']) {
|
||||
unset($_SESSION['idUsuario']);
|
||||
unset($_SESSION['email']);
|
||||
unset($_SESSION['nombreUsuario']);
|
||||
unset($_SESSION['avatar']);
|
||||
|
||||
// Destruimos la sesión
|
||||
session_destroy();
|
||||
@@ -86,7 +94,6 @@ switch ($_POST['orden']) {
|
||||
]);
|
||||
|
||||
break;
|
||||
|
||||
case 'mostrarEstadisticas':
|
||||
|
||||
$usuario = Usuario::buscarPorId($_SESSION['idUsuario']);
|
||||
@@ -229,4 +236,19 @@ switch ($_POST['orden']) {
|
||||
'ranking' => $ranking
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'comprobarSesion':
|
||||
if (isset($_SESSION['idUsuario']) && !empty($_SESSION['idUsuario'])) {
|
||||
echo json_encode([
|
||||
'activa' => true,
|
||||
'usuario' => [
|
||||
'idUsuario' => $_SESSION['idUsuario'],
|
||||
'nombreUsuario' => $_SESSION['nombreUsuario'] ?? '',
|
||||
'avatar' => $_SESSION['avatar'] ?? ''
|
||||
]
|
||||
]);
|
||||
} else {
|
||||
echo json_encode(['activa' => false]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+10
-2
@@ -68,8 +68,8 @@
|
||||
|
||||
.btn-unirse {
|
||||
border: none;
|
||||
border-bottom: 3px solid #0c4891;
|
||||
background-color: var(--kahoot-blue);
|
||||
border-bottom: 3px solid #1f6f09;
|
||||
background-color: #26890c;
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
border-radius: 8px;
|
||||
@@ -105,3 +105,11 @@
|
||||
border-color: var(--kahoot-purple);
|
||||
box-shadow: 0 0 0 3px rgba(70, 23, 143, 0.15);
|
||||
}
|
||||
|
||||
.jugador-host {
|
||||
background-color: #fff3cd;
|
||||
border: 1px solid #ffc107;
|
||||
border-radius: 8px;
|
||||
padding: 6px 10px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
@@ -1,8 +1,3 @@
|
||||
<?php
|
||||
|
||||
include 'cabecera.php';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="es-ES">
|
||||
|
||||
@@ -10,28 +5,26 @@ include 'cabecera.php';
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<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>
|
||||
|
||||
<?php include 'cabecera.php'; ?>
|
||||
|
||||
<div class="container my-5">
|
||||
<div class="row justify-content-center align-items-center g-4">
|
||||
|
||||
<!-- Botón Jugar (solo se muestra si está logueado) -->
|
||||
<?php if ($isLoggedIn): ?>
|
||||
<div class="col-12 col-lg-5 col-xl-4">
|
||||
<a href="buscadorSala.php" class="btn btn-play-kahoot" id="btnJugar">
|
||||
<i class="fa-solid fa-play"></i>
|
||||
<span>¡JUGAR!</span>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<!-- Botón Jugar (oculto por defecto, JS lo muestra si hay sesión activa) -->
|
||||
<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 <?= $isLoggedIn ? 'col-lg-7 col-xl-8' : 'col-lg-8' ?>">
|
||||
<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>
|
||||
|
||||
+305
-528
@@ -1,634 +1,411 @@
|
||||
let usuarioYaEstaEnEquipo = false;
|
||||
|
||||
$(document).ready(function () {
|
||||
comprobarSalaUsuario();
|
||||
comprobarSalaUsuario();
|
||||
});
|
||||
|
||||
// 1. Comprobar si el usuario actual ya pertenece a una sala
|
||||
function comprobarSalaUsuario() {
|
||||
$("#cargandoSalas").remove();
|
||||
|
||||
$("#cargandoSalas").remove();
|
||||
|
||||
$.ajax({
|
||||
$.ajax({
|
||||
url: "controladores/ControladorEquipoxUsuario.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
|
||||
data: {
|
||||
orden: "obtenerSalaUsuario"
|
||||
},
|
||||
|
||||
data: { orden: "obtenerSalaUsuario" },
|
||||
success: function (respuesta) {
|
||||
|
||||
console.log("Sala del usuario:", respuesta);
|
||||
|
||||
if (respuesta.error) {
|
||||
|
||||
console.error(respuesta.error);
|
||||
|
||||
usuarioYaEstaEnEquipo = false;
|
||||
|
||||
cargarSalas();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (respuesta.asociado) {
|
||||
|
||||
usuarioYaEstaEnEquipo = true;
|
||||
|
||||
$("#contenedorCrearSala").hide();
|
||||
|
||||
cargarSalaUsuario(respuesta.idPartida);
|
||||
|
||||
} else {
|
||||
|
||||
usuarioYaEstaEnEquipo = false;
|
||||
|
||||
cargarSalas();
|
||||
}
|
||||
},
|
||||
|
||||
error: function (xhr, status, error) {
|
||||
|
||||
console.error(
|
||||
"Error al comprobar la sala del usuario:",
|
||||
error
|
||||
);
|
||||
|
||||
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({
|
||||
$.ajax({
|
||||
url: "controladores/controladorPartida.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
|
||||
data: {
|
||||
orden: "buscar",
|
||||
idPartida: idPartida
|
||||
},
|
||||
|
||||
data: { orden: "buscar", idPartida: idPartida },
|
||||
success: function (partida) {
|
||||
|
||||
if (partida.error) {
|
||||
|
||||
console.error(partida.error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$("#contenedorSalas").empty();
|
||||
|
||||
cargarInformacionSala(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
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
console.error("Error al obtener la sala del usuario:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 3. Cargar la lista completa de todas las salas
|
||||
function cargarSalas() {
|
||||
|
||||
$.ajax({
|
||||
$.ajax({
|
||||
url: "controladores/controladorPartida.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
|
||||
data: {
|
||||
orden: "listar"
|
||||
},
|
||||
|
||||
data: { orden: "listar" },
|
||||
success: function (partidas) {
|
||||
const contenedor = $("#contenedorSalas");
|
||||
contenedor.empty();
|
||||
|
||||
const contenedor = $("#contenedorSalas");
|
||||
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;
|
||||
}
|
||||
|
||||
contenedor.empty();
|
||||
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.
|
||||
</p>
|
||||
</div>
|
||||
`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
partidas.forEach(function (partida) {
|
||||
|
||||
cargarInformacionSala(partida);
|
||||
|
||||
});
|
||||
partidas.forEach(function (partida) {
|
||||
cargarInformacionSala(partida);
|
||||
});
|
||||
},
|
||||
|
||||
error: function (xhr, status, error) {
|
||||
|
||||
console.error(
|
||||
"Error al obtener las partidas:",
|
||||
error
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
console.error("Error al obtener las partidas:", error);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 4. Obtener equipos y jugadores asociados a una sala concreta
|
||||
function cargarInformacionSala(partida) {
|
||||
|
||||
$.ajax({
|
||||
$.ajax({
|
||||
url: "controladores/controladorPartida.php",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
|
||||
data: {
|
||||
orden: "getEquipos",
|
||||
idPartida: partida.idPartida
|
||||
},
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
});
|
||||
$.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
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
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 = "";
|
||||
|
||||
const contenedor = $("#contenedorSalas");
|
||||
|
||||
let equiposHTML = "";
|
||||
|
||||
equipos.forEach(function (equipo) {
|
||||
|
||||
equipos.forEach(function (equipo) {
|
||||
const jugadoresEquipo = jugadores.filter(function (jugador) {
|
||||
|
||||
return jugador.idEquipo == equipo.idEquipo;
|
||||
|
||||
return jugador.idEquipo == equipo.idEquipo;
|
||||
});
|
||||
|
||||
let jugadoresHTML = "";
|
||||
|
||||
if (jugadoresEquipo.length > 0) {
|
||||
jugadoresEquipo.forEach(function (jugador) {
|
||||
const esHost = jugador.idUsuario == partida.idUsuario;
|
||||
|
||||
jugadoresEquipo.forEach(function (jugador) {
|
||||
|
||||
jugadoresHTML += `
|
||||
<div class="jugador">
|
||||
|
||||
<span class="avatar">
|
||||
👤
|
||||
</span>
|
||||
|
||||
${escapeHTML(jugador.nombreUsuario)}
|
||||
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
jugadoresHTML += `
|
||||
<div class="jugador border border-2 d-flex align-items-center justify-content-between ${
|
||||
esHost ? "jugador-host" : ""
|
||||
}">
|
||||
<div>
|
||||
<span class="avatar">${esHost ? "👑" : "👤"}</span>
|
||||
${escapeHTML(jugador.nombreUsuario)}
|
||||
</div>
|
||||
|
||||
${
|
||||
esHost
|
||||
? `<span class="badge bg-warning text-dark ms-2">HOST</span>`
|
||||
: ""
|
||||
}
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
} else {
|
||||
|
||||
jugadoresHTML = `
|
||||
<div class="text-muted small">
|
||||
Sin jugadores
|
||||
</div>
|
||||
`;
|
||||
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"
|
||||
botonUnirseHTML = `
|
||||
<button type="button" class="btn-unirse w-100 btn-unirse-equipo mt-2"
|
||||
data-id-partida="${partida.idPartida}"
|
||||
data-id-equipo="${equipo.idEquipo}">
|
||||
|
||||
Unirse
|
||||
|
||||
</button>
|
||||
`;
|
||||
Unirse
|
||||
</button>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
equiposHTML += `
|
||||
<div class="equipo">
|
||||
|
||||
<h6>
|
||||
${escapeHTML(equipo.nombreEquipo)}
|
||||
</h6>
|
||||
|
||||
<div class="jugadores">
|
||||
|
||||
${jugadoresHTML}
|
||||
|
||||
</div>
|
||||
|
||||
${botonUnirseHTML}
|
||||
|
||||
<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
|
||||
// Acciones disponibles si el usuario YA ESTÁ dentro de esta sala
|
||||
let accionesSalaHTML = "";
|
||||
|
||||
const salaHTML = `
|
||||
<div class="col-12 col-md-10 col-lg-8">
|
||||
if (usuarioYaEstaEnEquipo) {
|
||||
let botonIniciarHTML = "";
|
||||
|
||||
<div class="sala">
|
||||
// Solo el host puede iniciar la partida
|
||||
if (partida.idUsuario == idUsuarioSesion) {
|
||||
botonIniciarHTML = `
|
||||
<a href="juego.php?idPartida=${partida.idPartida}"
|
||||
class="btn btn-success btn-lg px-4">
|
||||
🎮 ¡Iniciar Partida!
|
||||
</a>
|
||||
`;
|
||||
}
|
||||
|
||||
<div class="sala-header">
|
||||
accionesSalaHTML = `
|
||||
<div class="sala-acciones text-center mt-4 pt-3 border-top d-flex justify-content-center gap-3">
|
||||
|
||||
${escapeHTML(partida.nombrePartida)}
|
||||
<button type="button"
|
||||
class="btn btn-outline-danger btn-abandonar-sala"
|
||||
data-id-partida="${partida.idPartida}">
|
||||
Abandonar sala
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="sala-body">
|
||||
|
||||
<div class="equipos">
|
||||
|
||||
${equiposHTML}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
${botonIniciarHTML}
|
||||
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
||||
contenedor.append(salaHTML);
|
||||
`;
|
||||
}
|
||||
|
||||
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 text-white">
|
||||
${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);
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
// UNIRSE A UN EQUIPO
|
||||
// ======================================================
|
||||
// 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");
|
||||
|
||||
$(document).on(
|
||||
"click",
|
||||
".btn-unirse-equipo",
|
||||
function () {
|
||||
boton.prop("disabled", true).text("Uniéndose...");
|
||||
|
||||
const boton = $(this);
|
||||
$.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;
|
||||
}
|
||||
|
||||
const idEquipo = boton.data("id-equipo");
|
||||
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");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const idPartida = boton.data("id-partida");
|
||||
// 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();
|
||||
});
|
||||
|
||||
boton.prop("disabled", true);
|
||||
// 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);
|
||||
|
||||
boton.text("Uniéndose...");
|
||||
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");
|
||||
|
||||
$.ajax({
|
||||
if (modalInstance) {
|
||||
modalInstance.hide();
|
||||
}
|
||||
|
||||
url: "controladores/ControladorEquipoxUsuario.php",
|
||||
if (respuesta.error) {
|
||||
alert(respuesta.error);
|
||||
return;
|
||||
}
|
||||
|
||||
type: "POST",
|
||||
// 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();
|
||||
|
||||
dataType: "json",
|
||||
let valido = true;
|
||||
$(".mensaje-error-sala").remove();
|
||||
$(".input-kahoot").removeClass("is-invalid");
|
||||
|
||||
data: {
|
||||
orden: "registrarUsuarioEnEquipo",
|
||||
idEquipo: idEquipo
|
||||
},
|
||||
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;
|
||||
}
|
||||
|
||||
success: function (respuesta) {
|
||||
if (nombreEquipo2 === "" || nombreEquipo2.length < 2) {
|
||||
mostrarError(
|
||||
"#nombreEquipo2",
|
||||
"El nombre del equipo debe tener al menos 2 caracteres.",
|
||||
);
|
||||
valido = false;
|
||||
}
|
||||
|
||||
console.log(
|
||||
"Respuesta al unirse:",
|
||||
respuesta
|
||||
);
|
||||
if (
|
||||
nombreEquipo1 !== "" &&
|
||||
nombreEquipo2 !== "" &&
|
||||
nombreEquipo1.toLowerCase() === nombreEquipo2.toLowerCase()
|
||||
) {
|
||||
mostrarError(
|
||||
"#nombreEquipo2",
|
||||
"Los dos equipos deben tener nombres diferentes.",
|
||||
);
|
||||
valido = false;
|
||||
}
|
||||
|
||||
if (!valido) return;
|
||||
|
||||
if (respuesta.error) {
|
||||
const boton = $("#btnCrearSala");
|
||||
boton.prop("disabled", true).text("Creando sala...");
|
||||
|
||||
alert(respuesta.error);
|
||||
$.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;
|
||||
}
|
||||
|
||||
boton.prop("disabled", false);
|
||||
|
||||
boton.text("Unirse");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// ==========================================
|
||||
// UNIÓN CORRECTA
|
||||
// ==========================================
|
||||
|
||||
usuarioYaEstaEnEquipo = true;
|
||||
|
||||
|
||||
// Ocultamos el botón "Crear sala"
|
||||
|
||||
$("#contenedorCrearSala").hide();
|
||||
|
||||
|
||||
// Eliminamos las salas actuales
|
||||
|
||||
$("#contenedorSalas").empty();
|
||||
|
||||
|
||||
// Cargamos directamente la sala
|
||||
// donde acaba de entrar el usuario
|
||||
|
||||
cargarSalaUsuario(idPartida);
|
||||
},
|
||||
|
||||
|
||||
error: function (xhr, status, error) {
|
||||
|
||||
console.error(
|
||||
"Error al unirse al equipo:",
|
||||
error
|
||||
);
|
||||
|
||||
console.error(
|
||||
"Respuesta del servidor:",
|
||||
xhr.responseText
|
||||
);
|
||||
|
||||
|
||||
alert(
|
||||
"No se ha podido unir al equipo."
|
||||
);
|
||||
|
||||
|
||||
boton.prop("disabled", false);
|
||||
|
||||
boton.text("Unirse");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
);
|
||||
|
||||
// ======================================================
|
||||
// ESCAPAR HTML
|
||||
// ======================================================
|
||||
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>")
|
||||
return $("<div>")
|
||||
.text(texto ?? "")
|
||||
.html();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
// 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 === '') {
|
||||
|
||||
mostrarError(
|
||||
'#nombreSala',
|
||||
'El nombre de la sala es obligatorio.'
|
||||
);
|
||||
|
||||
valido = false;
|
||||
|
||||
} else if (nombreSala.length < 3) {
|
||||
|
||||
mostrarError(
|
||||
'#nombreSala',
|
||||
'El nombre de la sala debe tener al menos 3 caracteres.'
|
||||
);
|
||||
|
||||
valido = false;
|
||||
}
|
||||
|
||||
if (nombreEquipo1 === '') {
|
||||
|
||||
mostrarError(
|
||||
'#nombreEquipo1',
|
||||
'El nombre del equipo 1 es obligatorio.'
|
||||
);
|
||||
|
||||
valido = false;
|
||||
|
||||
} else if (nombreEquipo1.length < 2) {
|
||||
|
||||
mostrarError(
|
||||
'#nombreEquipo1',
|
||||
'El nombre del equipo debe tener al menos 2 caracteres.'
|
||||
);
|
||||
|
||||
valido = false;
|
||||
}
|
||||
|
||||
if (nombreEquipo2 === '') {
|
||||
|
||||
mostrarError(
|
||||
'#nombreEquipo2',
|
||||
'El nombre del equipo 2 es obligatorio.'
|
||||
);
|
||||
|
||||
valido = false;
|
||||
|
||||
} else if (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;
|
||||
}
|
||||
|
||||
// Deshabilitamos el botón mientras se crea la sala
|
||||
const boton = $('#btnCrearSala');
|
||||
|
||||
boton.prop('disabled', true);
|
||||
boton.text('Creando sala...');
|
||||
|
||||
$.ajax({
|
||||
url: 'controladores/controladorPartida.php', // <-- cambia esto por la ruta de tu controlador
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
orden: 'crear',
|
||||
nombrePartida: nombreSala,
|
||||
nombreEquipo1: nombreEquipo1,
|
||||
nombreEquipo2: nombreEquipo2
|
||||
},
|
||||
|
||||
success: function (respuesta) {
|
||||
|
||||
console.log('Respuesta del servidor:', respuesta);
|
||||
|
||||
if (respuesta.error) {
|
||||
|
||||
alert(respuesta.error);
|
||||
|
||||
boton.prop('disabled', false);
|
||||
boton.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);
|
||||
console.error('Respuesta:', xhr.responseText);
|
||||
|
||||
alert('No se ha podido crear la sala.');
|
||||
|
||||
boton.prop('disabled', false);
|
||||
boton.text('Crear sala');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// ======================================================
|
||||
// MOSTRAR ERROR
|
||||
// ======================================================
|
||||
|
||||
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>
|
||||
`);
|
||||
|
||||
|
||||
const input = $(selector);
|
||||
input.addClass("is-invalid");
|
||||
input.after(
|
||||
`<div class="mensaje-error-sala text-danger mt-1 small">${mensaje}</div>`,
|
||||
);
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
// QUITAR ERROR AL ESCRIBIR
|
||||
// ======================================================
|
||||
|
||||
$(".input-kahoot").on(
|
||||
"input",
|
||||
function () {
|
||||
|
||||
$(this).removeClass(
|
||||
"is-invalid"
|
||||
);
|
||||
|
||||
$(this)
|
||||
.next(".mensaje-error-sala")
|
||||
.remove();
|
||||
}
|
||||
|
||||
|
||||
);
|
||||
$(document).on("input", ".input-kahoot", function () {
|
||||
$(this).removeClass("is-invalid");
|
||||
$(this).next(".mensaje-error-sala").remove();
|
||||
});
|
||||
|
||||
+200
-116
@@ -1,133 +1,217 @@
|
||||
// Registro
|
||||
$("#botonAceptarRegistro").click(function (event) {
|
||||
event.preventDefault();
|
||||
console.log("hola");
|
||||
let nombreUsuario = $("#regNombre").val().trim();
|
||||
let email = $("#regEmail").val().trim();
|
||||
let contrasena = $("#regPassword").val();
|
||||
let contrasenaConfirmacion = $("#regPasswordConfirm").val();
|
||||
let idUsuarioSesion = null;
|
||||
|
||||
// Limpiamos errores anteriores
|
||||
$("#regNombre").removeClass("is-invalid");
|
||||
$("#regEmail").removeClass("is-invalid");
|
||||
$("#regPassword").removeClass("is-invalid");
|
||||
$("#regPasswordConfirm").removeClass("is-invalid");
|
||||
$("#errorRegistro").text("");
|
||||
$(document).ready(function () {
|
||||
// Comprobar la sesión activa al cargar la página
|
||||
comprobarEstadoSesion();
|
||||
|
||||
// Comprobamos que las contraseñas coincidan
|
||||
if (contrasena !== contrasenaConfirmacion) {
|
||||
$("#regPassword").addClass("is-invalid");
|
||||
$("#regPasswordConfirm").addClass("is-invalid");
|
||||
// Evento Click: Login
|
||||
$('#botonAceptarLogin').on('click', function () {
|
||||
ejecutarLogin();
|
||||
});
|
||||
|
||||
$("#errorRegistro").text("Las contraseñas no coinciden.");
|
||||
// Permitir Submit con tecla Enter en el formulario de Login
|
||||
$('#formLogin').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
ejecutarLogin();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
// Evento Click: Registro
|
||||
$('#botonAceptarRegistro').on('click', function () {
|
||||
ejecutarRegistro();
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: {
|
||||
nombreUsuario: nombreUsuario,
|
||||
email: email,
|
||||
contrasena: contrasena,
|
||||
orden: "registrarUsuario",
|
||||
},
|
||||
}).done(function (respuesta) {
|
||||
//console.log(respuesta);
|
||||
respuesta = JSON.parse(respuesta);
|
||||
if (respuesta.error) {
|
||||
$("#errorRegistro").text(respuesta.error);
|
||||
|
||||
// Marcamos los campos si hay error
|
||||
$("#regNombre").addClass("is-invalid");
|
||||
$("#regEmail").addClass("is-invalid");
|
||||
} else {
|
||||
// Registro correcto
|
||||
$("#errorRegistro")
|
||||
.removeClass("text-danger")
|
||||
.addClass("text-success")
|
||||
.text(respuesta.exito);
|
||||
|
||||
// Limpiamos formulario
|
||||
$("#formRegistro")[0].reset();
|
||||
|
||||
// Cerramos modal después de un segundo
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
}); // Fin función ajax
|
||||
// Permitir Submit con tecla Enter en el formulario de Registro
|
||||
$('#formRegistro').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
ejecutarRegistro();
|
||||
});
|
||||
});
|
||||
|
||||
// Login
|
||||
$("#botonAceptarLogin").click(function (event) {
|
||||
event.preventDefault();
|
||||
/**
|
||||
* Comprueba con el servidor si existe una sesión PHP
|
||||
*/
|
||||
function comprobarEstadoSesion() {
|
||||
$.ajax({
|
||||
url: 'controladores/controladorUsuario.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { orden: 'comprobarSesion' },
|
||||
success: function (respuesta) {
|
||||
if (respuesta.activa) {
|
||||
idUsuarioSesion = respuesta.usuario.idUsuario;
|
||||
renderizarCabeceraConSesion(respuesta.usuario);
|
||||
$('#colBotonJugar').removeClass('d-none');
|
||||
} else {
|
||||
renderizarCabeceraSinSesion();
|
||||
$('#colBotonJugar').addClass('d-none');
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
renderizarCabeceraSinSesion();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let email = $("#loginEmail").val().trim();
|
||||
let contrasena = $("#loginPassword").val();
|
||||
/**
|
||||
* Petición AJAX para iniciar sesión
|
||||
*/
|
||||
function ejecutarLogin() {
|
||||
let email = $('#loginEmail').val().trim();
|
||||
let contrasena = $('#loginPassword').val().trim();
|
||||
$('#errorLogin').text('');
|
||||
|
||||
// Limpiamos errores anteriores
|
||||
$("#loginEmail").removeClass("is-invalid");
|
||||
$("#loginPassword").removeClass("is-invalid");
|
||||
$("#errorLogin").text("");
|
||||
|
||||
// Comprobación básica
|
||||
if (email === "" || contrasena === "") {
|
||||
$("#errorLogin").text("Todos los campos son obligatorios.");
|
||||
|
||||
if (email === "") {
|
||||
$("#loginEmail").addClass("is-invalid");
|
||||
if (email === '' || contrasena === '') {
|
||||
$('#errorLogin').text('Por favor, rellena todos los campos.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (contrasena === "") {
|
||||
$("#loginPassword").addClass("is-invalid");
|
||||
$.ajax({
|
||||
url: 'controladores/controladorUsuario.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
orden: 'comprobarUsuario',
|
||||
email: email,
|
||||
contrasena: contrasena
|
||||
},
|
||||
success: function (respuesta) {
|
||||
if (respuesta.error) {
|
||||
$('#errorLogin').text(respuesta.error);
|
||||
} else if (respuesta.exito) {
|
||||
$('#modalLogin').modal('hide');
|
||||
$('#formLogin')[0].reset();
|
||||
|
||||
// Cargar datos de la sesión actualizados
|
||||
comprobarEstadoSesion();
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$('#errorLogin').text('Error al conectar con el servidor.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Petición AJAX para registrar un usuario
|
||||
*/
|
||||
function ejecutarRegistro() {
|
||||
let nombre = $('#regNombre').val().trim();
|
||||
let email = $('#regEmail').val().trim();
|
||||
let pass = $('#regPassword').val().trim();
|
||||
let passConfirm = $('#regPasswordConfirm').val().trim();
|
||||
|
||||
$('#errorRegistro').text('');
|
||||
|
||||
if (nombre === '' || email === '' || pass === '') {
|
||||
$('#errorRegistro').text('Todos los campos son obligatorios.');
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: {
|
||||
email: email,
|
||||
contrasena: contrasena,
|
||||
orden: "comprobarUsuario",
|
||||
},
|
||||
}).done(function (respuesta) {
|
||||
//console.log(respuesta);
|
||||
respuesta = JSON.parse(respuesta);
|
||||
if (respuesta.error) {
|
||||
$("#loginEmail").addClass("is-invalid");
|
||||
$("#loginPassword").addClass("is-invalid");
|
||||
|
||||
$("#errorLogin").text(respuesta.error);
|
||||
} else {
|
||||
location.reload();
|
||||
if (pass !== passConfirm) {
|
||||
$('#errorRegistro').text('Las contraseñas no coinciden.');
|
||||
return;
|
||||
}
|
||||
}); // Fin función ajax
|
||||
});
|
||||
|
||||
// Cerrar sesión
|
||||
$("#botonCerrarSesion").click(function (event) {
|
||||
event.preventDefault();
|
||||
$.ajax({
|
||||
url: 'controladores/controladorUsuario.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
orden: 'registrarUsuario',
|
||||
nombreUsuario: nombre,
|
||||
email: email,
|
||||
contrasena: pass
|
||||
},
|
||||
success: function (respuesta) {
|
||||
if (respuesta.error) {
|
||||
$('#errorRegistro').text(respuesta.error);
|
||||
} else {
|
||||
$('#modalRegistro').modal('hide');
|
||||
$('#formRegistro')[0].reset();
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
data: {
|
||||
orden: "cerrarSesion",
|
||||
},
|
||||
}).done(function (respuesta) {
|
||||
//console.log(respuesta);
|
||||
respuesta = JSON.parse(respuesta);
|
||||
if (respuesta.error) {
|
||||
console.log(respuesta.error);
|
||||
} else {
|
||||
// Sesión cerrada correctamente
|
||||
window.location.href = 'index.php';
|
||||
// Autologin tras registrarse
|
||||
$('#loginEmail').val(email);
|
||||
$('#loginPassword').val(pass);
|
||||
ejecutarLogin();
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$('#errorRegistro').text('Error al procesar el registro.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}); // Fin función ajax
|
||||
}); // Fin función click
|
||||
/**
|
||||
* Petición AJAX para cerrar la sesión
|
||||
*/
|
||||
function cerrarSesion() {
|
||||
$.ajax({
|
||||
url: 'controladores/controladorUsuario.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { orden: 'cerrarSesion' },
|
||||
success: function () {
|
||||
renderizarCabeceraSinSesion();
|
||||
$('#colBotonJugar').addClass('d-none');
|
||||
|
||||
if (window.location.pathname.includes('perfil.php') || window.location.pathname.includes('buscadorSala.php')) {
|
||||
window.location.href = 'index.php';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza la cabecera cuando HAY sesión iniciada
|
||||
*/
|
||||
function renderizarCabeceraConSesion(usuario) {
|
||||
//Mete el avatar en cabecera
|
||||
let avatarImg = (usuario.avatar && usuario.avatar !== '')
|
||||
? usuario.avatar
|
||||
: 'img/avatars/defaultProfile.jpeg';
|
||||
|
||||
// Refrescar avatar si se cambia
|
||||
let avatarConCacheBuster = avatarImg + '?v=' + new Date().getTime();
|
||||
|
||||
let html = `
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-outline-light dropdown-toggle d-flex align-items-center gap-2 rounded-pill px-3 py-1 fw-bold" type="button" id="userMenu" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<img src="${avatarConCacheBuster}" alt="Avatar" class="rounded-circle border" style="width: 32px; height: 32px; object-fit: cover;">
|
||||
<span>${escapeHtml(usuario.nombreUsuario)}</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end shadow border-0 mt-2" aria-labelledby="userMenu">
|
||||
<li>
|
||||
<a class="dropdown-item py-2 fw-semibold" href="perfil.php">
|
||||
<i class="fa-solid fa-user me-2 text-primary"></i>Mi Perfil
|
||||
</a>
|
||||
</li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li>
|
||||
<button class="dropdown-item py-2 fw-semibold text-danger" onclick="cerrarSesion()">
|
||||
<i class="fa-solid fa-right-from-bracket me-2"></i>Cerrar Sesión
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
$('#contenedorUsuarioCabecera').html(html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza los botones en la cabecera cuando NO hay sesión (Iniciar sesión azul)
|
||||
*/
|
||||
function renderizarCabeceraSinSesion() {
|
||||
let html = `
|
||||
<button class="btn btn-primary rounded-pill px-4 fw-bold shadow-sm" data-bs-toggle="modal" data-bs-target="#modalLogin">
|
||||
<i class="fa-solid fa-right-to-bracket me-1"></i> Iniciar sesión
|
||||
</button>
|
||||
<button class="btn btn-success rounded-pill px-4 fw-bold shadow-sm" data-bs-toggle="modal" data-bs-target="#modalRegistro">
|
||||
<i class="fa-solid fa-user-plus me-1"></i> Registrarse
|
||||
</button>
|
||||
`;
|
||||
$('#contenedorUsuarioCabecera').html(html);
|
||||
}
|
||||
|
||||
function escapeHtml(texto) {
|
||||
return $('<div>').text(texto).html();
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
// ============================================
|
||||
// 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);
|
||||
+145
-7
@@ -26,6 +26,10 @@ $.ajax({
|
||||
function cambiarNombre() {
|
||||
let nuevoNombre = $("#nuevoNombre").val().trim();
|
||||
|
||||
if (nuevoNombre === "") {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "controladores/controladorUsuario.php",
|
||||
@@ -42,8 +46,13 @@ function cambiarNombre() {
|
||||
// Actualizamos el nombre mostrado en la página
|
||||
$("#nombre").text(respuesta.nombreUsuario);
|
||||
|
||||
// Limpiamos el input
|
||||
|
||||
$("#nuevoNombre").val("");
|
||||
|
||||
|
||||
if (typeof comprobarEstadoSesion === "function") {
|
||||
comprobarEstadoSesion();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -56,7 +65,6 @@ function borrarNombre() {
|
||||
document.getElementById("nuevoNombre").value = "";
|
||||
}
|
||||
|
||||
|
||||
// =========================
|
||||
// CAMBIAR FOTO
|
||||
// =========================
|
||||
@@ -75,14 +83,11 @@ $("#inputFoto").change(function () {
|
||||
// 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");
|
||||
|
||||
@@ -98,11 +103,144 @@ $("#inputFoto").change(function () {
|
||||
if (respuesta.error) {
|
||||
alert(respuesta.error);
|
||||
} else {
|
||||
// Actualizamos la imagen sin recargar la página
|
||||
// Actualizamos la imagen en la página de perfil sin recargar
|
||||
$("#fotoPerfil").attr(
|
||||
"src",
|
||||
respuesta.avatar + "?t=" + new Date().getTime(),
|
||||
respuesta.avatar + "?t=" + new Date().getTime()
|
||||
);
|
||||
|
||||
// Actualizamos también el avatar superior en la cabecera
|
||||
if (typeof comprobarEstadoSesion === "function") {
|
||||
comprobarEstadoSesion();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// =========================
|
||||
// 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");
|
||||
}
|
||||
},
|
||||
|
||||
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");
|
||||
},
|
||||
});
|
||||
});
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 120 KiB |
+109
-237
@@ -1,3 +1,17 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Redirección si el usuario no ha iniciado sesión
|
||||
if (!isset($_SESSION['idUsuario'])) {
|
||||
header('Location: login.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
$nombreUsuario = htmlspecialchars($_SESSION['nombreUsuario'] ?? 'Usuario');
|
||||
$avatarUsuario = htmlspecialchars($_SESSION['avatar'] ?? 'img/avatars/defaultProfile.jpeg');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
|
||||
@@ -9,151 +23,99 @@
|
||||
<title>Perfil</title>
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Bootstrap Icons -->
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<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">
|
||||
<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';
|
||||
?>
|
||||
|
||||
<?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">
|
||||
<?php echo $_SESSION['nombreUsuario'] ?>
|
||||
<?= $nombreUsuario ?>
|
||||
</h1>
|
||||
|
||||
|
||||
<!-- ========================= -->
|
||||
<!-- FOTO DE PERFIL -->
|
||||
<!-- ========================= -->
|
||||
|
||||
<div class="foto-container">
|
||||
|
||||
<img
|
||||
id="fotoPerfil"
|
||||
src="<?= htmlspecialchars($_SESSION['avatar'] ?? '') ?>"
|
||||
alt="Foto de perfil"
|
||||
class="avatar rounded-circle">
|
||||
|
||||
<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">
|
||||
|
||||
<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>
|
||||
<input type="file"
|
||||
id="inputFoto"
|
||||
accept="image/*"
|
||||
hidden>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ========================= -->
|
||||
<!-- CAMBIAR NOMBRE -->
|
||||
<!-- ========================= -->
|
||||
|
||||
<div class="formulario-nombre">
|
||||
|
||||
<label
|
||||
for="nuevoNombre"
|
||||
class="form-label">
|
||||
|
||||
<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">
|
||||
|
||||
<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()">
|
||||
|
||||
<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()">
|
||||
|
||||
<button type="button"
|
||||
class="btn-perfil-borrar"
|
||||
onclick="borrarNombre()">
|
||||
<i class="bi bi-x-lg"></i>
|
||||
Borrar
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
@@ -162,11 +124,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ========================= -->
|
||||
<!-- ESTADÍSTICAS -->
|
||||
<!-- ========================= -->
|
||||
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="estadisticas">
|
||||
@@ -176,60 +134,33 @@
|
||||
Estadísticas
|
||||
</h2>
|
||||
|
||||
|
||||
<div class="estadistica estadistica-victorias">
|
||||
|
||||
<i class="bi bi-trophy-fill"></i>
|
||||
Victorias:
|
||||
|
||||
<strong id="victorias">
|
||||
|
||||
</strong>
|
||||
|
||||
<strong id="victorias">0</strong>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="estadistica estadistica-derrotas">
|
||||
|
||||
<i class="bi bi-x-circle-fill"></i>
|
||||
Derrotas:
|
||||
|
||||
<strong id="derrotas">
|
||||
|
||||
</strong>
|
||||
|
||||
<strong id="derrotas">0</strong>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="estadistica estadistica-aciertos">
|
||||
|
||||
<i class="bi bi-bullseye"></i>
|
||||
Aciertos:
|
||||
|
||||
<strong id="aciertos">
|
||||
|
||||
</strong>
|
||||
|
||||
<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">
|
||||
|
||||
<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>
|
||||
@@ -245,172 +176,118 @@
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ================================================= -->
|
||||
<!-- MODAL CREAR PREGUNTA -->
|
||||
<!-- ================================================= -->
|
||||
|
||||
<div
|
||||
class="modal fade"
|
||||
id="modalCrearPregunta"
|
||||
tabindex="-1"
|
||||
aria-labelledby="modalCrearPreguntaLabel"
|
||||
aria-hidden="true">
|
||||
<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">
|
||||
|
||||
|
||||
<!-- CABECERA DEL MODAL -->
|
||||
|
||||
<div class="modal-header modal-kahoot-header">
|
||||
|
||||
<h5
|
||||
class="modal-title"
|
||||
id="modalCrearPreguntaLabel">
|
||||
|
||||
<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 type="button"
|
||||
class="btn-close btn-close-white"
|
||||
data-bs-dismiss="modal"
|
||||
aria-label="Cerrar">
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- CUERPO DEL MODAL -->
|
||||
|
||||
<div class="modal-body p-4">
|
||||
|
||||
<form id="formCrearPregunta">
|
||||
|
||||
|
||||
<!-- PREGUNTA -->
|
||||
|
||||
<div class="mb-4">
|
||||
|
||||
<label
|
||||
for="pregunta"
|
||||
class="form-label fw-semibold">
|
||||
|
||||
<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>
|
||||
|
||||
<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">
|
||||
|
||||
<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>
|
||||
|
||||
<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">
|
||||
|
||||
<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="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>
|
||||
<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>
|
||||
|
||||
|
||||
<!-- PIE DEL MODAL -->
|
||||
|
||||
<div class="modal-footer">
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-secondary"
|
||||
data-bs-dismiss="modal">
|
||||
|
||||
<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">
|
||||
|
||||
<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>
|
||||
@@ -420,14 +297,9 @@
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap JS -->
|
||||
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js">
|
||||
</script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Tu JavaScript -->
|
||||
|
||||
<script src="js/perfil.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user