|
|
@ -99,8 +99,8 @@ startAttendanceButton.addEventListener('click', async () => {
|
|
|
|
const response = await fetch('http://localhost:3000/api/random-call');
|
|
|
|
const response = await fetch('http://localhost:3000/api/random-call');
|
|
|
|
const data = await response.json();
|
|
|
|
const data = await response.json();
|
|
|
|
|
|
|
|
|
|
|
|
if (data.student) {
|
|
|
|
if (data.student_id && data.student_name) {
|
|
|
|
currentStudent = data.student;
|
|
|
|
currentStudent = data;
|
|
|
|
studentNameDisplay.textContent = `当前学生: ${currentStudent.student_name}`;
|
|
|
|
studentNameDisplay.textContent = `当前学生: ${currentStudent.student_name}`;
|
|
|
|
presentButton.style.display = 'inline-block';
|
|
|
|
presentButton.style.display = 'inline-block';
|
|
|
|
absentButton.style.display = 'inline-block';
|
|
|
|
absentButton.style.display = 'inline-block';
|
|
|
@ -117,8 +117,8 @@ startAttendanceButton.addEventListener('click', async () => {
|
|
|
|
// 到场按钮点击事件
|
|
|
|
// 到场按钮点击事件
|
|
|
|
presentButton.addEventListener('click', async () => {
|
|
|
|
presentButton.addEventListener('click', async () => {
|
|
|
|
if (currentStudent) {
|
|
|
|
if (currentStudent) {
|
|
|
|
await updatePoints(currentStudent.student_id, 1); // 到场加1分
|
|
|
|
await updatePoints(currentStudent.student_id, 0.5); // 到场加0.5分
|
|
|
|
alert(`${currentStudent.student_name} 已到,加1分`);
|
|
|
|
alert(`${currentStudent.student_name} 已到,加0.5分`);
|
|
|
|
resetAttendance();
|
|
|
|
resetAttendance();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -126,7 +126,7 @@ presentButton.addEventListener('click', async () => {
|
|
|
|
// 没到按钮点击事件
|
|
|
|
// 没到按钮点击事件
|
|
|
|
absentButton.addEventListener('click', async () => {
|
|
|
|
absentButton.addEventListener('click', async () => {
|
|
|
|
if (currentStudent) {
|
|
|
|
if (currentStudent) {
|
|
|
|
await updatePoints(currentStudent.student_id, -1); // 未到减2分
|
|
|
|
await updatePoints(currentStudent.student_id, -1); // 未到减1分
|
|
|
|
alert(`${currentStudent.student_name} 未到,减1分`);
|
|
|
|
alert(`${currentStudent.student_name} 未到,减1分`);
|
|
|
|
resetAttendance();
|
|
|
|
resetAttendance();
|
|
|
|
}
|
|
|
|
}
|
|
|
|