Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.0 #105

Merged
merged 56 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
b7b7303
Feat: Questions and answers are now written in the DB!
UO283615 Mar 8, 2024
53ef89c
Chore: Cleaned up the code a bit
UO283615 Mar 8, 2024
f5705e6
chore: Project renamed
Mar 8, 2024
889965b
chore: Unused imports removed and minor code clean up
Mar 8, 2024
5c9aacc
chore: Comments added on QuestionTemplate and small code clean ups.
Mar 8, 2024
cfc2ce0
chore: Missing comment added on QuestionTemplate
Mar 8, 2024
7a3ab99
chore: Added question generator to the glossary
UO283615 Mar 8, 2024
46ae6d7
Chore: Updated the class diagram
UO283615 Mar 8, 2024
bb53d23
feat: adding all the logic to the game view.
gony02 Mar 8, 2024
c86ccf7
chore: improving the main readme and adding the wireframes.
gony02 Mar 9, 2024
7cacc3c
fix: Adding the .env and modifications in the AuthUtils.js
sergiorodriguezgarcia Mar 9, 2024
bf2c9f7
feat: Making the Signup view to redirect to Login when new user register
sergiorodriguezgarcia Mar 9, 2024
054c847
fix: Changing the tests to pass with the new impl.
sergiorodriguezgarcia Mar 9, 2024
2826b5f
fix: docker compose release thing
Toto-hitori Mar 9, 2024
a1c75de
feat: Adding the custom message to the Login view
sergiorodriguezgarcia Mar 9, 2024
747f463
chore: Added documentation to CountryCapitalQuestion
Mar 9, 2024
4a2ae9c
chore: Added documentation to Jpa
Mar 9, 2024
24dcef1
chore: Code refactoring so AnswerRepositoryImpl and QuestionResposito…
Mar 9, 2024
1ee4594
chore: Code refactoring so AnswerRepositoryImpl and QuestionResposito…
Mar 9, 2024
bd3ef65
chore: Code refactoring so AnswerRepositoryImpl and QuestionResposito…
Mar 9, 2024
4c55598
chore: .mvn package removed from Git
Mar 9, 2024
f01d273
Merge pull request #97 from Arquisoft/feat/questionGeneratorMicroService
Toto-hitori Mar 9, 2024
c68252e
feat: Adding the logout logic to the dashboard
sergiorodriguezgarcia Mar 9, 2024
c1d35b7
Merge pull request #99 from Arquisoft/docs/gonzaloA
sergiorodriguezgarcia Mar 9, 2024
5054399
Merge branch 'develop' into feat/webapp/new-game
sergiorodriguezgarcia Mar 9, 2024
4124070
fix: questions now do not generate duplicate column
Toto-hitori Mar 9, 2024
9b2ac01
fix: questions add answers now
Toto-hitori Mar 9, 2024
fc00173
fix: answering questions not working
Toto-hitori Mar 9, 2024
124c342
fix: saving refresh token
Toto-hitori Mar 9, 2024
11ed3a7
fix: auth not working when reloading
Toto-hitori Mar 10, 2024
3687a93
fix: logout not removing session storage
Toto-hitori Mar 10, 2024
24ee185
fix: passed functions as references
Toto-hitori Mar 10, 2024
17fbf24
chore: removed unecessary terms from the glossary
UO283615 Mar 10, 2024
0865fcc
fix: right now all webapp tests are passing.
gony02 Mar 10, 2024
7013292
Merge pull request #98 from Arquisoft/docs/villanueva
Toto-hitori Mar 10, 2024
e6e9306
feat: creating the logout tests.
gony02 Mar 10, 2024
ea9f930
feat: creating the questions.js tests.
gony02 Mar 10, 2024
26b8a7a
feat: adding more tests cases for the dashboard.
gony02 Mar 10, 2024
bf228cf
feat: adding more tests to the dashboard.
gony02 Mar 10, 2024
cb79327
fix: getQuestions controller deleted
sergioqfeg1 Mar 10, 2024
46d2184
feat: new tests added to the login.
gony02 Mar 10, 2024
8ec2a1e
fix: lang parameter
sergioqfeg1 Mar 10, 2024
1fd2e94
fix: lang parameter added to service and repo
sergioqfeg1 Mar 10, 2024
57f908c
feat: adding more tests to the signup.
gony02 Mar 10, 2024
31ae9f3
fix: problems with service test
sergioqfeg1 Mar 10, 2024
112ac3c
feat: adding more unit tests to the game view.
gony02 Mar 10, 2024
3ba04fd
fix: problems with controller tests
sergioqfeg1 Mar 10, 2024
e07ffe9
fix: fixing the game unit tests.
gony02 Mar 10, 2024
56706d9
feat: adding more tests to the signup
gony02 Mar 10, 2024
3d5e714
Merge pull request #103 from Arquisoft/chore/question-gen-actions
UO283615 Mar 10, 2024
719d453
chore: removed unnecessary image in docker-compose.yml
Toto-hitori Mar 10, 2024
02944f0
Merge pull request #102 from Arquisoft/feat/webapp/new-game
Toto-hitori Mar 10, 2024
fd28553
fix: remove getQuestions
sergioqfeg1 Mar 11, 2024
2ccc0b3
Merge remote-tracking branch 'origin/develop' into hotfix/questionLan…
Toto-hitori Mar 11, 2024
adacaa7
fix: lang is not required
Toto-hitori Mar 11, 2024
e91dc9f
Merge pull request #104 from Arquisoft/hotfix/questionLanguage
Toto-hitori Mar 11, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,5 @@ jobs:
echo "DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }}" >> .env
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env
echo "API_URI=http://${{ secrets.DEPLOY_HOST }}:8080" >> .env
docker compose down
docker compose --profile prod down
docker compose --profile prod up -d
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ We aim to create a platform that not only challenges your knowledge but also spa
🌐 Multiplayer: Compete with friends and strangers to prove you are the best.

## Contributors
| Nombre | UO |
|---------------------------------|----------|
| Gonzalo Alonso Fernández | UO282104 |
| Darío Gutiérrez Mori | UO282435 |
| Sergio Rodríguez García | UO282598 |
| Jorge Joaquín Gancedo Fernández | UO282161 |
| Sergio Quintana Fernández | UO288090 |
| Diego Villanueva Berros | UO283615 |
| Gonzalo Suárez Losada | UO283928 |
Contributor | Contact
-- | --
Gonzalo Alonso Fernández | <a href="https://github.com/gony02"><img src="https://img.shields.io/badge/UO282104-Gonzalo Alonso-red"></a>
Sergio Rodríguez García | <a href="https://github.com/sergiorodriguezgarcia"><img src="https://img.shields.io/badge/UO282598-Sergio Rodríguez-orange"></a>
Jorge Joaquín Gancedo Fernández | <a href="https://github.com/jjgancfer"><img src="https://img.shields.io/badge/UO282161-Jorge Joaquín Gancedo-yellow"></a>
Darío Gutiérrez Mori | <a href="https://github.com/Toto-hitori"><img src="https://img.shields.io/badge/UO282435-Darío Gutiérrez-green"></a>
Sergio Quintana Fernández | <a href="https://github.com/sergioqfeg1"><img src="https://img.shields.io/badge/UO288090-Sergio Quintana-cyan"></a>
Diego Villanueva Berros | <a href="https://github.com/UO283615"><img src="https://img.shields.io/badge/UO283615-Diego Villanueva-blue"></a>
Gonzalo Suárez Losada | <a href="https://github.com/uo283928"><img src="https://img.shields.io/badge/UO283928-Gonzalo Suárez-pink"></a>

***

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.List;

@RequiredArgsConstructor
@Service
//@Service
public class InsertDataUtils {

private final QuestionRepository questionRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public class Question {
@NotNull
@JoinColumn(name = "correct_answer_id")
private Answer correctAnswer;
@Column(name = "question_category")
private QuestionCategory questionCategory;
@Column(name = "answer_category")
private AnswerCategory answerCategory;
private String language;
private QuestionType type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,20 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/questions")
@RequiredArgsConstructor
public class QuestionController {
private final QuestionService questionService;

// TODO: REMOVE WHEN NOT USED FOR TESTING
@GetMapping
private ResponseEntity<List<QuestionResponseDto>> getQuestions() {
return ResponseEntity.ok(questionService.getQuestions());
}

@PostMapping("/{questionId}/answer")
private ResponseEntity<AnswerCheckResponseDto> answerQuestion(@PathVariable @PositiveOrZero Long questionId, @Valid @RequestBody AnswerDto answerDto){
return ResponseEntity.ok(questionService.answerQuestion(questionId,answerDto));
}

@GetMapping("/new")
private ResponseEntity<QuestionResponseDto> generateQuestion(){
return ResponseEntity.ok(questionService.getRandomQuestion());
private ResponseEntity<QuestionResponseDto> generateQuestion(@RequestParam(required = false) String lang){
return ResponseEntity.ok(questionService.getRandomQuestion(lang));
}

@GetMapping("/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import org.springframework.data.jpa.repository.Query;

public interface QuestionRepository extends JpaRepository<Question,Long> {
@Query(value = "SELECT * FROM questions ORDER BY RANDOM() LIMIT 1", nativeQuery = true)
Question findRandomQuestion();
@Query(value = "SELECT q FROM questions WHERE q.language=?1 ORDER BY RANDOM() LIMIT 1", nativeQuery = true)
Question findRandomQuestion(String lang);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ public class QuestionService {
private final QuestionRepository questionRepository;
private final QuestionResponseDtoMapper questionResponseDtoMapper;

public List<QuestionResponseDto> getQuestions() {
return questionRepository.findAll().stream().map(questionResponseDtoMapper).toList();
}

public AnswerCheckResponseDto answerQuestion(Long id, AnswerDto answerDto) {
Question question = questionRepository.findById(id).orElseThrow();
if(question.getCorrectAnswer().getId().equals(answerDto.getAnswerId())){
Expand All @@ -37,8 +33,11 @@ else if(question.getAnswers().stream().noneMatch(i -> i.getId().equals(answerDto
}
}

public QuestionResponseDto getRandomQuestion() {
return questionResponseDtoMapper.apply(questionRepository.findRandomQuestion());
public QuestionResponseDto getRandomQuestion(String lang) {
if (lang==null || lang.isBlank()) {
lang = "en";
}
return questionResponseDtoMapper.apply(questionRepository.findRandomQuestion(lang));
}

public QuestionResponseDto getQuestionById(Long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,26 @@ public class QuestionControllerTest {
QuestionService questionService;
@MockBean
UserService userService;

@Test
void getQuestionNoAuthShouldReturn403() throws Exception {
mockMvc.perform(get("/questions")
void newQuestionShouldReturn403() throws Exception{
mockMvc.perform(get("/questions/new?lang=en")
.contentType("application/json")
.with(csrf()))
.andExpect(status().isForbidden());
}

@Test
void getQuestionShouldReturn200() throws Exception {
mockMvc.perform(get("/questions")
void newQuestionShouldReturn200() throws Exception{
mockMvc.perform(get("/questions/new?lang=en")
.with(user("test").roles("user"))
.contentType("application/json")
.with(csrf()))
.andExpect(status().isOk());
}

@Test
void newQuestionShouldReturn403() throws Exception{
mockMvc.perform(get("/questions/new")
.contentType("application/json")
.with(csrf()))
.andExpect(status().isForbidden());
}

@Test
void newQuestionShouldReturn200() throws Exception{
void newQuestionNoLangShouldReturn200() throws Exception{
mockMvc.perform(get("/questions/new")
.with(user("test").roles("user"))
.contentType("application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ void setUp() {

@Test
void testGetRandomQuestion() {
when(questionRepository.findRandomQuestion()).thenReturn(defaultQuestion);
QuestionResponseDto response = questionService.getRandomQuestion();
when(questionRepository.findRandomQuestion("en")).thenReturn(defaultQuestion);
QuestionResponseDto response = questionService.getRandomQuestion("");

assertEquals(response, defaultResponseDto);
}
Expand Down
Binary file added docs/images/wireframe-Dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/wireframe-Game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/wireframe-Results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/wireframe-Rules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/wireframe-SignIn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/wireframe-SignUp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/wireframe-Welcome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions docs/src/02_architecture_constraints.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,18 @@ The application must be developed according to some constraints that were define
| Documentation in Arc42 | The documentation must follow the Arc42 template
|===

*Wireframes*

image::wireframe-Welcome.png[align="center", title="Welcome Wireframe"]

image::wireframe-SignIn.png[align="center", title="Sign In Wireframe"]

image::wireframe-SignUp.png[align="center", title="Sign Up Wireframe"]

image::wireframe-Dashboard.png[align="center", title="Dashboard Wireframe"]

image::wireframe-Rules.png[align="center", title="Rules Wireframe"]

image::wireframe-Game.png[align="center", title="Game Wireframe"]

image::wireframe-Results.png[align="center", title="Results Wireframe"]
34 changes: 25 additions & 9 deletions docs/src/08_concepts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,44 @@ This is the first version of the diagram, it will be updated if needed.
----
@startuml

enum Category {
enum QuestionCategory {
HISTORY
GEOGRAPHY
SCIENCE
MATH
LITERATURE
ART
SPORTS
}

enum Type {
enum AnsswerCategory {
CITY
COUNTRY
PERSON
DATE
OTHER
}

enum QuestionType{
TEXT
IMAGE
AUDIO
}

class Question{
id: long
content: String
answers: List<Answer>
correct: Answer
category: Category
correctAnswer: Answer
questionCategory: QuestionCategory
answerCategory: AnswerCategory
language: String
Type: Type
QuestionType: Type
}

class User{
username: String
email: String
password: String
answeredQuestions: int
}

Expand All @@ -41,8 +56,9 @@ class UserStat{

class Answer {
text: String
category: Category
Type: Type
category: AnswerCategory
questionsWithThisAnswer: List<Question>

}

class Game {
Expand All @@ -52,7 +68,7 @@ class Game {


class Ranking << Singleton >> {

}

User o--> Question
Expand Down
11 changes: 2 additions & 9 deletions docs/src/12_glossary.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ ifndef::imagesdir[:imagesdir: ../images]
[cols="e,2e" options="header"]
|===
|Term |Definition

|React
|An open-source JavaScript library for developing user interfaces. It can be used to develop web applications, and it has to be complemented with other libraries to develop full-fledged products.

|SpringBoot
|Java Spring Boot (Spring Boot) is a tool that makes developing web application and microservices with Spring Framework faster and easier through three core capabilities: Autoconfiguration, an opinionated approach to configuration, the ability to create standalone applications.

|PostgreSQL
|Object-relational database management system (ORDMBS), which means that it has relational capabilities and an object-oriented design
|Question Generator
|A module of the application responsible for querying Wikidata, creating the questions and storing them in our DB.
|===
38 changes: 38 additions & 0 deletions questiongenerator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
Loading