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

Correción contador de preguntas y primera respuesta correcta #193

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading