Merge branch 'main' of http://10.10.14.176:3000/huanghai/dsProject
This commit is contained in:
@@ -502,3 +502,10 @@ select {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* 在physics_quiz.css中添加多选题提示样式 */
|
||||
.multiple-choice {
|
||||
color: #2196f3;
|
||||
font-size: 0.9em;
|
||||
font-weight: normal;
|
||||
}
|
@@ -102,7 +102,7 @@
|
||||
</div>
|
||||
|
||||
<div>
|
||||
有权限问题的话,请点击<a href="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/11%E3%80%81%E5%AD%A6%E4%BC%B4Chrome%E5%BD%95%E9%9F%B3%E9%85%8D%E7%BD%AE%E4%BF%AE%E6%94%B9.pdf">这里</a>
|
||||
<a href="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/11%E3%80%81%E5%AD%A6%E4%BC%B4Chrome%E5%BD%95%E9%9F%B3%E9%85%8D%E7%BD%AE%E4%BF%AE%E6%94%B9.pdf">有权限问题?</a>
|
||||
</div>
|
||||
|
||||
<!-- 引入看板娘相关脚本 -->
|
||||
|
@@ -314,6 +314,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
}
|
||||
|
||||
// 提交当前难度的答案
|
||||
// 修改提交按钮的事件处理逻辑
|
||||
submitBtn.addEventListener('click', function() {
|
||||
const currentAnswers = correctAnswers[quizState.currentDifficulty];
|
||||
const totalQuestions = Object.keys(currentAnswers).length;
|
||||
@@ -322,37 +323,63 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
let incorrect = 0;
|
||||
|
||||
// 检查所有问题的答案
|
||||
for (const [questionName, correctAnswer] of Object.entries(currentAnswers)) {
|
||||
const selectedOption = document.querySelector(`input[name="${questionName}"]:checked`);
|
||||
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 (selectedOption) {
|
||||
const userAnswer = selectedOption.value;
|
||||
if (selectedOptions.length > 0) {
|
||||
// 标记用户选择的选项
|
||||
let allCorrect = true;
|
||||
|
||||
// 标记正确或错误
|
||||
if (userAnswer === correctAnswer) {
|
||||
// 标记用户选择的每个选项
|
||||
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++;
|
||||
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';
|
||||
|
||||
// 显示所有正确答案
|
||||
document.querySelectorAll(`input[name="${questionName}"]`).forEach(checkbox => {
|
||||
if (correctOptions.includes(checkbox.value)) {
|
||||
checkbox.closest('.option').style.backgroundColor = '#e3f2fd';
|
||||
checkbox.closest('.option').style.borderColor = '#2196f3';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,15 +514,20 @@ function renderQuestions() {
|
||||
question.options.forEach(option => {
|
||||
optionsHTML += `
|
||||
<div class="option">
|
||||
<input type="radio" id="${option.id}" name="${question.id}" value="${option.label}">
|
||||
<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}分)</h3>
|
||||
<h3>第${question.number}题 (${question.points}分)${isMultipleChoice ? ' <span class="multiple-choice">(多选题)</span>' : ''}</h3>
|
||||
</div>
|
||||
<div class="question-content">
|
||||
<p>${question.text}</p>
|
||||
|
Reference in New Issue
Block a user