Enable editing for draft exams
This commit is contained in:
+16
-5
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user