feat(tests): общие тесты с автором, в истории только результаты ученика (для всех ролей)

Made-with: Cursor
This commit is contained in:
Константин Лебединский
2026-04-01 23:09:17 +05:00
parent d8805bd4ed
commit 35f27a6eb7
4 changed files with 79 additions and 19 deletions
+10 -3
View File
@@ -26,7 +26,9 @@ model User {
questions Question[]
chatMessages ChatMessage[]
textbooks Textbook[]
tests Test[]
testsInScope Test[] @relation("TestStudentScope")
testsAuthored Test[] @relation("TestAuthor")
testResults TestResult[]
reports Report[]
hallPhotos HallPhoto[]
}
@@ -75,8 +77,11 @@ model Textbook {
model Test {
id Int @id @default(autoincrement())
/// Контекст пары наставник–ученик (id назначенного ученика); общие тесты для обоих
studentId Int
student User @relation(fields: [studentId], references: [id], onDelete: Cascade)
student User @relation("TestStudentScope", fields: [studentId], references: [id], onDelete: Cascade)
authorId Int
author User @relation("TestAuthor", fields: [authorId], references: [id], onDelete: Cascade)
topic String
questions String
createdAt DateTime @default(now())
@@ -86,11 +91,13 @@ model Test {
model TestResult {
id Int @id @default(autoincrement())
testId Int
test Test @relation(fields: [testId], references: [id], onDelete: Cascade)
studentId Int
student User @relation(fields: [studentId], references: [id], onDelete: Cascade)
answers String
score Int
total Int
createdAt DateTime @default(now())
test Test @relation(fields: [testId], references: [id], onDelete: Cascade)
}
model Report {