This commit is contained in:
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 69 KiB |
@@ -1,12 +1,11 @@
|
||||
{
|
||||
"version": 1772164483,
|
||||
"version": 1772438857,
|
||||
"fileList": [
|
||||
"data.js",
|
||||
"c2runtime.js",
|
||||
"jquery-3.4.1.min.js",
|
||||
"offlineClient.js",
|
||||
"images/card-sheet0.png",
|
||||
"images/logo-sheet0.png",
|
||||
"images/khung_timer-sheet0.png",
|
||||
"images/whitebg-sheet0.png",
|
||||
"images/boardsetting-sheet0.png",
|
||||
@@ -37,7 +36,6 @@
|
||||
"icon-128.png",
|
||||
"icon-256.png",
|
||||
"loading-logo.png",
|
||||
"bg.mp4",
|
||||
"sena_sdk.js"
|
||||
]
|
||||
}
|
||||
@@ -119,6 +119,7 @@ SenaSDK.prototype.loadFromPostMessage = function (inputJson, callback) {
|
||||
console.warn("⚠️ Sena SDK: tdv_sdk not found, storing data locally");
|
||||
self.data = inputJson.data;
|
||||
self.correctAnswer = inputJson.answer;
|
||||
self._parseGameCode(); // Thêm dòng này để SDK đọc đuôi thời gian T30
|
||||
if (callback) callback(true);
|
||||
}
|
||||
return true;
|
||||
@@ -154,7 +155,7 @@ SenaSDK.prototype.loadFromPostMessage = function (inputJson, callback) {
|
||||
// Lưu trữ danh sách gốc
|
||||
self.masterList = [...self.data.options];
|
||||
// Tính tổng số level
|
||||
self.totalLevels = Math.ceil(self.masterList.length / self.itemCount);
|
||||
self.totalLevels = Math.ceil(self.masterList.length / 6);
|
||||
self.currentLevel = 0;
|
||||
|
||||
// Load Level 1 ngay lập tức để self.data.options chỉ chứa 6 card đầu
|
||||
@@ -518,7 +519,7 @@ SenaSDK.prototype._loadFromServer = function (
|
||||
// Lưu trữ danh sách gốc
|
||||
self.masterList = [...self.data.options];
|
||||
// Tính tổng số level
|
||||
self.totalLevels = Math.ceil(self.masterList.length / self.itemCount);
|
||||
self.totalLevels = Math.ceil(self.masterList.length / 6);
|
||||
self.currentLevel = 0;
|
||||
|
||||
// Load Level 1 ngay lập tức để self.data.options chỉ chứa 6 card đầu
|
||||
@@ -1037,6 +1038,10 @@ SenaSDK.prototype.getHintValue = function (index) {
|
||||
SenaSDK.prototype.start = function () {
|
||||
let self = this;
|
||||
|
||||
// LUÔN GÁN THỜI GIAN BẮT ĐẦU Ở ĐÂY
|
||||
self.startTime = Date.now();
|
||||
console.log("🎮 Sena SDK: Game Started");
|
||||
|
||||
// Nếu là matching game, forward sang tdv_sdk.start()
|
||||
if (self.isMatchingGame) {
|
||||
console.log("🎮 Sena SDK: Matching game - forwarding start() to tdv_sdk");
|
||||
@@ -1051,7 +1056,6 @@ SenaSDK.prototype.start = function () {
|
||||
if (self.shuffle && self.data && self.data.options) {
|
||||
self.shuffleArray(self.data.options);
|
||||
}
|
||||
self.startTime = Date.now();
|
||||
// Additional logic for tracking can be added here if needed
|
||||
};
|
||||
|
||||
@@ -1083,7 +1087,7 @@ SenaSDK.prototype.canReloadData = function () {
|
||||
|
||||
/**
|
||||
* End the game and check answer
|
||||
* [UPDATE] Support Unordered Answers & Auto-cleanup empty strings
|
||||
* [UPDATE] Support Unordered Answers, Auto-cleanup empty strings & Post GAME_RESULT to FE
|
||||
*/
|
||||
SenaSDK.prototype.end = function (answer, callback) {
|
||||
let self = this;
|
||||
@@ -1103,6 +1107,20 @@ SenaSDK.prototype.end = function (answer, callback) {
|
||||
`Result: ${correctCount}/${totalPairs} correct - ${isCorrect ? "CORRECT" : "INCORRECT"}`,
|
||||
);
|
||||
|
||||
// [NEW] Universal PostMessage for BE
|
||||
window.parent.postMessage(
|
||||
{
|
||||
type: "GAME_RESULT",
|
||||
payload: {
|
||||
game_id: self.gameID || self.gameCode,
|
||||
result: isCorrect ? "CORRECT" : "INCORRECT",
|
||||
time_spent: duration,
|
||||
},
|
||||
},
|
||||
"*",
|
||||
);
|
||||
console.log("📤 Sena SDK: GAME_RESULT sent successfully");
|
||||
|
||||
if (callback) callback(isCorrect);
|
||||
return {
|
||||
isCorrect: isCorrect,
|
||||
@@ -1199,12 +1217,24 @@ SenaSDK.prototype.end = function (answer, callback) {
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// [BƯỚC 3] Log và Return
|
||||
// [BƯỚC 3] Log và Return (KÈM BẮN POST MESSAGE CHO FE)
|
||||
// -----------------------------------------------------------
|
||||
console.log(`Time spent: ${duration}s`);
|
||||
console.log(
|
||||
`Result: ${isCorrect ? "CORRECT" : "INCORRECT"} (User: ${result.userAnswer} vs Correct: ${result.correctAnswer})`,
|
||||
console.log(`Result: ${isCorrect ? "CORRECT" : "INCORRECT"}`);
|
||||
|
||||
// THÊM MỚI: Bắn tín hiệu GAME_RESULT lên cho hệ thống FE tính điểm
|
||||
window.parent.postMessage(
|
||||
{
|
||||
type: "GAME_RESULT",
|
||||
payload: {
|
||||
game_id: self.gameID || self.gameCode,
|
||||
result: isCorrect ? "CORRECT" : "INCORRECT",
|
||||
time_spent: duration,
|
||||
},
|
||||
},
|
||||
"*",
|
||||
);
|
||||
console.log("📤 Sena SDK: GAME_RESULT sent successfully for Quiz/Sort/Fill");
|
||||
|
||||
if (callback) callback(result.isCorrect);
|
||||
return result; // Return full object for debug
|
||||
@@ -1733,7 +1763,7 @@ SenaSDK.prototype.loadLevelG5 = function (levelIndex) {
|
||||
if (self.gameType !== 5 || !self.masterList) return false;
|
||||
|
||||
self.currentLevel = levelIndex;
|
||||
let count = self.itemCount; // Số card tối đa mỗi trang (VD: 6)
|
||||
let count = 6; // Khóa cứng max 6 card/trang cho G5
|
||||
|
||||
window.Sena_TotalLevels = Math.ceil(self.masterList.length / count);
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user