Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
254 changes: 254 additions & 0 deletions docs/Memorama.postman_collection[1].json
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
{
"info": {
"_postman_id": "2083381c-545f-49b5-859b-46b1336c927a",
"name": "Memorama",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "29780256"
},
"item": [
{
"name": "crear partida",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"nombre profesor\" : \"Surisadai\",\r\n \"nombre juego\" : \"TPSI 8A\",\r\n \"cartas\" : {\r\n \"0\" : {\r\n \"question\" : \"a\",\r\n \"answer\" : \"a\"\r\n },\r\n \"1\" : {\r\n \"question\" : \"b\",\r\n \"answer\" : \"b\"\r\n },\r\n \"3\" : {\r\n \"question\" : \"c\",\r\n \"answer\" : \"c\"\r\n },\r\n \"4\" : {\r\n \"question\" : \"d\",\r\n \"answer\" : \"d\"\r\n }\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://127.0.0.1:8000/api/crearPartida/",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"crearPartida",
""
]
}
},
"response": []
},
{
"name": "unirse",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "partidaID",
"value": "1",
"type": "text"
},
{
"key": "nombre alumno",
"value": "milo",
"type": "text"
}
]
},
"url": {
"raw": "http://127.0.0.1:8000/api/unirse/",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"unirse",
""
]
}
},
"response": []
},
{
"name": "cartas subpartida",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://127.0.0.1:8000/api/cartas/subpartida/:subpartida/?alumno=1",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"cartas",
"subpartida",
":subpartida",
""
],
"query": [
{
"key": "alumno",
"value": "1"
}
],
"variable": [
{
"key": "subpartida",
"value": "1"
}
]
}
},
"response": []
},
{
"name": "alumnos subpartida",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://127.0.0.1:8000/api/subpartida/alumnos/:subpartida/",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"subpartida",
"alumnos",
":subpartida",
""
],
"variable": [
{
"key": "subpartida",
"value": "1"
}
]
}
},
"response": []
},
{
"name": "cartas partida",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://127.0.0.1:8000/api/partida/:partida/",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"partida",
":partida",
""
],
"variable": [
{
"key": "partida",
"value": "1"
}
]
}
},
"response": []
},
{
"name": "voltear cartas",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"alumnoID\": 1,\r\n \"carta1ID\": 1,\r\n \"carta2ID\": 3\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://127.0.0.1:8000/api/subpartida/:subpartida/",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"subpartida",
":subpartida",
""
],
"variable": [
{
"key": "subpartida",
"value": "1"
}
]
}
},
"response": []
},
{
"name": "update score",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://127.0.0.1:8000/api/updateScore/:alumno/",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"updateScore",
":alumno",
""
],
"variable": [
{
"key": "alumno",
"value": "1"
}
]
}
},
"response": []
}
]
}
38 changes: 23 additions & 15 deletions frontend/src/app/iniciar/page.jsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
import HostHeader from "@/components/host/HostHeader"
import MainButton from "@/components/MainButton"
import styles from '@/styles/pages/Iniciar.module.css'
'use client';
import useGameInfo from "@/libs/helpers/host/useGameInfo";

import { DummyGame, DummySubroom } from "@/libs/Dummy"

/*
* Dummy Data
*/
const GameInfo = DummyGame
const { players : a } = DummySubroom
const players = [ ...a, ...a]
import styles from '@/styles/pages/Iniciar.module.css';
import HostHeader from "@/components/host/HostHeader";
import MainButton from "@/components/MainButton";

export default function page() {
const { gameInfo, players, statusOptions, cancelGame } = useGameInfo();

return (
<main className={styles.Iniciar__main} >

<HostHeader gameInfo={GameInfo} >
<MainButton msg={'Iniciar juego'} />
<MainButton level={2} msg={'Cancelar'} />
<HostHeader gameInfo={ gameInfo } >
<MainButton
msg={ statusOptions.cta }
onclick={ statusOptions.action }
/>

<MainButton
msg="Cancelar juego"
level={2}
onclick={ () => cancelGame( gameInfo.gameID ) }
/>
</HostHeader>

<section className={styles.Iniciar__OnlinePlayers}>

<p className={styles.Iniciar__TableTitle}>Jugadores en linea</p>

<section className={styles.Iniciar__Players}>
{ players.map( ( player, key ) => <p key={key} className={styles.Iniciar__Player} >{player.name}</p> ) }
{ players.map( ( player, key ) => <p key={key} className={styles.Iniciar__Player} >{player.nombre}</p> ) }
</section>
{
gameInfo.playersOnline == 0 &&
<p className={styles.Iniciar__Player} >No hay jugadores en línea</p>
}

</section>

Expand Down
28 changes: 9 additions & 19 deletions frontend/src/app/stats/page.jsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
"use client"

import useGameInfo from "@/libs/helpers/host/useGameInfo"
import useSubRoomLogic from "@/libs/helpers/host/useSubRoomLogic"

import style from "@/styles/pages/stats.module.css"
import MainButton from "@/components/MainButton"
import SubroomStat from "@/components/host/SubroomStat"
import HostHeader from "@/components/host/HostHeader"

import { DummyGame, DummySubroom } from "@/libs/Dummy";

const Page = () => {
/*
* I'm working with dummy data for now
* This will be replaced with the real-time connection to the server
*
* We have to get the Subrooms from the server and then map them to the SubroomStat component
* The game info probably from cookies
* - Name of the game
* - Game ID
* - Number of players
* - Teacher name
*/
const GameInfo = DummyGame
const Subrooms = [DummySubroom, DummySubroom]
const { gameInfo, players, statusOptions } = useGameInfo();
const { subrooms } = useSubRoomLogic( players );

return (
<main className={style.stats__main}>

<HostHeader gameInfo={GameInfo} >
<MainButton msg='Jugar de nuevo' />
<HostHeader gameInfo={ gameInfo } >
<MainButton msg={ statusOptions.cta } onclick={ statusOptions.action } />
</HostHeader>

<table className={style.stats__subroomsSection}>
Expand All @@ -38,8 +28,8 @@ const Page = () => {
</thead>

<tbody className={style.stats__subrooms}>
{Subrooms.map(subroom => (
<SubroomStat key={subroom.subroomID} {...subroom} />
{ Object.keys( subrooms ).map(subroom => (
<SubroomStat key={ subroom } {...subrooms[ subroom ]} />
))}
</tbody>

Expand Down
10 changes: 9 additions & 1 deletion frontend/src/components/Inicio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ export default function Inicio() {
partidaID: gameCode,
"nombre alumno": name,
});
console.log(res)

if ( !res ) {
alert("Error al unirse al juego");
}

if (res) {
console.log("res", res);
redirect(`/espera/?gameCode=${ gameCode.toString() }`);
}
};

return (
Expand Down
Loading