Enable editing for draft exams

This commit is contained in:
2026-07-19 21:58:35 +08:00 Unverified
parent bb5d3da766
commit 1ed3b6722f
5 changed files with 79 additions and 14 deletions
+16 -5
View File
@@ -720,8 +720,8 @@ function createRepository({ client, location, read, transaction, close }) {
operations.push(auditOperation(log));
await transaction(operations);
},
async updateExam(exam, log) {
await transaction([
async updateExam(exam, log, replaceSubjects = false) {
const operations = [
operation(
`UPDATE exams SET
code = ?, name = ?, description = ?, registration_start = ?, registration_end = ?,
@@ -730,9 +730,20 @@ function createRepository({ client, location, read, transaction, close }) {
exam.code, exam.name, exam.description || '', exam.registrationStart, exam.registrationEnd,
exam.examStart, exam.examEnd, exam.admitDownloadStart, exam.admitDownloadEnd,
exam.location || '', exam.status, exam.id
),
auditOperation(log)
]);
)
];
if (replaceSubjects) {
operations.push(operation('DELETE FROM exam_subjects WHERE exam_id = ?', exam.id));
exam.subjects.forEach((subject, index) => operations.push(operation(
`INSERT INTO exam_subjects (
id, exam_id, name, subject_date, start_time, end_time, fee, position
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
subject.id, exam.id, subject.name, subject.date || String(exam.examStart).slice(0, 10),
subject.start || '', subject.end || '', Number(subject.fee || 0), Number(subject.order || index + 1)
)));
}
operations.push(auditOperation(log));
await transaction(operations);
},
async createNotice(notice, log) {
await transaction([