feat: add exam score management
Some checks failed
CI 检查 / lint (pull_request) Has been cancelled
CI 检查 / typecheck (pull_request) Has been cancelled
CI 检查 / test (pull_request) Has been cancelled

This commit is contained in:
2026-07-21 16:04:17 +08:00
parent 37ef6f9dd7
commit cbc04fea4f
27 changed files with 1061 additions and 16 deletions

View File

@@ -75,7 +75,11 @@ export class ArchiveService {
] = await Promise.all([
this.profileRepo.findOne({ where: { studentId } }),
this.enrollmentRepo.find({ where: { studentId, status: 'active' }, order: { createdAt: 'DESC' } }),
this.examScoreRepo.find({ where: { studentId, status: 'active' }, order: { examDate: 'DESC' } }),
this.examScoreRepo.find({
where: { studentId, status: 'active' },
relations: ['exam', 'exam.class'],
order: { examDate: 'DESC' },
}),
this.learningRecordRepo.find({ where: { studentId, status: 'active' }, order: { recordDate: 'DESC' } }),
this.resultRepo.findOne({ where: { studentId } }),
this.attachmentRepo.find({ where: { studentId, status: 'active' }, order: { createdAt: 'DESC' } }),
@@ -154,6 +158,7 @@ export class ArchiveService {
async updateExamScore(id: number, dto: UpdateExamScoreDto) {
const entity = await this.examScoreRepo.findOne({ where: { id } });
if (!entity) throw new NotFoundException('考试成绩不存在');
if (entity.examId) throw new BadRequestException('考试管理同步成绩请在考试管理中修改');
await this.assertEnrollmentBelongsToStudent(entity.studentId, dto.enrollmentId);
Object.assign(entity, dto);
return this.examScoreRepo.save(entity);
@@ -162,6 +167,7 @@ export class ArchiveService {
async deleteExamScore(id: number) {
const entity = await this.examScoreRepo.findOne({ where: { id } });
if (!entity) throw new NotFoundException('考试成绩不存在');
if (entity.examId) throw new BadRequestException('考试管理同步成绩不能在学生档案中归档');
if (entity.status === 'archived') throw new BadRequestException('考试成绩已归档');
await this.examScoreRepo.update(id, { status: 'archived' });
return { message: '已归档' };