From a1ef5785268e47ffe2a3d93ae276f43cab58e0ba Mon Sep 17 00:00:00 2001 From: nicoboy Date: Sun, 4 Jan 2026 09:47:58 +0100 Subject: [PATCH] erreur chatbot --- assets/js/chatbot.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/assets/js/chatbot.js b/assets/js/chatbot.js index 9856938..e3cea2c 100644 --- a/assets/js/chatbot.js +++ b/assets/js/chatbot.js @@ -47,9 +47,17 @@ class ChatbotIA { }); } - ouvrirChat() { - // Récupérer l'ID de la question ACTUELLE dynamiquement - this.currentQuestionId = this.detectCurrentQuestion(); + ouvrirChat() { + // Utiliser la variable globale currentQuestion du formulaire + if (typeof window.currentQuestion !== 'undefined' && window.questionsIds) { + // currentQuestion est l'index (1-80), on récupère l'ID réel + const questionIndex = window.currentQuestion - 1; + this.currentQuestionId = window.questionsIds[questionIndex]; + console.log('💬 Question détectée via currentQuestion:', window.currentQuestion, '→ ID:', this.currentQuestionId); + } else { + // Fallback sur la détection par classe active + this.currentQuestionId = this.detectCurrentQuestion(); + } if (!this.currentQuestionId) { alert('Erreur : impossible de déterminer la question actuelle');