|
|
@ -65,8 +65,43 @@
|
|
|
|
<button onclick="window.location.href='dianming.html'">课堂点名</button>
|
|
|
|
<button onclick="window.location.href='dianming.html'">课堂点名</button>
|
|
|
|
<button onclick="window.location.href='select.html'">随机提问</button>
|
|
|
|
<button onclick="window.location.href='select.html'">随机提问</button>
|
|
|
|
<button onclick="window.location.href='score_display.html'">积分显示</button>
|
|
|
|
<button onclick="window.location.href='score_display.html'">积分显示</button>
|
|
|
|
|
|
|
|
<button onclick="document.getElementById('fileInput').click()">导入学生名单</button>
|
|
|
|
|
|
|
|
<input type="file" id="fileInput" accept=".xlsx" style="display:none;" onchange="importStudents(event)">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
async function importStudents() {
|
|
|
|
|
|
|
|
const fileInput = document.getElementById('fileInput');
|
|
|
|
|
|
|
|
const file = fileInput.files[0]; // 获取选中的文件
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!file) {
|
|
|
|
|
|
|
|
alert('请选择一个文件');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
|
|
|
formData.append('file', file); // 将文件添加到FormData中,键名为'file'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const response = await fetch('/api/upload', { // 假设后端API的路径为/api/upload
|
|
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
|
|
body: formData
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
|
|
|
const result = await response.json();
|
|
|
|
|
|
|
|
console.log('上传成功:', result);
|
|
|
|
|
|
|
|
alert('学生名单导入成功!');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
console.error('上传失败:', response.statusText);
|
|
|
|
|
|
|
|
alert('导入失败,请重试。');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('请求错误:', error);
|
|
|
|
|
|
|
|
alert('发生错误,请检查控制台了解详细信息。');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
</html>
|
|
|
|