feat(classes): optimize teacher dashboard ui and implement grade management
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
classes,
|
||||
classEnrollments,
|
||||
classSchedule,
|
||||
subjects,
|
||||
exams,
|
||||
examQuestions,
|
||||
examSubmissions,
|
||||
@@ -88,8 +89,8 @@ export const questionsRelations = relations(questions, ({ one, many }) => ({
|
||||
relationName: "question_hierarchy",
|
||||
}),
|
||||
|
||||
// Many-to-Many with Knowledge Points
|
||||
questionsToKnowledgePoints: many(questionsToKnowledgePoints),
|
||||
// Many-to-Many with Knowledge Points (Direct relation mapping)
|
||||
knowledgePoints: many(questionsToKnowledgePoints),
|
||||
|
||||
// Usage in Exams
|
||||
examQuestions: many(examQuestions),
|
||||
@@ -209,6 +210,14 @@ export const examsRelations = relations(exams, ({ one, many }) => ({
|
||||
fields: [exams.creatorId],
|
||||
references: [users.id],
|
||||
}),
|
||||
subject: one(subjects, {
|
||||
fields: [exams.subjectId],
|
||||
references: [subjects.id],
|
||||
}),
|
||||
gradeEntity: one(grades, {
|
||||
fields: [exams.gradeId],
|
||||
references: [grades.id],
|
||||
}),
|
||||
questions: many(examQuestions),
|
||||
submissions: many(examSubmissions),
|
||||
}));
|
||||
|
||||
@@ -184,6 +184,17 @@ export const questionsToKnowledgePoints = mysqlTable("questions_to_knowledge_poi
|
||||
|
||||
// --- 4. Academic / Teaching Flow ---
|
||||
|
||||
export const subjects = mysqlTable("subjects", {
|
||||
id: id("id").primaryKey(),
|
||||
name: varchar("name", { length: 100 }).notNull().unique(),
|
||||
code: varchar("code", { length: 50 }).unique(),
|
||||
order: int("order").default(0),
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(),
|
||||
}, (table) => ({
|
||||
nameIdx: index("subjects_name_idx").on(table.name),
|
||||
}));
|
||||
|
||||
export const textbooks = mysqlTable("textbooks", {
|
||||
id: id("id").primaryKey(),
|
||||
title: varchar("title", { length: 255 }).notNull(),
|
||||
@@ -406,6 +417,10 @@ export const exams = mysqlTable("exams", {
|
||||
|
||||
creatorId: varchar("creator_id", { length: 128 }).notNull().references(() => users.id),
|
||||
|
||||
// Link to Subjects and Grades
|
||||
subjectId: varchar("subject_id", { length: 128 }).references(() => subjects.id),
|
||||
gradeId: varchar("grade_id", { length: 128 }).references(() => grades.id),
|
||||
|
||||
startTime: timestamp("start_time"),
|
||||
endTime: timestamp("end_time"),
|
||||
|
||||
@@ -414,7 +429,10 @@ export const exams = mysqlTable("exams", {
|
||||
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(),
|
||||
});
|
||||
}, (table) => ({
|
||||
subjectIdx: index("exams_subject_idx").on(table.subjectId),
|
||||
gradeIdx: index("exams_grade_idx").on(table.gradeId),
|
||||
}));
|
||||
|
||||
// Linking Exams to Questions (Many-to-Many often, or One-to-Many if specific to exam)
|
||||
// Usually questions are reused, so Many-to-Many
|
||||
|
||||
Reference in New Issue
Block a user