Skip to content

Commit

Permalink
issues
Browse files Browse the repository at this point in the history
  • Loading branch information
uo288574 committed Apr 27, 2024
1 parent b5370e2 commit 4f3bf4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
10 changes: 0 additions & 10 deletions webapp/src/components/FirstGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ const Quiz = () => {


console.log("Todas las preguntas", allQuestions)
// console.log(option === questions[currentQuestionIndex].correctAnswer)
isCorrect = (option === allQuestions[currentQuestionIndex].correctAnswer);

changeButtons("true")
// changeButtons(true);

const numberAnswer = allQuestions[currentQuestionIndex].options.indexOf(allQuestions[currentQuestionIndex].correctAnswer)
const botonCorrecta = document.getElementById('option-' + numberAnswer)
Expand Down Expand Up @@ -114,18 +112,10 @@ const Quiz = () => {

const botonIncorrecta = document.getElementById('option-' + allQuestions[currentQuestionIndex].options.indexOf(option))

// console.log(haveFailedQuestion)
// console.log(isCorrect)
if (!isCorrect) {
console.log("Entramos en el correct")
// console.log(isCorrect)
botonIncorrecta.style.backgroundColor = 'red'
// console.log("Entramos a cambiar")
// haveFailedQuestion = true;

// console.log("Despues de modificar los valores")
} else {
// getQuestions()
points = points += 100;
}

Expand Down
20 changes: 10 additions & 10 deletions webapp/src/components/game/GameConfiguration.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ const GameConfiguration = () => {
}

function formatearTopics() {
var topicsFormated = ''
let topicsFormated = '';

for (var i = 0; i < tematicasSeleccionadas.length; i++) {
topicsFormated += ("&tema=" + tematicasSeleccionadas[i])
for (const tema of tematicasSeleccionadas) {
topicsFormated += `&tema=${tema}`;
}

return topicsFormated
Expand All @@ -95,18 +95,18 @@ const GameConfiguration = () => {
try {
const topicsFormated = formatearTopics()
const response = await axios.get(`${apiEndpoint}/questions?n_preguntas=${numPreguntas}&n_respuestas=${numRes}${topicsFormated}`);
for (var i = 0; i < response.data.length; i++) {
var possibleAnswers = [response.data[i].respuesta_correcta]
for (var j = 0; j < response.data[i].respuestas_incorrectas.length; j++) {
possibleAnswers.push(response.data[i].respuestas_incorrectas[j])
for (const pregunta of response.data) {
let possibleAnswers = [pregunta.respuesta_correcta]
for (const respuestaIncorrecta of pregunta.respuestas_incorrectas) {
possibleAnswers.push(respuestaIncorrecta)
}
possibleAnswers = shuffleArray(possibleAnswers)
questions.push({
question: response.data[i].pregunta,
question: pregunta.pregunta,
options: possibleAnswers,
correctAnswer: response.data[i].respuesta_correcta
correctAnswer: pregunta.respuesta_correcta
})
}
}
} catch (error) {
console.error(error);
}
Expand Down
4 changes: 0 additions & 4 deletions webapp/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ code {
flex-wrap: wrap;
}

#root{

}

#root > main > h1{
text-align: center;
}
Expand Down

0 comments on commit 4f3bf4f

Please sign in to comment.