39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
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));
|
||
}
|
||
}
|