up
All checks were successful
Deploy to Production / deploy (push) Successful in 8s

This commit is contained in:
lubukhu
2026-01-24 14:56:52 +07:00
parent de61a67c61
commit 404c8985f1

View File

@@ -265,7 +265,40 @@ var tdv_sdk = {
if (!q.parts && q.sentence) { if (!q.parts && q.sentence) {
q.parts = q.sentence.split(/\s+/); q.parts = q.sentence.split(/\s+/);
} }
// ===== LOGIC GỐC (BẮT BUỘC PHẢI CÓ) =====
this.correctSentence = String(q.sentence || "").trim();
if (q.parts && Array.isArray(q.parts) && q.parts.length > 0) {
this.currentWords = [...q.parts];
this.correctWords = this.correctSentence.split(/\s+/).filter(w => w.length > 0);
console.log("📦 Using server-provided parts:", this.currentWords);
} else {
this.correctWords = this.correctSentence.split(/\s+/).filter(w => w.length > 0);
this.currentWords = this.shuffleArray([...this.correctWords]);
console.log("🔀 Auto-split and shuffled words");
} }
// reset + blank logic
this.resetPlacedWords();
this.generateBlankIndexes();
this.generateMissingWords();
this.newWidth = this.calculateWordWidth(this.currentWords);
this.listPosX = this.getObjectPositions(
this.currentWords.length,
this.newWidth,
this.margin,
this.maxWWidth
);
this.lastLoadedLevel = this.level;
console.log("📝 Correct sentence:", this.correctSentence);
console.log("📝 Display words:", this.currentWords);
console.log("📝 Word count:", this.currentWords.length);
}
}, },
// Tính width dựa trên số từ và độ dài từ dài nhất // Tính width dựa trên số từ và độ dài từ dài nhất