diff --git a/G102-sequence/tdv_sdk.js b/G102-sequence/tdv_sdk.js index e53c497..77229e3 100644 --- a/G102-sequence/tdv_sdk.js +++ b/G102-sequence/tdv_sdk.js @@ -254,13 +254,30 @@ var tdv_sdk = { lastLoadedLevel: -1, loadQuestions: function () { + if (this.lastLoadedLevel === this.level && this.currentWords.length > 0) { + console.log("⏭️ Sentence", this.level + 1, "already loaded, skipping..."); + return; + } + this.currentQuestion = this.list[this.level]; - this.questionStartTime = new Date(); - window.gameState = 0; - window.answerResult = -1; if (this.currentQuestion) { - if (!this.currentQuestion.id) this.currentQuestion.id = "Q" + (this.level + 1); - console.log(`📝 Loaded Q${this.level + 1}: ${this.currentQuestion.question}`); + // ===== NORMALIZE DATA (COMPANY STANDARD) ===== + var q = this.currentQuestion; + + // Chuẩn công ty + if (q.question && !q.sentence) { + q.sentence = q.question; + } + + // Options / words + if (Array.isArray(q.options) && !q.parts) { + q.parts = q.options; + } + + // Fallback cuối + if (!q.parts && q.sentence) { + q.parts = q.sentence.split(/\s+/); + } } },