From 1f510762ba818e683acd31d50d72e7ebda395acc Mon Sep 17 00:00:00 2001 From: "gwenael.planchon" Date: Tue, 2 Apr 2024 16:56:38 +0200 Subject: [PATCH] fix creer partie --- science-quest/src/data/kahoot.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/science-quest/src/data/kahoot.js b/science-quest/src/data/kahoot.js index 42732b1..7405ee6 100644 --- a/science-quest/src/data/kahoot.js +++ b/science-quest/src/data/kahoot.js @@ -9,16 +9,6 @@ export class Kahoot{ async obtenirSalleAttente(){ const response=await fetch(`${REST_API}/partie/kahoot/${this.codeInvitation}/status`) return new KahootSalleAttente(await response.json()) - } - async creerPartie(){ - const user = await Utilisateur.utilisateurConnecteOuCreerInvite() - const response = await fetch(`${REST_API}/partie/kahoot/${this.codeInvitation}`,{ - method:"POST", - headers:{"Content-Type":"application/json"}, - //{"idJoueur": 0, "thematiques": [0,1,2,3], "idDifficulte": 0} - body:{"idJoueur":user.id, "thematiques":this.thematiques, "idDifficulte":this.idDifficulte} - }) - return new KahootDetailsPartie(await response.json()) } } @@ -54,10 +44,20 @@ out: "difficulte": {"id":0, "libelle": 0} } */ -export class KahootDetailsPartie extends DataObject{ +export class KahootPartie extends DataObject{ constructor(parsedJSON){ super(parsedJSON) } + async creerPartie(){ + const user = await Utilisateur.utilisateurConnecteOuCreerInvite() + const response = await fetch(`${REST_API}/partie/kahoot`,{ + method:"POST", + headers:{"Content-Type":"application/json"}, + //{"idJoueur": 0, "thematiques": [0,1,2,3], "idDifficulte": 0} + body:JSON.stringify({"idJoueur":user.id, "thematiques":this.thematiques, "idDifficulte":this.idDifficulte}) + }) + return new this.constructor(await response.json()) + } } /* JSON de reference (question)