Skip to content

Commit

Permalink
Merge pull request #193 from Arquisoft/CorreccionesFuncionalidad
Browse files Browse the repository at this point in the history
Correción contador de preguntas y primera respuesta correcta
  • Loading branch information
RicardoDiNu authored Apr 15, 2024
2 parents af04f3e + 5d3c4c4 commit c897fba
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void questionGenerator(String statement, List<String> options, String cor
answers.add(correct);

Question question = new Question(statement, answers, correct, category, language);
question.scrambleOptions();
//question.scrambleOptions();
questions.add(question);
}

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/uniovi/entities/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@ public boolean isCorrectAnswer(Answer answer){
return answer.isCorrect();
}

public void scrambleOptions(){
/*public void scrambleOptions(){
Collections.shuffle(options); USO EN LOS TESTS Y ABSTRACTQUESTIONGENERATOR
}*/

public List<Answer> returnScrambledOptions(){
Collections.shuffle(options);
return options;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/game/basicGame.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<b id="questionNumber" th:inline="text">
<span id="currentQuestion" th:text="${session.gameSession.answeredQuestions.size()+1}"></span>
/
<span id="totalQuestions" th:text="${session.gameSession.questionsToAnswer.size()}"></span>
<span id="totalQuestions" th:text="${session.gameSession.questionsToAnswer.size() + session.gameSession.answeredQuestions.size()}"></span>
</b>
</p>
<div id="gameFrame" th:replace="~{game/fragments/gameFrame}"></div>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/game/fragments/gameFrame.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h1 class="text-center" th:text="${question.statement}"></h1>
<div class="container">
<div class="row">
<!-- Thymeleaf loop to generate buttons -->
<div th:each="answer, iterStat : ${question.options}" class="col-6 col-md-6 col-12">
<div th:each="answer, iterStat : ${question.returnScrambledOptions()}" class="col-6 col-md-6 col-12">
<button th:id="${'btn' + answer.id}" class="btn btn-primary btn-block m-2 rounded" th:text="${answer.text}" th:value="${answer}"></button>
</div>
</div>
Expand Down Expand Up @@ -48,7 +48,7 @@ <h1 class="text-center" th:text="${question.statement}"></h1>
let progressBar = $('#progressBar');
let currentTime = parseFloat(progressBar.attr('aria-valuenow'));
let decrement = 100 * updateInterval / timeoutPeriod;
let newTime = Math.max(0, currentTime - decrement);;
let newTime = Math.max(0, currentTime - decrement);
// Calculate the color based on the percentage
let greenValue = Math.round((newTime * 255) / 100);
let redValue = 255 - greenValue;
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/uniovi/Wiq_UnitTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ public void testScrambleOptions() {
question.addOption(option2);
question.addOption(option3);

question.scrambleOptions();
List<Answer> scrambledOptions = question.getOptions();
// question.scrambleOptions();
List<Answer> scrambledOptions = question.returnScrambledOptions();

Assertions.assertTrue(scrambledOptions.contains(option1));
Assertions.assertTrue(scrambledOptions.contains(option2));
Expand Down

0 comments on commit c897fba

Please sign in to comment.