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.

136 lines
4.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FZU软工学生点名系统</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background: linear-gradient(to bottom, #e0f7fa, #ffffff);
color: #333;
}
h1, h2 {
color: #00796b;
}
button {
background-color: #00796b;
color: white;
border: none;
padding: 10px 20px;
margin: 10px;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s;
}
button:hover {
background-color: #004d40;
}
input[type="file"],
input[type="text"] {
padding: 10px;
margin: 10px;
border: 1px solid #ccc;
border-radius: 5px;
width: 200px;
}
input[type="hidden"] {
display: none;
}
p {
font-size: 18px;
margin: 10px;
}
</style>
<script>
function uploadStudents() {
const fileInput = $('#fileInput')[0];
const formData = new FormData();
formData.append('file', fileInput.files[0]);
$.ajax({
url: '/upload_students',
type: 'POST',
processData: false,
contentType: false,
data: formData,
success: function(response) {
alert(response.message);
},
error: function(xhr) {
alert("请求失败: " + xhr.responseJSON.message);
}
});
}
function callStudent() {
$.ajax({
url: '/call_student',
type: 'POST',
success: function(response) {
$('#studentInfo').text(`被点到的学生: ${response.name} (学号: ${response.student_id})`);
$('#studentIndex').val(response.index);
},
error: function(xhr) {
alert("请求失败: " + xhr.responseJSON.message);
}
});
}
function updatePoints() {
const answer = $('#answer').val();
const studentIndex = $('#studentIndex').val();
$.ajax({
url: '/update_points',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ index: studentIndex, answer: answer }),
success: function(response) {
alert(response.message);
$('#points').text(`当前积分: ${response.points}`);
},
error: function(xhr) {
alert("请求失败: " + xhr.responseJSON.message);
}
});
}
</script>
</head>
<body>
<h1>学生管理系统</h1>
<h2>上传学生名单</h2>
<input type="file" id="fileInput" accept=".xlsx,.xls">
<button onclick="uploadStudents()">上传</button>
<h2>随机点名</h2>
<button onclick="callStudent()">点名</button>
<p id="studentInfo"></p>
<input type="hidden" id="studentIndex">
<h2>回答问题1+1=</h2>
<input type="text" id="answer" placeholder="输入你的答案">
<button onclick="updatePoints()">提交答案</button>
<p id="points">当前积分: 0</p>
<h2>特殊模式</h2>
<button id="toggleSpecialMode" onclick="toggleSpecialMode()">开启特殊模式</button>
</body>
</html>