Files
dsProject/dsLightRag/static/YunXiao/physics_quiz.js
2025-08-28 15:35:54 +08:00

529 lines
30 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 存储各难度题目的正确答案
const correctAnswers = {
medium: {
mq1: 'B',
mq2: 'D',
mq3: 'B',
mq4: 'A',
mq5: 'C'
},
easy: {
eq1: 'B',
eq2: 'A',
eq3: 'C',
eq4: 'B',
eq5: 'A'
},
hard: {
hq1: 'C',
hq2: 'A',
hq3: 'C',
hq4: ['C', 'D'], // 多选题正确答案是CD
hq5: ['A', 'C'] // 多选题正确答案是AC
}
};
// 所有试题数据
const quizQuestions = [
// 中等难度题目
{
id: 'mq1',
difficulty: 'medium',
number: 1,
points: 20,
text: '关于万有引力定律,下列说法正确的是(  )',
options: [
{ id: 'mq1-a', label: 'A', text: '万有引力定律是牛顿发现的' },
{ id: 'mq1-b', label: 'B', text: '万有引力定律适用于自然界中任何两个物体之间' },
{ id: 'mq1-c', label: 'C', text: '万有引力定律只适用于天体之间' },
{ id: 'mq1-d', label: 'D', text: '万有引力定律只适用于质点之间' }
],
explanation: '正确答案B<br>解析万有引力定律是牛顿发现的故A正确万有引力定律适用于自然界中任何两个物体之间故B正确万有引力定律不仅适用于天体之间也适用于地面上的物体之间故C错误万有引力定律适用于任何两个物体之间对于质量分布均匀的球体可以将其视为质量集中在球心的质点来处理故D错误。根据题目要求选择B。'
},
{
id: 'mq2',
difficulty: 'medium',
number: 2,
points: 20,
text: '地球质量为M半径为R引力常量为G。一颗质量为m的人造地球卫星在距离地面高度为h的轨道上做匀速圆周运动  ',
options: [
{ id: 'mq2-a', label: 'A', text: '卫星的线速度大小为<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/e2ef2d4a91a3dfc8f7e227c45dcf5dc0/media/image1.png" alt="公式">' },
{ id: 'mq2-b', label: 'B', text: '卫星的角速度大小为<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/e2ef2d4a91a3dfc8f7e227c45dcf5dc0/media/image2.png" alt="公式">' },
{ id: 'mq2-c', label: 'C', text: '卫星的向心加速度大小为<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/e2ef2d4a91a3dfc8f7e227c45dcf5dc0/media/image3.png" alt="公式">' },
{ id: 'mq2-d', label: 'D', text: '卫星的周期为<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/e2ef2d4a91a3dfc8f7e227c45dcf5dc0/media/image4.png" alt="公式">' }
],
explanation: '正确答案C<br>解析A.卫星的线速度大小为v=√(GM/(R+h))故A错误B.卫星的角速度大小为ω=√(GM/(R+h)³)故B错误C.卫星的向心加速度大小为a=GM/(R+h)²故C正确D.卫星的周期为T=2π√((R+h)³/GM)故D错误。故答案为C。'
},
{
id: 'mq3',
difficulty: 'medium',
number: 3,
points: 20,
text: '已知地球质量为M半径为R引力常量为G。一物体在地球表面所受的重力为mg若将该物体移至距离地面高度为R的位置则该物体所受的重力为  ',
options: [
{ id: 'mq3-a', label: 'A', text: 'mg/4' },
{ id: 'mq3-b', label: 'B', text: 'mg/2' },
{ id: 'mq3-c', label: 'C', text: '2mg' },
{ id: 'mq3-d', label: 'D', text: '4mg' }
],
explanation: '正确答案A<br>解析物体在地球表面所受的重力为mg=GMm/R²当物体移至距离地面高度为R的位置时物体到地心的距离为2R此时重力为mg\'=GMm/(2R)²=GMm/4R²=mg/4故答案为A。'
},
{
id: 'mq4',
difficulty: 'medium',
number: 4,
points: 20,
text: '关于开普勒行星运动定律,下列说法正确的是(  )',
options: [
{ id: 'mq4-a', label: 'A', text: '所有行星绕太阳运动的轨道都是正圆' },
{ id: 'mq4-b', label: 'B', text: '行星在近日点的速率小于在远日点的速率' },
{ id: 'mq4-c', label: 'C', text: '所有行星的轨道半长轴的三次方与公转周期的二次方的比值都相等' },
{ id: 'mq4-d', label: 'D', text: '开普勒定律仅适用于行星绕太阳的运动' }
],
explanation: '正确答案C<br>解析A.开普勒第一定律指出所有行星绕太阳运动的轨道都是椭圆太阳处在椭圆的一个焦点上不是正圆故A错误B.根据开普勒第二定律行星与太阳的连线在相等时间内扫过相等的面积因此行星在近日点的速率大于在远日点的速率故B错误C.开普勒第三定律表明所有行星的轨道半长轴的三次方与公转周期的二次方的比值都相等故C正确D.开普勒定律仅适用于行星绕太阳的运动也适用于卫星绕行星的运动只是比值不同故D错误。故答案为C。'
},
{
id: 'mq5',
difficulty: 'medium',
number: 5,
points: 20,
text: '我国首颗超百Gbps容量高通量地球静止轨道通信卫星中星26号卫星于北京时间2023年2月23日在西昌卫星发射中心成功发射该卫星主要用于为固定端及车、船、机载终端提供高速宽带接入服务。如图某时刻中星26与椭圆轨道侦察卫星恰好位于C、D两点两星轨道相交于A、B两点C、D连线过地心D点为远地点两卫星运行周期都为T。下列说法正确的是  <br><br><img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/760c54b8e6491d7c3ac566d6299818a4/media/image1.png" alt="轨道图">',
options: [
{ id: 'mq5-a', label: 'A', text: '中星26与侦察卫星可能在A点或B点相遇' },
{ id: 'mq5-b', label: 'B', text: '侦查卫星从D点运动到A点过程中机械能增大' },
{ id: 'mq5-c', label: 'C', text: '中星26在C点线速度<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/760c54b8e6491d7c3ac566d6299818a4/media/image2.png" alt="公式">与侦察卫星在D点线速度<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/760c54b8e6491d7c3ac566d6299818a4/media/image3.png" alt="公式">相等' },
{ id: 'mq5-d', label: 'D', text: '相等时间内中星26与地球的连线扫过的面积大于侦察卫星与地球的连线扫过的面积' }
],
explanation: '正确答案D<br>解析A.中星26与侦察卫星周期相同并且当中星26在下半周运动时卫星在上半周运动故不可能相遇故A错误B.侦查卫星在D到A点过程中只有引力做功故机械能不变故B错误C.开普勒第二定律可知在近地点速度大于远地点速度故中星26在C点线速度大于侦察卫星在D点线速度故C错误D.中星26与侦察卫星的周期相同由开普勒第三定律中星26轨道半径等于侦察卫星的半长轴运动一个周期中星26是一个圆而侦察卫星是一个椭圆由于圆的面积大于椭圆的面积故相等时间内中星26与地球的连线扫过的面积大于侦察卫星与地球的连线扫过的面积故D正确故答案为D。'
},
// 简单难度题目
{
id: 'eq1',
difficulty: 'easy',
number: 1,
points: 20,
text: '万有引力定律是由哪位科学家提出的?',
options: [
{ id: 'eq1-a', label: 'A', text: '爱因斯坦' },
{ id: 'eq1-b', label: 'B', text: '牛顿' },
{ id: 'eq1-c', label: 'C', text: '伽利略' },
{ id: 'eq1-d', label: 'D', text: '开普勒' }
],
explanation: '正确答案B<br>解析万有引力定律是由英国科学家牛顿在1687年提出的故答案为B。'
},
{
id: 'eq2',
difficulty: 'easy',
number: 2,
points: 20,
text: '地球对物体的吸引力称为:',
options: [
{ id: 'eq2-a', label: 'A', text: '重力' },
{ id: 'eq2-b', label: 'B', text: '摩擦力' },
{ id: 'eq2-c', label: 'C', text: '弹力' },
{ id: 'eq2-d', label: 'D', text: '向心力' }
],
explanation: '正确答案A<br>解析地球对物体的吸引力称为重力故答案为A。'
},
{
id: 'eq3',
difficulty: 'easy',
number: 3,
points: 20,
text: '下列哪个现象与万有引力无关?',
options: [
{ id: 'eq3-a', label: 'A', text: '苹果落地' },
{ id: 'eq3-b', label: 'B', text: '月球绕地球运动' },
{ id: 'eq3-c', label: 'C', text: '磁铁吸引铁钉' },
{ id: 'eq3-d', label: 'D', text: '地球绕太阳公转' }
],
explanation: '正确答案C<br>解析磁铁吸引铁钉是磁力作用的结果与万有引力无关故答案为C。'
},
{
id: 'eq4',
difficulty: 'easy',
number: 4,
points: 20,
text: '物体的质量越大,它受到的重力就:',
options: [
{ id: 'eq4-a', label: 'A', text: '越小' },
{ id: 'eq4-b', label: 'B', text: '越大' },
{ id: 'eq4-c', label: 'C', text: '不变' },
{ id: 'eq4-d', label: 'D', text: '无法确定' }
],
explanation: '正确答案B<br>解析根据重力公式G=mg物体受到的重力与质量成正比质量越大重力越大故答案为B。'
},
{
id: 'eq5',
difficulty: 'easy',
number: 5,
points: 20,
text: '在地球表面重力加速度g的近似值为',
options: [
{ id: 'eq5-a', label: 'A', text: '9.8 m/s²' },
{ id: 'eq5-b', label: 'B', text: '5.0 m/s²' },
{ id: 'eq5-c', label: 'C', text: '15.6 m/s²' },
{ id: 'eq5-d', label: 'D', text: '3.0 m/s²' }
],
explanation: '正确答案A<br>解析在地球表面重力加速度g的近似值为9.8 m/s²故答案为A。'
},
// 高级难度题目
{
id: 'hq1',
difficulty: 'hard',
number: 1,
points: 20,
text: '已知地球质量为M半径为R万有引力常量为G。一颗人造卫星在离地面高度为R的圆形轨道上运行则该卫星的运行周期为',
options: [
{ id: 'hq1-a', label: 'A', text: '2π√(2R³/GM)' },
{ id: 'hq1-b', label: 'B', text: '4π√(2R³/GM)' },
{ id: 'hq1-c', label: 'C', text: '2π√(8R³/GM)' },
{ id: 'hq1-d', label: 'D', text: '4π√(R³/GM)' }
],
explanation: '正确答案C<br>解析卫星轨道半径r=R+h=2R根据万有引力提供向心力GMm/r²=m(2π/T)²r解得T=2π√(r³/GM)=2π√((2R)³/GM)=2π√(8R³/GM)故答案为C。'
},
{
id: 'hq2',
difficulty: 'hard',
number: 2,
points: 20,
text: '两个质量分别为m1和m2的星球组成双星系统它们绕两者连线上某一点做匀速圆周运动两星球之间的距离为L。则它们的运行周期T为',
options: [
{ id: 'hq2-a', label: 'A', text: '2π√(L³/G(m1+m2))' },
{ id: 'hq2-b', label: 'B', text: '2π√(L³/2G(m1+m2))' },
{ id: 'hq2-c', label: 'C', text: '2π√(L³/Gm1m2)' },
{ id: 'hq2-d', label: 'D', text: '2π√(L³/G|m1-m2|)' }
],
explanation: '正确答案A<br>解析双星系统中万有引力提供向心力且两星球的角速度相等。设m1和m2到质心的距离分别为r1和r2则r1+r2=Lm1ω²r1=m2ω²r2=Gm1m2/L²解得ω=√(G(m1+m2)/L³)周期T=2π/ω=2π√(L³/G(m1+m2))故答案为A。'
},
{
id: 'hq3',
difficulty: 'hard',
number: 3,
points: 20,
text: '一物体在地球表面的重量为G若将该物体移至距离地心4R的位置R为地球半径则它的重量变为',
options: [
{ id: 'hq3-a', label: 'A', text: 'G/4' },
{ id: 'hq3-b', label: 'B', text: 'G/8' },
{ id: 'hq3-c', label: 'C', text: 'G/16' },
{ id: 'hq3-d', label: 'D', text: 'G/2' }
],
explanation: '正确答案C<br>解析重量即物体受到的重力根据万有引力公式G=GMm/r²当距离地心由R变为4R时重力变为原来的1/16故答案为C。'
},
{
id: 'hq4',
difficulty: 'hard',
number: 4,
points: 20,
text: '关于如图a、图b、图c、图d所示的四种情况下列说法中不正确的是   <br><br><img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/1fed2b06e9b4da9f88221ee2ed96a315/media/image1.png" alt="四种情况图">',
options: [
{ id: 'hq4-a', label: 'A', text: '图a中火车以大于规定速度经过外轨高于内轨的弯道时火车对外轨有压力' },
{ id: 'hq4-b', label: 'B', text: '图b中英国科学家卡文迪什利用了扭秤实验成功地测出了引力常量' },
{ id: 'hq4-c', label: 'C', text: '图c中牛顿根据第谷的观测数据提出了关于行星运动的三大定律' },
{ id: 'hq4-d', label: 'D', text: '图d中小球通过轻杆在竖直面内做圆周运动通过最高点的最小速度为<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/1fed2b06e9b4da9f88221ee2ed96a315/media/image2.png" alt="公式">' }
],
explanation: '正确答案CD<br>解析A图a中火车以大于规定速度经过外轨高于内轨的弯道时火车重力和轨道对火车的支持力的合力不足以提供向心力此时外轨对火车有压力从而提供一部分向心力根据牛顿第三定律可知火车对外轨有压力A正确不符合题意B图b中英国科学家卡文迪什利用了扭秤实验成功地测出了引力常量B正确不符合题意C图c中开普勒根据第谷的观测数据提出了关于行星运动的三大定律C错误符合题意D图d中小球通过轻杆在竖直面内做圆周运动由于轻杆对小球可以有竖直向上支持力的作用所以小球通过最高点时向心力可以为零即最小速度为零D错误符合题意。故答案为CD。'
},
{
id: 'hq5',
difficulty: 'hard',
number: 5,
points: 20,
text: '<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image1.png" alt="日期">年<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image2.png" alt="月份">月<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image3.png" alt="日期">日,神舟十二号载人飞船与空间站天和核心舱在轨运行<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image4.png" alt="天数">天后成功实施分离,三名航天员在踏上回家之路前,完成了绕飞和径向交会对接试验,经过两小时的绕飞和三次姿态调整后,神舟十二号飞船来到节点舱的径向对接口正下方,从相距<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image5.png" alt="距离">向相距<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image6.png" alt="距离">靠近,飞船与核心舱的轨道半径分别为<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image7.png" alt="半径">和<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image8.png" alt="半径">,运行周期分别为<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image9.png" alt="周期">和<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image10.png" alt="周期">,下列说法正确的是( <br><br><img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image11.png" alt="轨道图">',
options: [
{ id: 'hq5-a', label: 'A', text: '飞船靠近天和核心舱过程中,向心加速度逐渐增大' },
{ id: 'hq5-b', label: 'B', text: '飞船靠近天和核心舱过程中,所在轨道处的重力加速度逐渐增大' },
{ id: 'hq5-c', label: 'C', text: '交会对接试验过程中,飞船发动机需要提供飞船向前和指向核心舱的作用力' },
{ id: 'hq5-d', label: 'D', text: '交会对接试验过程中应满足<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image12.png" alt="公式">' }
],
explanation: '正确答案AC<br>解析A.交会对接试验过程中,神舟十二号飞船与天和核心舱径向交会对接,角速度大小相同,保持不变,飞船轨道半径逐渐增大,向心加速度<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image13.png" alt="公式">逐渐增大A正确B.根据<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image14.png" alt="公式">可得<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image15.png" alt="公式">飞船靠近天和核心舱过程中<img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image16.png" alt="公式">增大所以所在轨道处的重力加速度逐渐减小B错误C.交会对接试验过程中飞船做离心运动的同时做加速运动所以发动机需要提供飞船向前和指向核心舱的作用力C正确D.交会对接试验过程中, <img src="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/WToM/images/b503155b05ad2749119fb61378d0cdd4/media/image17.png" alt="公式">D错误。故选AC'
}
];
// 跟踪测验状态
const quizState = {
currentDifficulty: 'medium', // 初始难度
completedDifficulties: [],
scores: {}
};
// DOM元素
const submitBtn = document.getElementById('submit-btn');
const nextBtn = document.getElementById('next-btn');
const navigationSection = document.getElementById('navigation');
const navigationMessage = document.getElementById('navigation-message');
const result = document.getElementById('result');
const scoreValue = document.getElementById('score-value');
const correctCount = document.getElementById('correct-count');
const incorrectCount = document.getElementById('incorrect-count');
const difficultyIndicator = document.querySelector('.difficulty-indicator');
const questionSection = document.querySelector('.question-section');
// 获取难度名称
function getDifficultyName(difficulty) {
const names = {
easy: '简单',
medium: '中等',
hard: '高级'
};
return names[difficulty] || difficulty;
}
// 等待DOM加载完成
document.addEventListener('DOMContentLoaded', function() {
// 渲染题目
renderQuestions();
// 录音按钮事件绑定
const startRecordBtn = document.getElementById('startRecordBtn');
const stopRecordBtn = document.getElementById('stopRecordBtn');
const recordingIndicator = document.getElementById('recordingIndicator');
if (startRecordBtn && stopRecordBtn && recordingIndicator) {
startRecordBtn.addEventListener('click', function() {
recordingIndicator.style.display = 'flex';
startRecordBtn.style.display = 'none';
stopRecordBtn.style.display = 'flex';
console.log('开始录音...');
});
stopRecordBtn.addEventListener('click', function() {
recordingIndicator.style.display = 'none';
stopRecordBtn.style.display = 'none';
startRecordBtn.style.display = 'flex';
console.log('停止录音...');
});
} else {
console.error('录音相关DOM元素未找到');
}
// 提交按钮事件
submitBtn.addEventListener('click', function() {
const currentAnswers = correctAnswers[quizState.currentDifficulty];
const totalQuestions = Object.keys(currentAnswers).length;
let score = 0;
let correct = 0;
let incorrect = 0;
// 检查所有问题的答案
for (const [questionName, correctOptions] of Object.entries(currentAnswers)) {
// 获取用户选择的所有选项
const selectedOptions = Array.from(document.querySelectorAll(`input[name="${questionName}"]:checked`))
.map(checkbox => checkbox.value);
const questionNumber = questionName.substring(2); // 从mq1提取1
const explanationElement = document.querySelector(`[data-difficulty="${quizState.currentDifficulty}"][data-question="${questionNumber}"] .question-explanation`);
// 显示解析
explanationElement.style.display = 'block';
if (selectedOptions.length > 0) {
// 标记用户选择的选项
let allCorrect = true;
// 标记用户选择的每个选项
document.querySelectorAll(`input[name="${questionName}"]:checked`).forEach(checkbox => {
const userAnswer = checkbox.value;
if (correctOptions.includes(userAnswer)) {
checkbox.closest('.option').style.backgroundColor = '#e8f5e9';
checkbox.closest('.option').style.borderColor = '#4caf50';
} else {
checkbox.closest('.option').style.backgroundColor = '#ffebee';
checkbox.closest('.option').style.borderColor = '#c62828';
allCorrect = false;
}
});
// 标记用户未选择但正确的选项
document.querySelectorAll(`input[name="${questionName}"]`).forEach(checkbox => {
if (correctOptions.includes(checkbox.value) && !checkbox.checked) {
checkbox.closest('.option').style.backgroundColor = '#e3f2fd';
checkbox.closest('.option').style.borderColor = '#2196f3';
allCorrect = false;
}
});
// 判断是否全对
if (allCorrect && selectedOptions.length === correctOptions.length) {
score += 20; // 每题20分
correct++;
} else {
incorrect++;
}
} else {
// 未答题
incorrect++;
const questionElement = document.querySelector(`[data-difficulty="${quizState.currentDifficulty}"][data-question="${questionNumber}"]`);
questionElement.style.border = '2px solid #ff9800';
// 显示所有正确答案
document.querySelectorAll(`input[name="${questionName}"]`).forEach(checkbox => {
if (correctOptions.includes(checkbox.value)) {
checkbox.closest('.option').style.backgroundColor = '#e3f2fd';
checkbox.closest('.option').style.borderColor = '#2196f3';
}
});
}
}
// 保存当前难度得分
quizState.scores[quizState.currentDifficulty] = {
score: score,
correct: correct,
incorrect: incorrect
};
quizState.completedDifficulties.push(quizState.currentDifficulty);
// 显示当前难度结果
scoreValue.textContent = score;
correctCount.textContent = correct;
incorrectCount.textContent = incorrect;
result.style.display = 'block';
// 隐藏提交按钮
submitBtn.style.display = 'none';
// 根据当前难度和得分决定下一步
if (quizState.currentDifficulty === 'medium') {
if (correct < 3) {
// 中等难度答对少于3题推荐简单难度
showNavigation('您在中等难度题目中表现不佳,建议先完成简单难度题目来巩固基础。', 'easy');
} else {
// 中等难度答对3题及以上推荐高级难度
showNavigation('恭喜您完成中等难度题目!接下来挑战高级难度题目吧。', 'hard');
}
} else {
// 简单或高级难度完成后,显示最终结果
showFinalResult();
}
});
// 开始下一组题目
nextBtn.addEventListener('click', function() {
const nextDifficulty = navigationSection.dataset.nextDifficulty;
if (!nextDifficulty) return;
// 更新当前难度
quizState.currentDifficulty = nextDifficulty;
// 隐藏导航和结果
navigationSection.style.display = 'none';
result.style.display = 'none';
// 显示提交按钮
submitBtn.style.display = 'inline-block';
// 更新难度指示器
difficultyIndicator.textContent = `当前难度:${getDifficultyName(nextDifficulty)}`;
difficultyIndicator.className = `difficulty-indicator difficulty-${nextDifficulty}`;
// 隐藏所有题目
document.querySelectorAll('.question').forEach(question => {
question.classList.add('hidden');
});
// 显示下一组题目
document.querySelectorAll(`[data-difficulty="${nextDifficulty}"]`).forEach(question => {
question.classList.remove('hidden');
});
// 滚动到页面顶部
window.scrollTo(0, 0);
});
});
// 显示导航信息
function showNavigation(message, nextDifficulty) {
navigationMessage.textContent = message;
navigationSection.dataset.nextDifficulty = nextDifficulty;
navigationSection.style.display = 'block';
}
// 显示最终结果
function showFinalResult() {
// 计算总分
let totalScore = 0;
let totalCorrect = 0;
let totalIncorrect = 0;
for (const difficulty of quizState.completedDifficulties) {
totalScore += quizState.scores[difficulty].score;
totalCorrect += quizState.scores[difficulty].correct;
totalIncorrect += quizState.scores[difficulty].incorrect;
}
// 更新结果显示
scoreValue.textContent = totalScore;
correctCount.textContent = totalCorrect;
incorrectCount.textContent = totalIncorrect;
result.style.display = 'block';
// 显示完成信息
navigationMessage.textContent = '恭喜您完成所有推荐题目!';
navigationSection.style.display = 'block';
document.getElementById('next-btn').style.display = 'none';
}
// 渲染题目函数
function renderQuestions() {
// 清空题目区域
questionSection.innerHTML = '';
// 按难度分组题目
const questionsByDifficulty = {};
quizQuestions.forEach(question => {
if (!questionsByDifficulty[question.difficulty]) {
questionsByDifficulty[question.difficulty] = [];
}
questionsByDifficulty[question.difficulty].push(question);
});
// 为每个难度创建题目
Object.keys(questionsByDifficulty).forEach(difficulty => {
questionsByDifficulty[difficulty].forEach((question, index) => {
// 创建题目元素
const questionElement = document.createElement('div');
questionElement.className = 'question';
questionElement.dataset.difficulty = question.difficulty;
questionElement.dataset.question = question.number;
// 如果不是中等难度,添加隐藏类
if (question.difficulty !== 'medium') {
questionElement.classList.add('hidden');
}
// 创建题目HTML结构
let optionsHTML = '';
question.options.forEach(option => {
optionsHTML += `
<div class="option">
<input type="checkbox" id="${option.id}" name="${question.id}" value="${option.label}">
<label for="${option.id}">${option.label}. ${option.text}</label>
</div>
`;
});
// 检查是否为多选题
const isMultipleChoice = correctAnswers[question.difficulty] &&
correctAnswers[question.difficulty][question.id] &&
correctAnswers[question.difficulty][question.id].length > 1;
questionElement.innerHTML = `
<div class="question-header">
<h3>第${question.number}题 (${question.points}分)${isMultipleChoice ? ' <span class="multiple-choice">(多选题)</span>' : ''}</h3>
</div>
<div class="question-content">
<p>${question.text}</p>
<div class="options">
${optionsHTML}
</div>
<div class="question-explanation" style="display: none;">
${question.explanation}
</div>
</div>
`;
questionSection.appendChild(questionElement);
});
});
}