feat: add exam score management
This commit is contained in:
@@ -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;
|
||||
|
||||
49
apps/server/src/entities/exam.entity.ts
Normal file
49
apps/server/src/entities/exam.entity.ts
Normal 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;
|
||||
}
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user