trivia: maybe true and false wont act up now? idk im dumb somtimes

This commit is contained in:
Ayden Jahola 2024-09-06 00:18:16 +01:00
parent 06934db8b9
commit 4572fb18ed
No known key found for this signature in database
GPG key ID: 71DD90AE4AE92742

View file

@ -96,7 +96,17 @@ module.exports = {
// Handle True/False questions specifically
if (triviaQuestion.type === "boolean") {
allAnswers = ["True", "False"];
// Always keep "True" as option 1 and "False" as option 2
answerMap = { 1: "True", 2: "False" };
} else {
// Shuffle answers for other types of questions
allAnswers = allAnswers.sort(() => Math.random() - 0.5);
// Create a mapping of numbers to answers
answerMap = allAnswers.reduce((map, answer, index) => {
map[index + 1] = answer;
return map;
}, {});
}
allAnswers = allAnswers.sort(() => Math.random() - 0.5); // Shuffle answers