From 1a9c9ea067c5ea5093473f9c4613e44490774313 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Thu, 28 Aug 2025 08:58:19 +0800 Subject: [PATCH] 'commit' --- dsLightRag/static/YunXiao/physics_quiz.html | 984 ++++++++++++++++---- dsLightRag/static/YunXiao/physics_quiz.js | 325 ------- 2 files changed, 792 insertions(+), 517 deletions(-) delete mode 100644 dsLightRag/static/YunXiao/physics_quiz.js diff --git a/dsLightRag/static/YunXiao/physics_quiz.html b/dsLightRag/static/YunXiao/physics_quiz.html index 823e2b4b..62f8525a 100644 --- a/dsLightRag/static/YunXiao/physics_quiz.html +++ b/dsLightRag/static/YunXiao/physics_quiz.html @@ -13,37 +13,32 @@ } body { - background-color: #f0f2f5; + background-color: #f5f7fa; color: #333; line-height: 1.6; + padding: 20px; } .container { - max-width: 1200px; + max-width: 1000px; margin: 0 auto; - padding: 20px; + background-color: white; + border-radius: 12px; + box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08); + padding: 30px; } header { text-align: center; margin-bottom: 30px; - padding: 20px 0; - background-color: #1a5276; - color: white; - border-radius: 10px; - box-shadow: 0 4px 12px rgba(0,0,0,0.1); + padding-bottom: 20px; + border-bottom: 1px solid #eee; } h1 { - font-size: 2.2rem; + color: #2c3e50; margin-bottom: 10px; - font-weight: 700; - } - - .quiz-info { - font-size: 1.1rem; - margin-bottom: 20px; - color: #ecf0f1; + font-size: 28px; } .difficulty-indicator { @@ -69,24 +64,30 @@ color: #c62828; } + .quiz-info { + color: #666; + font-size: 16px; + margin-bottom: 20px; + } + .question-section { - background-color: white; - border-radius: 12px; - padding: 30px; - box-shadow: 0 4px 20px rgba(0,0,0,0.08); margin-bottom: 30px; } .question { - margin-bottom: 30px; - padding-bottom: 20px; - border-bottom: 1px solid #eee; + background-color: #f9f9f9; + border-radius: 8px; + padding: 20px; + margin-bottom: 20px; + transition: all 0.3s ease; } - .question:last-child { - border-bottom: none; - margin-bottom: 0; - padding-bottom: 0; + .question.hidden { + display: none; + } + + .question:hover { + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); } .question-header { @@ -98,28 +99,29 @@ .question-number { font-weight: bold; - font-size: 1.1rem; - color: #1a5276; + color: #2980b9; + font-size: 18px; } .question-points { - background-color: #3498db; - color: white; - padding: 4px 10px; + background-color: #e3f2fd; + color: #2980b9; + padding: 3px 10px; border-radius: 12px; - font-size: 0.9rem; + font-size: 14px; } .question-text { - margin-bottom: 20px; - font-size: 1.1rem; + margin-bottom: 15px; + font-size: 16px; line-height: 1.7; } .options { display: grid; grid-template-columns: 1fr 1fr; - gap: 15px; + gap: 12px; + margin-bottom: 15px; } @media (max-width: 768px) { @@ -129,117 +131,37 @@ } .option { - background-color: #f8f9fa; + background-color: white; border: 1px solid #ddd; - border-radius: 8px; - padding: 15px; + border-radius: 6px; + padding: 12px 15px; cursor: pointer; - transition: all 0.3s ease; + transition: all 0.2s ease; + display: flex; + align-items: center; } .option:hover { - background-color: #e3f2fd; - border-color: #90caf9; + border-color: #2980b9; + background-color: #f0f7ff; } .option input { margin-right: 10px; } - .btn-section { - text-align: center; - margin-top: 40px; - } - - .submit-btn { - background-color: #27ae60; - color: white; - border: none; - padding: 12px 30px; - border-radius: 8px; - font-size: 1rem; + .option label { cursor: pointer; - transition: background-color 0.3s ease; + flex: 1; } - .submit-btn:hover { - background-color: #219653; - } - - .result-section { - background-color: white; - border-radius: 12px; - padding: 30px; - box-shadow: 0 4px 20px rgba(0,0,0,0.08); - margin-top: 30px; - display: none; - } - - .result-header { - text-align: center; - margin-bottom: 20px; - color: #1a5276; - } - - .result-stats { - display: flex; - justify-content: space-around; - margin-bottom: 30px; - flex-wrap: wrap; - } - - .stat-item { - text-align: center; - padding: 15px; - } - - .stat-value { - font-size: 2rem; - font-weight: bold; - color: #2c3e50; - } - - /* 添加学伴答疑按钮隐藏样式 */ - .ask-xueban-btn { - display: none; - margin-top: 15px; - padding: 8px 16px; - background-color: #3498db; - color: white; - border: none; - border-radius: 4px; - cursor: pointer; - } - - .ask-xueban-btn.show { - display: inline-block; - } - .stat-label { - color: #7f8c8d; - font-size: 0.9rem; - } - - .explanation { + .question-explanation { margin-top: 15px; padding: 15px; - background-color: #f8f9fa; - border-left: 4px solid #3498db; - border-radius: 4px; - display: none; - } - - .explanation.show { - display: block; - } - - .correct { background-color: #e8f5e9; - border-color: #81c784; - } - - .incorrect { - background-color: #ffebee; - border-color: #e57373; + border-left: 4px solid #4caf50; + border-radius: 4px; + display: none; } .navigation-section { @@ -251,29 +173,62 @@ display: none; } - .next-btn { - background-color: #3498db; - color: white; - border: none; - padding: 10px 25px; - border-radius: 8px; - font-size: 0.9rem; - cursor: pointer; - transition: background-color 0.3s ease; - margin-top: 15px; + .submit-section { + text-align: center; + margin-top: 40px; } - .next-btn:hover { + #submit-btn { background-color: #2980b9; + color: white; + border: none; + padding: 12px 30px; + border-radius: 6px; + cursor: pointer; + font-size: 16px; + transition: all 0.2s ease; } - /* 在现有样式中添加 */ - .ask-xueban-btn.hidden { - display: none; - } - .explanation.show + .ask-xueban-btn { - margin-top: 15px; - } - + + #submit-btn:hover { + background-color: #1e6fa5; + transform: translateY(-2px); + } + + #result { + margin-top: 30px; + padding: 20px; + border-radius: 8px; + display: none; + } + + .result-header { + font-size: 22px; + font-weight: bold; + margin-bottom: 15px; + color: #2c3e50; + } + + .score { + font-size: 18px; + margin-bottom: 20px; + color: #333; + } + + .correct-answers { + background-color: #e8f5e9; + color: #2e7d32; + padding: 10px 15px; + border-radius: 6px; + margin-bottom: 10px; + } + + .incorrect-answers { + background-color: #ffebee; + color: #c62828; + padding: 10px 15px; + border-radius: 6px; + } +
@@ -285,57 +240,702 @@
-
- -
- -
- -
- -
-
-

测验结果

+
+ +
+
+
中等难度 - 问题 1
+
20分
+
+
+ 下列关于万有引力定律的说法中,正确的是: +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ 正确答案:B
+ 解析:万有引力定律适用于宇宙中任何两个有质量的物体之间的相互作用,不仅限于天体,故A错误;根据万有引力公式F=G(m₁m₂)/r²,两个物体之间的万有引力大小与它们距离的平方成反比,故B正确;万有引力的方向总是沿着两个物体的连线方向,故C错误;万有引力常量G是卡文迪许通过扭秤实验测量得出的,故D错误。 +
-
-
-
0
-
总分
+ +
+
+
中等难度 - 问题 2
+
20分
-
-
0
-
正确题数
+
+ 地球表面的重力加速度为g,若地球的质量不变,但半径变为原来的一半,则地球表面的重力加速度变为:
-
-
0
-
错误题数
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ 正确答案:D
+ 解析:根据重力加速度公式g=GM/R²,其中G为万有引力常量,M为地球质量,R为地球半径。当地球质量M不变,半径R变为原来的一半时,新的重力加速度g'=GM/(R/2)²=4GM/R²=4g,故答案为D。 +
+
+ +
+
+
中等难度 - 问题 3
+
20分
+
+
+ 人造地球卫星绕地球做匀速圆周运动,若轨道半径增大到原来的2倍,则卫星的线速度大小变为原来的: +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ 正确答案:B
+ 解析:根据万有引力提供向心力的公式GMm/r²=mv²/r,可得卫星线速度v=√(GM/r)。当轨道半径r增大到原来的2倍时,新的线速度v'=√(GM/(2r))=v/√2,故答案为B。 +
+
+ +
+
+
中等难度 - 问题 4
+
20分
+
+
+ 两个质量分别为m和M的物体相距为r,它们之间的万有引力大小为F。若将它们的距离变为2r,质量分别变为2m和3M,则它们之间的万有引力大小变为: +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ 正确答案:A
+ 解析:根据万有引力公式F=G(mM)/r²,变化后的万有引力F'=G(2m·3M)/(2r)²=6GMm/4r²=3GMm/2r²=3F/2,故答案为A。 +
+
+ +
+
+
中等难度 - 问题 5
+
20分
+
+
+ 关于开普勒行星运动定律,下列说法正确的是: +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ 正确答案:C
+ 解析:开普勒第一定律指出所有行星绕太阳运动的轨道都是椭圆,太阳处在椭圆的一个焦点上,故A错误;根据开普勒第二定律,行星与太阳的连线在相等时间内扫过相等的面积,因此行星在近日点的速率大于在远日点的速率,故B错误;开普勒第三定律表明所有行星的轨道半长轴的三次方与公转周期的二次方的比值都相等,故C正确;开普勒定律不仅适用于行星绕太阳的运动,也适用于卫星绕行星的运动,只是比值不同,故D错误。 +
+
+ + + + + + + + + + + + + + + + + + + + + +
- - - + - - -
-
- - - -
- - - - -00:00 \ No newline at end of file + \ No newline at end of file diff --git a/dsLightRag/static/YunXiao/physics_quiz.js b/dsLightRag/static/YunXiao/physics_quiz.js deleted file mode 100644 index 38dc6715..00000000 --- a/dsLightRag/static/YunXiao/physics_quiz.js +++ /dev/null @@ -1,325 +0,0 @@ -// 物理测验系统完整实现 -const physicsQuestions = { - easy: [ - { - question: "下列哪个是矢量?", - options: ["质量", "温度", "速度", "时间"], - correctAnswer: "C", - explanation: "矢量具有大小和方向,速度是矢量;质量、温度和时间是标量,只有大小没有方向。" - }, - { - question: "牛顿第一定律又称为?", - options: ["惯性定律", "加速度定律", "作用与反作用定律", "能量守恒定律"], - correctAnswer: "A", - explanation: "牛顿第一定律指出物体在不受外力作用时保持静止或匀速直线运动状态,也称为惯性定律。" - }, - { - question: "力的单位是?", - options: ["焦耳", "瓦特", "牛顿", "帕斯卡"], - correctAnswer: "C", - explanation: "力的单位是牛顿(N),以物理学家艾萨克·牛顿的名字命名。" - }, - { - question: "下列哪种现象是由于惯性引起的?", - options: ["苹果落地", "汽车刹车时乘客前倾", "磁铁吸引铁钉", "气球升空"], - correctAnswer: "B", - explanation: "汽车刹车时,乘客由于惯性保持原来的运动状态继续向前运动,所以会前倾。" - }, - { - question: "物体的加速度与什么成正比?", - options: ["质量", "速度", "作用力", "位移"], - correctAnswer: "C", - explanation: "根据牛顿第二定律,物体的加速度与作用在它上面的合外力成正比,与物体的质量成反比。" - } - ], - medium: [ - { - question: "关于万有引力定律,下列说法正确的是?", - options: ["万有引力只存在于天体之间", "万有引力与物体质量成正比,与距离成反比", "万有引力的发现者是牛顿", "地球对苹果的引力大于苹果对地球的引力"], - correctAnswer: "C", - explanation: "万有引力存在于任何有质量的物体之间,A错误;万有引力与距离的平方成反比,B错误;牛顿发现了万有引力定律,C正确;物体间的引力是相互的,大小相等,D错误。" - }, - { - question: "自由落体运动的加速度大小约为?", - options: ["5m/s²", "9.8m/s²", "15m/s²", "20m/s²"], - correctAnswer: "B", - explanation: "在地球表面附近,自由落体运动的加速度大小约为9.8m/s²,方向竖直向下。" - }, - { - question: "平抛运动可以分解为哪两个方向的运动?", - options: ["水平方向匀速直线运动和竖直方向自由落体运动", "水平方向匀加速直线运动和竖直方向匀速直线运动", "水平方向匀速圆周运动和竖直方向自由落体运动", "水平方向匀减速直线运动和竖直方向匀加速直线运动"], - correctAnswer: "A", - explanation: "平抛运动可以分解为水平方向的匀速直线运动和竖直方向的自由落体运动,这两个方向的运动具有独立性。" - }, - { - question: "质量为2kg的物体受到4N的力作用,其加速度为?", - options: ["0.5m/s²", "2m/s²", "4m/s²", "8m/s²"], - correctAnswer: "B", - explanation: "根据牛顿第二定律F=ma,加速度a=F/m=4N/2kg=2m/s²。" - }, - { - question: "一物体做匀加速直线运动,初速度为2m/s,加速度为1m/s²,则3秒后的速度为?", - options: ["3m/s", "4m/s", "5m/s", "6m/s"], - correctAnswer: "C", - explanation: "根据匀加速直线运动速度公式v=v0+at,v=2m/s+1m/s²×3s=5m/s。" - } - ], - hard: [ - { - question: "相对论的创立者是哪位物理学家?", - options: ["牛顿", "爱因斯坦", "麦克斯韦", "玻尔"], - correctAnswer: "B", - explanation: "相对论是由阿尔伯特·爱因斯坦创立的,分为狭义相对论和广义相对论。" - }, - { - question: "根据动量守恒定律,下列哪种情况动量不守恒?", - options: ["光滑水平面上两球碰撞", "粗糙水平面上两球碰撞", "匀速行驶的车厢内人与物体相对运动", "太空中两宇航员相互推离"], - correctAnswer: "B", - explanation: "动量守恒的条件是系统不受外力或所受合外力为零。粗糙水平面上的摩擦力属于外力,因此动量不守恒。" - }, - { - question: "一物体在光滑斜面上从静止开始下滑,斜面倾角为30°,则其加速度大小为?(g=9.8m/s²)", - options: ["4.9m/s²", "9.8m/s²", "8.5m/s²", "5.7m/s²"], - correctAnswer: "A", - explanation: "沿斜面方向的加速度a=gsinθ=9.8m/s²×sin30°=4.9m/s²。" - }, - { - question: "简谐运动的回复力与位移的关系是?", - options: ["成正比且同向", "成正比且反向", "成反比且同向", "成反比且反向"], - correctAnswer: "B", - explanation: "简谐运动的回复力F=-kx,其中k为劲度系数,负号表示回复力方向与位移方向相反,大小成正比。" - }, - { - question: "两颗质量分别为m1和m2的星球,相距r,它们之间的万有引力大小为?", - options: ["Gm1m2/r", "Gm1m2/r²", "G(m1+m2)/r²", "Gm1m2²/r²"], - correctAnswer: "B", - explanation: "根据万有引力定律,两物体间的引力F=Gm1m2/r²,其中G为引力常量。" - } - ] -}; - -// 全局变量 -let currentDifficulty = 'medium'; -let score = 0; -let totalQuestions = 5; // 当前只显示5道题 <-- 这里是问题所在 -let userAnswers = {}; -let mediaRecorder; -let audioChunks = []; -let audioBlob; -let isRecording = false; -let recordingStartTime; -let recordingTimer; - -// DOM元素 <-- 删除此行及以下全局DOM变量声明 -const questionContainer = document.getElementById('question-container'); -const scoreElement = document.getElementById('score'); -const submitButton = document.getElementById('submit-btn'); -const difficultySelect = document.getElementById('difficulty-select'); -const xuebanBtn = document.getElementById('xueban-btn'); -const recordButton = document.getElementById('record-btn'); -const audioPlayer = document.getElementById('audio-player'); -const uploadButton = document.getElementById('upload-btn'); -const progressBar = document.getElementById('progress-bar'); -const recordingTime = document.getElementById('recording-time'); -const resultContainer = document.getElementById('result-container'); - -// 页面加载完成后初始化 -function init() { - // 添加DOM元素获取逻辑 - const questionContainer = document.getElementById('question-container'); - const scoreElement = document.getElementById('score'); - const submitButton = document.getElementById('submit-btn'); - const difficultySelect = document.getElementById('difficulty-select'); - const xuebanBtn = document.getElementById('xueban-btn'); - const recordButton = document.getElementById('record-btn'); - const audioPlayer = document.getElementById('audio-player'); - const uploadButton = document.getElementById('upload-btn'); - const progressBar = document.getElementById('progress-bar'); - const recordingTime = document.getElementById('recording-time'); - const resultContainer = document.getElementById('result-container'); - - // 检查关键DOM元素是否存在 - const requiredElements = [ - 'question-container', 'score', 'submit-btn', - 'difficulty-select', 'xueban-btn', 'result-container' - ]; - - const missingElements = requiredElements.filter(id => !document.getElementById(id)); - if (missingElements.length > 0) { - console.error('缺少必要的DOM元素:', missingElements); - alert('页面加载失败,请检查HTML结构'); - return; - } - - // 正常初始化 - renderQuestions(); - submitButton.addEventListener('click', checkAnswers); - difficultySelect.addEventListener('change', changeDifficulty); - recordButton.addEventListener('click', toggleRecording); - uploadButton.addEventListener('click', uploadAudio); - - // 默认隐藏学伴答疑按钮 - xuebanBtn.classList.add('hidden'); -} - -// 确保DOM加载完成后执行初始化 -window.addEventListener('DOMContentLoaded', init); - -// 获取难度名称 -function getDifficultyName(difficulty) { - const names = { easy: '简单难度', medium: '中等难度', hard: '困难难度' }; - return names[difficulty] || '中等难度'; -} - -// 渲染题目 -function renderQuestions() { - questionContainer.innerHTML = ''; - const questions = physicsQuestions[currentDifficulty]; - - // 只显示前2道题 - for (let i = 0; i < totalQuestions; i++) { - const q = questions[i]; - const questionElement = document.createElement('div'); - questionElement.className = `question ${currentDifficulty}`; - questionElement.innerHTML = ` -

${getDifficultyName(currentDifficulty)} - 问题 ${i+1}

-

${q.question}

-
- ${q.options.map((option, index) => ` - - `).join('')} -
-
- `; - questionContainer.appendChild(questionElement); - } -} - -// 切换难度 -function changeDifficulty() { - currentDifficulty = difficultySelect.value; - score = 0; - userAnswers = {}; - resultContainer.innerHTML = ''; - renderQuestions(); - scoreElement.textContent = `得分: ${score}`; - xuebanBtn.classList.add('hidden'); -} - -// 检查答案 -function checkAnswers() { - score = 0; - const questions = physicsQuestions[currentDifficulty]; - resultContainer.innerHTML = ''; - - for (let i = 0; i < totalQuestions; i++) { - const q = questions[i]; - const selectedOption = document.querySelector(`input[name="question-${currentDifficulty}-${i}"]:checked`); - - if (selectedOption) { - userAnswers[i] = selectedOption.value; - const explanationElement = document.getElementById(`explanation-${currentDifficulty}-${i}`); - - if (selectedOption.value === q.correctAnswer) { - score++; - explanationElement.className = 'explanation correct'; - explanationElement.innerHTML = `

正确!

${q.explanation}

`; - } else { - explanationElement.className = 'explanation incorrect'; - explanationElement.innerHTML = `

错误

正确答案: ${q.correctAnswer}. ${q.explanation}

`; - } - } - } - - scoreElement.textContent = `得分: ${score}/${totalQuestions}`; - resultContainer.innerHTML += `
总分: ${score}/${totalQuestions}
`; - - // 显示学伴答疑按钮 - xuebanBtn.classList.remove('hidden'); -} - -// 切换录音状态 -async function toggleRecording() { - if (!isRecording) { - // 开始录音 - try { - const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); - mediaRecorder = new MediaRecorder(stream); - audioChunks = []; - - mediaRecorder.ondataavailable = (e) => { - audioChunks.push(e.data); - }; - - mediaRecorder.onstop = () => { - audioBlob = new Blob(audioChunks, { type: 'audio/wav' }); - const audioUrl = URL.createObjectURL(audioBlob); - audioPlayer.src = audioUrl; - audioPlayer.style.display = 'block'; - }; - - mediaRecorder.start(); - isRecording = true; - recordButton.textContent = '停止录音'; - recordButton.classList.add('recording'); - progressBar.style.display = 'block'; - recordingTime.style.display = 'block'; - - // 开始计时 - recordingStartTime = Date.now(); - updateRecordingTime(); - } catch (error) { - console.error('录音初始化失败:', error); - alert('无法访问麦克风。请确保已授予麦克风权限。'); - } - } else { - // 停止录音 - mediaRecorder.stop(); - isRecording = false; - recordButton.textContent = '开始录音'; - recordButton.classList.remove('recording'); - clearTimeout(recordingTimer); - - // 停止所有音轨 - mediaRecorder.stream.getTracks().forEach(track => track.stop()); - } -} - -// 更新录音时间 -function updateRecordingTime() { - if (!isRecording) return; - - const elapsedTime = Date.now() - recordingStartTime; - const seconds = Math.floor((elapsedTime / 1000) % 60); - const minutes = Math.floor(elapsedTime / 60000); - - recordingTime.textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`; - progressBar.value = elapsedTime / 30000; // 30秒进度条 - - if (elapsedTime < 30000) { // 限制最长录音30秒 - recordingTimer = setTimeout(updateRecordingTime, 1000); - } else { - toggleRecording(); // 自动停止 - } -} - -// 上传音频 -function uploadAudio() { - if (!audioBlob) { - alert('请先录制音频'); - return; - } - - const formData = new FormData(); - formData.append('audio', audioBlob, 'recording.wav'); - - // 这里是模拟上传,实际项目中替换为真实API - console.log('上传音频数据:', formData); - alert('音频上传成功! (模拟)'); -} - -// 添加DOM加载完成监听 -document.addEventListener('DOMContentLoaded', init);