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

@@ -9,12 +9,20 @@ import {
} from 'typeorm';
import { Student } from './student.entity';
import { StudentEnrollment } from './student-enrollment.entity';
import { Exam } from './exam.entity';
@Entity('exam_scores')
export class ExamScore {
@PrimaryGeneratedColumn()
id: number;
@Column({ name: 'exam_id', type: 'integer', nullable: true })
examId: number | null;
@ManyToOne(() => Exam, (exam) => exam.scores, { nullable: true, onDelete: 'CASCADE' })
@JoinColumn({ name: 'exam_id' })
exam: Exam | null;
@Column({ name: 'student_id', type: 'integer' })
studentId: number;
@@ -39,13 +47,13 @@ export class ExamScore {
subject: string;
@Column({ type: 'decimal', precision: 5, scale: 2, nullable: true })
score: number;
score: number | null;
@Column({ name: 'class_avg', type: 'decimal', precision: 5, scale: 2, nullable: true })
classAvg: number;
classAvg: number | null;
@Column({ type: 'integer', nullable: true })
rank: number;
rank: number | null;
@Column({ name: 'exam_date', type: 'date', nullable: true })
examDate: string;

View File

@@ -0,0 +1,49 @@
import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { Class } from './class.entity';
import { ExamScore } from './exam-score.entity';
@Entity('exams')
export class Exam {
@PrimaryGeneratedColumn()
id: number;
@Column({ name: 'exam_type', length: 50 })
examType: string;
@Column({ name: 'exam_name', length: 100 })
examName: string;
@Column({ length: 50 })
subject: string;
@Column({ name: 'exam_date', type: 'date' })
examDate: string;
@Column({ name: 'class_id', type: 'integer' })
classId: number;
@ManyToOne(() => Class)
@JoinColumn({ name: 'class_id' })
class: Class;
@OneToMany(() => ExamScore, (score) => score.exam)
scores: ExamScore[];
@Column({ type: 'varchar', length: 20, default: 'active' })
status: 'active' | 'archived';
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date;
}

View File

@@ -32,6 +32,7 @@ export { Notification, NotificationType } from './notification.entity';
export { StudentProfile } from './student-profile.entity';
export { StudentEnrollment } from './student-enrollment.entity';
export { ExamScore } from './exam-score.entity';
export { Exam } from './exam.entity';
export { LearningRecord } from './learning-record.entity';
export { ResultArchive } from './result-archive.entity';
export { ArchiveAttachment } from './archive-attachment.entity';