Skip to content
Snippets Groups Projects
Commit ce4c5776 authored by BRICHE Louis's avatar BRICHE Louis
Browse files

suppression de la réponse dans le json envoyé au client

parent 4dc6b705
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ public class ConnexionResource { ...@@ -31,7 +31,7 @@ public class ConnexionResource {
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("uuid", user.getUuid().toString()); jsonObject.addProperty("uuid", user.getUuid().toString());
jsonObject.addProperty("question", new Gson().toJson(user.getActualQuizz())); jsonObject.addProperty("question", new Gson().toJson(user.getActualQuizz().toClientQuiz()));
return Response.ok(jsonObject.toString(), MediaType.APPLICATION_JSON).build(); return Response.ok(jsonObject.toString(), MediaType.APPLICATION_JSON).build();
} }
......
...@@ -12,7 +12,7 @@ import jakarta.ws.rs.core.Response; ...@@ -12,7 +12,7 @@ import jakarta.ws.rs.core.Response;
import java.util.UUID; import java.util.UUID;
@Path("/quiz") @Path("/quiz")
public class QuizzResource { public class QuizResource {
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
...@@ -20,7 +20,7 @@ public class QuizzResource { ...@@ -20,7 +20,7 @@ public class QuizzResource {
UUID playerUuid = UUID.fromString(inputJson.get("uuid").getAsString()); UUID playerUuid = UUID.fromString(inputJson.get("uuid").getAsString());
User user = Users.get(playerUuid); User user = Users.get(playerUuid);
return Response.ok(new Gson().toJson(user.getNextQuizz()), MediaType.APPLICATION_JSON).build(); return Response.ok(new Gson().toJson(user.getNextQuizz().toClientQuiz()), MediaType.APPLICATION_JSON).build();
} }
/** /**
......
package fr.louis.projetprogreseau.quizz;
import fr.louis.projetprogreseau.user.User;
/**
* même principe qu'un quiz, sauf qu'on envoie pas la bonne réponse
*/
public class ClientQuiz {
private final String question = "quelle est cette ville ?";
private final String[] answers;
private final int imageIndex;
ClientQuiz(String[] answers, int imageIndex) {
this.answers = answers;
this.imageIndex = imageIndex;
}
public String getQuestion() {
return question;
}
public String[] getAnswers() {
return answers;
}
public int getImageIndex() {
return imageIndex;
}
}
...@@ -36,4 +36,8 @@ public class Quiz { ...@@ -36,4 +36,8 @@ public class Quiz {
public int getImageIndex() { public int getImageIndex() {
return imageIndex; return imageIndex;
} }
public ClientQuiz toClientQuiz(){
return new ClientQuiz(answers, imageIndex);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment