You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
209 lines
8.2 KiB
209 lines
8.2 KiB
2 months ago
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<title>回答问题</title>
|
||
|
<style>
|
||
|
body {
|
||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||
|
background: linear-gradient(135deg, #283c86, #45a247); /* 深蓝到绿色的渐变 */
|
||
|
height: 100vh;
|
||
|
margin: 0;
|
||
|
display: flex;
|
||
|
justify-content: center;
|
||
|
align-items: center;
|
||
|
color: #ffffff;
|
||
|
}
|
||
|
|
||
|
.container {
|
||
|
text-align: center;
|
||
|
background: rgba(50, 50, 70, 0.9); /* 更深的背景色 */
|
||
|
padding: 40px;
|
||
|
border-radius: 20px;
|
||
|
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
|
||
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
||
|
backdrop-filter: blur(10px); /* 增加模糊效果 */
|
||
|
}
|
||
|
|
||
|
#question {
|
||
|
font-size: 2.5em;
|
||
|
margin-bottom: 30px;
|
||
|
text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5); /* 文字阴影 */
|
||
|
}
|
||
|
|
||
|
button {
|
||
|
padding: 15px 30px;
|
||
|
font-size: 1.2em;
|
||
|
border: none;
|
||
|
border-radius: 50px;
|
||
|
background: linear-gradient(45deg, #fc5c7d, #6a82fb); /* 渐变按钮 */
|
||
|
color: white;
|
||
|
cursor: pointer;
|
||
|
transition: transform 0.2s, background 0.3s, box-shadow 0.3s;
|
||
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
|
||
|
margin: 10px;
|
||
|
}
|
||
|
|
||
|
button:hover {
|
||
|
background: linear-gradient(45deg, #e54d84, #5a72d6); /* 悬停时加深 */
|
||
|
transform: translateY(-3px); /* 悬停时上移效果 */
|
||
|
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
|
||
|
<body>
|
||
|
|
||
|
<div class="container">
|
||
|
<div id="question">请重复问题,选择正确或错误:</div>
|
||
|
<button id="repeatCorrectButton">准确重复</button>
|
||
|
<button id="repeatWrongButton">未准确重复</button>
|
||
|
|
||
|
<div id="questionResult"></div> <!-- 显示重复问题的结果 -->
|
||
|
|
||
|
<div id="answerContainer" style="display:none;">
|
||
|
<p>现在回答问题:</p>
|
||
|
<button id="correctButton">回答正确</button>
|
||
|
<button id="partiallyCorrectButton">部分正确</button>
|
||
|
<button id="wrongButton">回答错误</button>
|
||
|
</div>
|
||
|
|
||
|
<button class="back-button" onclick="window.location.href='select.html'">返回点名页面</button>
|
||
|
<div id="result"></div>
|
||
|
<div id="studentInfo"></div> <!-- 显示学生信息 -->
|
||
|
</div>
|
||
|
|
||
|
<script>
|
||
|
async function updateScore(student_id, points) {
|
||
|
try {
|
||
|
const response = await fetch('/api/update-score', {
|
||
|
method: 'POST',
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json',
|
||
|
},
|
||
|
body: JSON.stringify({ student_id, points }),
|
||
|
});
|
||
|
|
||
|
if (!response.ok) {
|
||
|
throw new Error('网络响应不正常');
|
||
|
}
|
||
|
|
||
|
const data = await response.text(); // 使用 text() 解析纯数字响应
|
||
|
console.log('更新后的分数:', data); // data 是字符串形式的分数
|
||
|
return data; // 返回更新后的分数字符串
|
||
|
} catch (error) {
|
||
|
console.error('分数更新失败:', error);
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
const urlParams = new URLSearchParams(window.location.search);
|
||
|
const student_name = urlParams.get('student_name');
|
||
|
const student_id = urlParams.get('student_id');
|
||
|
|
||
|
const repeatCorrectButton = document.querySelector('#repeatCorrectButton');
|
||
|
const repeatWrongButton = document.querySelector('#repeatWrongButton');
|
||
|
const questionResultDisplay = document.querySelector('#questionResult');
|
||
|
const correctButton = document.querySelector('#correctButton');
|
||
|
const partiallyCorrectButton = document.querySelector('#partiallyCorrectButton');
|
||
|
const wrongButton = document.querySelector('#wrongButton');
|
||
|
const resultDisplay = document.querySelector('#result');
|
||
|
const answerContainer = document.querySelector('#answerContainer');
|
||
|
const studentInfoDisplay = document.querySelector('#studentInfo');
|
||
|
|
||
|
// 显示学生姓名和学号
|
||
|
studentInfoDisplay.textContent = `学生: ${student_name} 学号: ${student_id}`;
|
||
|
|
||
|
// 正确重复问题处理 +0.5
|
||
|
repeatCorrectButton.addEventListener('click', () => {
|
||
|
updateScore(student_id, 0.5)
|
||
|
.then(newscore => {
|
||
|
if (newscore !== null) {
|
||
|
questionResultDisplay.textContent = `重复正确!${student_id} 的当前积分: ${newscore}`; // 直接使用字符串
|
||
|
answerContainer.style.display = 'block'; // 显示回答问题部分
|
||
|
} else {
|
||
|
console.error('更新分数失败');
|
||
|
questionResultDisplay.textContent = `更新分数失败,请重试。`;
|
||
|
}
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('请求失败:', error);
|
||
|
questionResultDisplay.textContent = `更新分数失败,请重试。`;
|
||
|
});
|
||
|
});
|
||
|
|
||
|
// 未准确重复问题处理 -1
|
||
|
repeatWrongButton.addEventListener('click', () => {
|
||
|
updateScore(student_id, -1)
|
||
|
.then(newscore => {
|
||
|
if (newscore !== null) {
|
||
|
questionResultDisplay.textContent = `重复错误!${student_id} 的当前积分: ${newscore}`; // 直接使用字符串
|
||
|
answerContainer.style.display = 'block'; // 显示回答问题部分
|
||
|
} else {
|
||
|
console.error('更新分数失败');
|
||
|
questionResultDisplay.textContent = `更新分数失败,请重试。`;
|
||
|
}
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('请求失败:', error);
|
||
|
questionResultDisplay.textContent = `更新分数失败,请重试。`;
|
||
|
});
|
||
|
});
|
||
|
|
||
|
// 回答问题的处理
|
||
|
correctButton.addEventListener('click', () => {
|
||
|
updateScore(student_id, 3)
|
||
|
.then(newscore => {
|
||
|
if (newscore !== null) {
|
||
|
resultDisplay.textContent = `回答完全正确!${student_id} 的当前积分: ${newscore}`; // 直接使用字符串
|
||
|
} else {
|
||
|
console.error('更新分数失败');
|
||
|
resultDisplay.textContent = `更新分数失败,请重试。`;
|
||
|
}
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('请求失败:', error);
|
||
|
resultDisplay.textContent = `更新分数失败,请重试。`;
|
||
|
});
|
||
|
});
|
||
|
|
||
|
|
||
|
partiallyCorrectButton.addEventListener('click', () => {
|
||
|
updateScore(student_id, 1.5)
|
||
|
.then(newscore => {
|
||
|
if (newscore !== null) {
|
||
|
resultDisplay.textContent = `回答部分正确!${student_id} 的当前积分: ${newscore}`; // 直接使用字符串
|
||
|
} else {
|
||
|
console.error('更新分数失败');
|
||
|
resultDisplay.textContent = `更新分数失败,请重试。`;
|
||
|
}
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('请求失败:', error);
|
||
|
resultDisplay.textContent = `更新分数失败,请重试。`;
|
||
|
});
|
||
|
});
|
||
|
|
||
|
|
||
|
wrongButton.addEventListener('click', () => {
|
||
|
updateScore(student_id, 0.5)
|
||
|
.then(newscore => {
|
||
|
if (newscore !== null) {
|
||
|
resultDisplay.textContent = `回答基本正确!${student_id} 的当前积分: ${newscore}`; // 直接使用字符串
|
||
|
} else {
|
||
|
console.error('更新分数失败');
|
||
|
resultDisplay.textContent = `更新分数失败,请重试。`;
|
||
|
}
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('请求失败:', error);
|
||
|
resultDisplay.textContent = `更新分数失败,请重试。`;
|
||
|
});
|
||
|
});
|
||
|
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|