2024-08-29 02:06:09 +08:00

39 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function editAssignment(assignmentId, currentDeadline) {
const newDeadline = prompt("请输入新的截止日期格式YYYY-MM-DD:", currentDeadline);
if (newDeadline) {
fetch(`/teacher/edit_assignment/${assignmentId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ deadline: newDeadline })
})
.then(response => {
if (response.ok) {
alert('截止日期已更新');
location.reload();
} else {
alert('更新失败');
}
})
.catch(error => console.error('Error:', error));
}
}
function deleteAssignment(assignmentId) {
if (confirm("您确定要删除这个作业吗?")) {
fetch(`/teacher/delete_assignment/${assignmentId}`, {
method: 'DELETE'
})
.then(response => {
if (response.ok) {
alert('作业已删除');
location.reload();
} else {
alert('删除失败');
}
})
.catch(error => console.error('Error:', error));
}
}