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

This commit is contained in:
lubukhu
2026-01-30 18:33:34 +07:00
commit 8870c30d91
60 changed files with 25410 additions and 0 deletions

51
RCV_QuizSpin2/tdv_sdk.js Normal file
View File

@@ -0,0 +1,51 @@
let data = []; // thay vì animals
// Hàm load dữ liệu từ file data.json
async function loadData() {
try {
const res = await fetch("data.json");
data = await res.json();
} catch (error) {
console.error("Lỗi load data:", error);
return [];
}
}
// Hàm chọn ngẫu nhiên 4 con và lấy 1 con làm đáp án đúng
function getRandomQuestion() {
if (data.length < 3) {
console.error("Không đủ dữ liệu để chọn!");
return null;
}
// Shuffle
const shuffled = [...data].sort(() => 0.5 - Math.random());
// Lấy 4 con đầu tiên
const options = shuffled.slice(0, 3).map(item => ({
...item,
image: getImage(item.image)
}));
// Chọn 1 trong 4 làm đáp án đúng
const correct = options[Math.floor(Math.random() * options.length)];
window.items = {
options: options,
correct: correct
};
return window.items;
}
function voiceItem(name){
const newAudio = new Audio();
newAudio.src = "https://audio.senaai.vn/audio/en_female_1_"+name.toLowerCase()+".mp3";
newAudio.play();
}
function getImage(name) {
return "https://senaai.tech/games/RCV-QuizSpin2/" + name;
}