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.

198 lines
6.5 KiB

<!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, #add8e6, #ffb6c1);
color: #333;
transition: background-color 0.5s ease;
}
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"],
input[type="password"] {
padding: 10px;
margin: 10px;
border: 1px solid #ccc;
border-radius: 5px;
width: 200px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
input[type="hidden"] {
display: none;
}
p {
font-size: 18px;
margin: 10px;
border: 1px solid #00796b;
border-radius: 10px;
padding: 10px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
#loginForm, #mainContent {
display: flex;
flex-direction: column;
align-items: center;
border: 1px solid #00796b;
border-radius: 10px;
padding: 20px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
background-color: white; /* 背景色 */
}
#mainContent {
display: none; /* 默认隐藏主要内容 */
}
</style>
<script>
$(document).ready(function() {
$('#loginSubmit').click(function() {
const username = $('#username').val();
const password = $('#password').val();
$.ajax({
url: '/login',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ username: username, password: password }),
success: function(response) {
alert("登录成功!");
$('#loginForm').fadeOut(300, function() {
$('#mainContent').fadeIn(300); // 使用 fadeIn() 进行动画效果
});
},
error: function(xhr) {
alert("登录失败: " + xhr.responseJSON.message);
}
});
});
});
let specialMode = false;
function toggleSpecialMode() {
specialMode = !specialMode; // 切换特殊模式状态
const message = specialMode ? "开启特殊模式!!!!" : "关闭特殊模式";
alert(message);
$('#toggleSpecialMode').text(specialMode ? "关闭特殊模式" : "开启特殊模式");
}
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>
<div id="loginForm">
<h2>登录</h2>
<input type="text" id="username" placeholder="用户名" required>
<input type="password" id="password" placeholder="密码" required>
<button id="loginSubmit">提交</button>
</div>
<div id="mainContent">
<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>
</div>
</body>
</html>