|
|
|
|
@ -782,6 +782,12 @@
@@ -782,6 +782,12 @@
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showResultsBtn.disabled = !allAnswered || connectedModules.size === 0; |
|
|
|
|
|
|
|
|
|
// Afficher automatiquement les résultats si tous les modules ont répondu |
|
|
|
|
if (allAnswered && connectedModules.size > 0 && !resultsShown) { |
|
|
|
|
console.log('✅ Tous les modules ont répondu - Calcul automatique des scores'); |
|
|
|
|
showResults(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function showResults() { |
|
|
|
|
@ -789,7 +795,10 @@
@@ -789,7 +795,10 @@
|
|
|
|
|
resultsShown = true; |
|
|
|
|
|
|
|
|
|
const question = questions[currentQuestionIndex]; |
|
|
|
|
const correctAnswerIndex = question.correctAnswer; |
|
|
|
|
// Utiliser la position mélangée de la bonne réponse |
|
|
|
|
const correctAnswerIndex = question.shuffledCorrectAnswer !== undefined |
|
|
|
|
? question.shuffledCorrectAnswer |
|
|
|
|
: question.correctAnswer; |
|
|
|
|
const correctLetter = ['A', 'B', 'C', 'D'][correctAnswerIndex]; |
|
|
|
|
const scoringConfig = getScoringConfig(); |
|
|
|
|
|
|
|
|
|
@ -1023,6 +1032,16 @@
@@ -1023,6 +1032,16 @@
|
|
|
|
|
showQuestion(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Fonction pour mélanger un tableau (algorithme Fisher-Yates) |
|
|
|
|
function shuffleArray(array) { |
|
|
|
|
const shuffled = [...array]; |
|
|
|
|
for (let i = shuffled.length - 1; i > 0; i--) { |
|
|
|
|
const j = Math.floor(Math.random() * (i + 1)); |
|
|
|
|
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]]; |
|
|
|
|
} |
|
|
|
|
return shuffled; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function showQuestion() { |
|
|
|
|
if (currentQuestionIndex >= questions.length) { |
|
|
|
|
showFinalScore(); |
|
|
|
|
@ -1032,17 +1051,27 @@
@@ -1032,17 +1051,27 @@
|
|
|
|
|
resultsShown = false; |
|
|
|
|
const question = questions[currentQuestionIndex]; |
|
|
|
|
|
|
|
|
|
// Mélanger les réponses et mémoriser la nouvelle position de la bonne réponse |
|
|
|
|
const originalAnswers = question.answers; |
|
|
|
|
const answerIndices = [0, 1, 2, 3]; // Indices originaux |
|
|
|
|
const shuffledIndices = shuffleArray(answerIndices); |
|
|
|
|
const shuffledAnswers = shuffledIndices.map(i => originalAnswers[i]); |
|
|
|
|
|
|
|
|
|
// Stocker la nouvelle position de la bonne réponse |
|
|
|
|
const newCorrectAnswerIndex = shuffledIndices.indexOf(question.correctAnswer); |
|
|
|
|
question.shuffledCorrectAnswer = newCorrectAnswerIndex; |
|
|
|
|
|
|
|
|
|
// Afficher la question |
|
|
|
|
document.querySelector('.question-number').textContent = |
|
|
|
|
`Question ${currentQuestionIndex + 1}/${questions.length}`; |
|
|
|
|
document.querySelector('.question-text').innerHTML = formatText(question.question); |
|
|
|
|
|
|
|
|
|
// Afficher les réponses |
|
|
|
|
// Afficher les réponses mélangées |
|
|
|
|
const answersContainer = document.getElementById('answersContainer'); |
|
|
|
|
answersContainer.innerHTML = ''; |
|
|
|
|
|
|
|
|
|
const letters = ['A', 'B', 'C', 'D']; |
|
|
|
|
question.answers.forEach((answer, index) => { |
|
|
|
|
shuffledAnswers.forEach((answer, index) => { |
|
|
|
|
const answerDiv = document.createElement('div'); |
|
|
|
|
answerDiv.className = 'answer'; |
|
|
|
|
|
|
|
|
|
@ -1085,6 +1114,12 @@
@@ -1085,6 +1114,12 @@
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function showNextQuestion() { |
|
|
|
|
// Calculer les scores avant de passer à la question suivante |
|
|
|
|
// (même si tous les modules n'ont pas répondu) |
|
|
|
|
if (!resultsShown && currentQuestionIndex < questions.length) { |
|
|
|
|
showResults(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (currentQuestionIndex < questions.length - 1) { |
|
|
|
|
currentQuestionIndex++; |
|
|
|
|
showQuestion(); |
|
|
|
|
|