一切测验
This is an automatic translation. Read the original

<头>
<元字符集=“UTF-8”>
<风格>
身体{
字体系列:Arial、无衬线字体;
背景:线性渐变(135deg,#1e1e2f,#2c2c54);
颜色: 白色;
文本对齐:居中;
内边距:20px;
}
h1 {
颜色:#00d4ff;
}
.quiz-box {
背景:#2f2f4f;
内边距:20px;
边框半径:15px;
最大宽度:600px;
保证金:自动;
盒子阴影:0 0 20px rgba(0,0,0,0.5);
}
.问题{
字体大小:20px;
下边距:15px;
}
按钮{
显示:块;
边距:自动 10 像素;
内边距:10 像素 15 像素;
宽度:80%;
边框:无;
边框半径:10px;
背景:#00d4ff;
颜色:黑色;
字体大小:16px;
光标:指针;
过渡:0.3s;
}
按钮:悬停{
背景:#00a3cc;
}
.正确{
背景:#4caf50!重要;
}
.错误{
背景:#f44336!重要;
}
#分数{
顶部边距:20px;
字体大小:22px;
}
<正文>
<脚本>
常量测验 = [
{
问:“12 × 8 是什么?”,
a:[“96”,“88”,“108”,“86”],
正确:0
},
{
q:“哪颗行星被称为红色星球?”,
a:[“地球”,“火星”,“木星”,“金星”],
正确:1
},
{
q: "《罗密欧与朱丽叶》是谁写的?",
a: [“查尔斯·狄更斯”、“威廉·莎士比亚”、“马克·吐温”、“简·奥斯汀”]、
正确:1
},
{
q: "144 的平方根是多少?",
a:[“10”,“11”,“12”,“13”],
正确:2
},
{
q:“第二次世界大战是哪一年结束的?”,
a:[“1942年”,“1945年”,“1939年”,“1950年”],
正确:1
},
{
q: “H2O 俗称什么?”,
a:[“氧”,“氢”,“盐”,“水”],
正确:3
},
{
q:“求解:3x = 21”,
a:[“5”,“6”,“7”,“8”],
正确:2
},
{
问:“法国的首都是哪里?”,
a:[“柏林”、“马德里”、“巴黎”、“罗马”],
正确:2
},
{
问:“植物吸收哪种气体?”,
a:[“氧气”,“二氧化碳”,“氮气”,“氢气”],
正确:1
},
{
问:“世界上最长的河流是什么?”,
a:[“亚马逊”、“尼罗河”、“多瑙河”、“密西西比河”],
正确:1
}
];
令电流=0;
让分数= 0;
函数加载问题(){
const q = 测验[当前];
document.getElementById("问题").innerText = q.q;
constanswerDiv = document.getElementById("answers");
answersDiv.innerHTML = "";
q.a.forEach((答案, 索引) => {
const btn = document.createElement("按钮");
btn.innerText = 答案;
btn.onclick = () => checkAnswer(index, btn);
answerDiv.appendChild(btn);
});
}
函数 checkAnswer(索引, btn) {
const CorrectIndex = quiz[当前]. Correct;
if (索引===正确索引) {
btn.classList.add("正确");
分数++;
} 否则{
btn.classList.add("错误");
}
Array.from(document.getElementById("answers").children)
.forEach(b => b.disabled = true);
设置超时(()=> {
当前++;
if (当前 < 测验长度) {
加载问题();
} 否则{
document.querySelector(".quiz-box").innerHTML =
"
一切测验
测验完成!
您的分数:" + 分数 + " / " + quiz.length + "
"; } }, 1000); } 加载问题();

