502 lines
29 KiB
JavaScript
502 lines
29 KiB
JavaScript
// 存储各难度题目的正确答案
|
||
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: 'A',
|
||
hq5: 'B'
|
||
}
|
||
};
|
||
|
||
// 所有试题数据
|
||
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=L,m1ω²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 = 'block';
|
||
// 这里添加实际录音功能逻辑
|
||
console.log('开始录音...');
|
||
// 示例:调用录音API或相关函数
|
||
// startRecording();
|
||
});
|
||
|
||
stopRecordBtn.addEventListener('click', function() {
|
||
// 隐藏录音指示器
|
||
recordingIndicator.style.display = 'none';
|
||
// 这里添加停止录音功能逻辑
|
||
console.log('停止录音...');
|
||
// 示例:停止录音并处理音频
|
||
// stopRecording();
|
||
});
|
||
} 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, correctAnswer] of Object.entries(currentAnswers)) {
|
||
const selectedOption = document.querySelector(`input[name="${questionName}"]:checked`);
|
||
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 (selectedOption) {
|
||
const userAnswer = selectedOption.value;
|
||
|
||
// 标记正确或错误
|
||
if (userAnswer === correctAnswer) {
|
||
score += 20; // 每题20分
|
||
correct++;
|
||
selectedOption.closest('.option').style.backgroundColor = '#e8f5e9';
|
||
selectedOption.closest('.option').style.borderColor = '#4caf50';
|
||
} else {
|
||
incorrect++;
|
||
selectedOption.closest('.option').style.backgroundColor = '#ffebee';
|
||
selectedOption.closest('.option').style.borderColor = '#c62828';
|
||
// 标记正确答案
|
||
const correctOption = document.querySelector(`input[name="${questionName}"][value="${correctAnswer}"]`);
|
||
correctOption.closest('.option').style.backgroundColor = '#e8f5e9';
|
||
correctOption.closest('.option').style.borderColor = '#4caf50';
|
||
}
|
||
} else {
|
||
// 未答题
|
||
incorrect++;
|
||
const questionElement = document.querySelector(`[data-difficulty="${quizState.currentDifficulty}"][data-question="${questionNumber}"]`);
|
||
questionElement.style.border = '2px solid #ff9800';
|
||
}
|
||
}
|
||
|
||
// 保存当前难度得分
|
||
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();
|
||
}
|
||
});
|
||
|
||
// 显示导航信息
|
||
function showNavigation(message, nextDifficulty) {
|
||
navigationMessage.textContent = message;
|
||
navigationSection.dataset.nextDifficulty = nextDifficulty;
|
||
navigationSection.style.display = 'block';
|
||
}
|
||
|
||
// 开始下一组题目
|
||
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 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="radio" id="${option.id}" name="${question.id}" value="${option.label}">
|
||
<label for="${option.id}">${option.label}. ${option.text}</label>
|
||
</div>
|
||
`;
|
||
});
|
||
|
||
questionElement.innerHTML = `
|
||
<div class="question-header">
|
||
<h3>第${question.number}题 (${question.points}分)</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);
|
||
});
|
||
});
|
||
} |