diff --git a/api/src/main/java/lab/en2b/quizapi/game/GameService.java b/api/src/main/java/lab/en2b/quizapi/game/GameService.java index cccd2b31..36e10efd 100644 --- a/api/src/main/java/lab/en2b/quizapi/game/GameService.java +++ b/api/src/main/java/lab/en2b/quizapi/game/GameService.java @@ -73,7 +73,7 @@ private Question generateQuestionForGame(Game game){ if(question.isPresent()){ return question.get(); } else { - game.isGameOver(); + game.setGameOver(true); gameRepository.save(game); throw new InternalApiErrorException("Could not find a question for the game"); } diff --git a/docs/images/wireframe-About.png b/docs/images/wireframe-About.png new file mode 100644 index 00000000..9e4093c1 Binary files /dev/null and b/docs/images/wireframe-About.png differ diff --git a/docs/images/wireframe-Dashboard-GameModes.png b/docs/images/wireframe-Dashboard-GameModes.png new file mode 100644 index 00000000..cdaf4695 Binary files /dev/null and b/docs/images/wireframe-Dashboard-GameModes.png differ diff --git a/docs/images/wireframe-Dashboard-ResumeGame.png b/docs/images/wireframe-Dashboard-ResumeGame.png new file mode 100644 index 00000000..3036c63d Binary files /dev/null and b/docs/images/wireframe-Dashboard-ResumeGame.png differ diff --git a/docs/images/wireframe-Dashboard-UserPanel.png b/docs/images/wireframe-Dashboard-UserPanel.png new file mode 100644 index 00000000..9e10f41b Binary files /dev/null and b/docs/images/wireframe-Dashboard-UserPanel.png differ diff --git a/docs/images/wireframe-Dashboard-customGameMode.png b/docs/images/wireframe-Dashboard-customGameMode.png new file mode 100644 index 00000000..e62254a0 Binary files /dev/null and b/docs/images/wireframe-Dashboard-customGameMode.png differ diff --git a/docs/images/wireframe-Dashboard.png b/docs/images/wireframe-Dashboard.png deleted file mode 100644 index 6ee931f2..00000000 Binary files a/docs/images/wireframe-Dashboard.png and /dev/null differ diff --git a/docs/images/wireframe-Results.png b/docs/images/wireframe-Results.png new file mode 100644 index 00000000..7586c5f8 Binary files /dev/null and b/docs/images/wireframe-Results.png differ diff --git a/docs/images/wireframe-Statistics.png b/docs/images/wireframe-Statistics.png new file mode 100644 index 00000000..077ae749 Binary files /dev/null and b/docs/images/wireframe-Statistics.png differ diff --git a/docs/src/02_architecture_constraints.adoc b/docs/src/02_architecture_constraints.adoc index 0ec6e6b0..3b28b338 100644 --- a/docs/src/02_architecture_constraints.adoc +++ b/docs/src/02_architecture_constraints.adoc @@ -32,14 +32,26 @@ The application must be developed according to some constraints that were define image::wireframe-Root.png[align="center", title="Root Wireframe"] +image::wireframe-About.png[align="center", title="About Wireframe"] + image::wireframe-SignUp.png[align="center", title="Sign up Wireframe"] image::wireframe-SignIn.png[align="center", title="Sign in Wireframe"] -image::wireframe-Dashboard.png[align="center", title="Dashboard Wireframe"] +image::wireframe-Dashboard-GameModes.png[align="center", title="Dashboard game modes Wireframe"] + +image::wireframe-Dashboard-customGameMode.png[align="center", title="Dashboard custom game mode Wireframe"] + +image::wireframe-Dashboard-UserPanel.png[align="center", title="Dashboard user panel Wireframe"] + +image::wireframe-Dashboard-ResumeGame.png[align="center", title="Dashboard resume game Wireframe"] image::wireframe-Rules.png[align="center", title="Rules Wireframe"] image::wireframe-Game.png[align="center", title="Game Wireframe"] -image::wireframe-Menu.png[align="center", title="Menu Wireframe"] \ No newline at end of file +image::wireframe-Statistics.png[align="center", title="Statistics Wireframe"] + +image::wireframe-Menu.png[align="center", title="Menu Wireframe"] + +image::wireframe-Results.png[align="center", title="Results Wireframe"] \ No newline at end of file diff --git a/questiongenerator/src/main/java/Main.java b/questiongenerator/src/main/java/Main.java index 3b7a256b..d89a60bb 100644 --- a/questiongenerator/src/main/java/Main.java +++ b/questiongenerator/src/main/java/Main.java @@ -38,6 +38,11 @@ public static void main(String[] args) { new BasketballVenueQuestion("es"); } + if (GeneralRepositoryStorer.doesntExist(AnswerCategory.SONG)) { + new MusicAuthorQuestion("en"); + new MusicAuthorQuestion("es"); + } + // IMAGES if(GeneralRepositoryStorer.doesntExist(AnswerCategory.STADIUM)) { diff --git a/questiongenerator/src/main/java/templates/MusicAuthorQuestion.java b/questiongenerator/src/main/java/templates/MusicAuthorQuestion.java new file mode 100644 index 00000000..0731926b --- /dev/null +++ b/questiongenerator/src/main/java/templates/MusicAuthorQuestion.java @@ -0,0 +1,95 @@ +package templates; + +import model.*; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +public class MusicAuthorQuestion extends QuestionTemplate { + + + List authorLabels; + + private static final String[] spanishStringsIni = {"¿Quién es el autor de '", "¿Quién canta '", "¿Quién es el cantante de '", "¿Quién es el intérprete de '"}; + private static final String[] englishStringsIni= {"Who is the author of '", "Who sings '", "Who is the singer of '", "Who is the performer of '"}; + + private static final String[] spanishStringsFin = {"'?", "'?", "'?", "'?"}; + private static final String[] englishStringsFin = {"'?", "'?", "'?", "'?"}; + + + public MusicAuthorQuestion(String langCode) { + super(langCode); + } + + @Override + public void setQuery() { + this.sparqlQuery = "SELECT DISTINCT ?songLabel ?performerLabel ?awardLabel " + + "WHERE { " + + " ?song wdt:P31 wd:Q134556; " + + " wdt:P175 ?performer; " + + " p:P166 ?statement. " + + " ?statement ps:P166 ?award. " + + " SERVICE wikibase:label { " + + " bd:serviceParam wikibase:language \"en, es\"." + + " } " + + "}" + + "LIMIT 100"; + } + + @Override + public void processResults() { + authorLabels = new ArrayList<>(); + List questions = new ArrayList<>(); + List answers = new ArrayList<>(); + + for (int i = 0; i < results.length(); i++) { + JSONObject result = results.getJSONObject(i); + + String songLabel = ""; + String performerLabel = ""; + + try { + JSONObject songObject = result.getJSONObject("songLabel"); + songLabel = songObject.getString("value"); + + JSONObject performerLabelObject = result.getJSONObject("performerLabel"); + performerLabel = performerLabelObject.getString("value"); + } catch (Exception e) { + continue; + } + + if (needToSkip(songLabel, performerLabel)) + continue; + + Answer a = new Answer(performerLabel, AnswerCategory.SONG, langCode); + answers.add(a); + + String questionString = ""; + + if (langCode.equals("es")) + questionString = spanishStringsIni[i%4] + songLabel + spanishStringsFin[i%4]; + else + questionString = englishStringsIni[i%4] + songLabel + englishStringsFin[i%4]; + + questions.add(new Question(a, questionString, QuestionCategory.MUSIC, QuestionType.TEXT)); + } + + repository.saveAll(new ArrayList<>(answers)); + repository.saveAll(new ArrayList<>(questions)); + } + + private boolean needToSkip(String musicLabel, String genreLabel) { + if (authorLabels.contains(musicLabel)) { + return true; + } + authorLabels.add(musicLabel); + + if (musicLabel.equals("") || genreLabel.equals("")) + return true; + if (QGHelper.isEntityName(musicLabel) || QGHelper.isEntityName(genreLabel)) + return true; + + return false; + } +}