-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathelement.prisma
More file actions
243 lines (183 loc) · 6.94 KB
/
Copy pathelement.prisma
File metadata and controls
243 lines (183 loc) · 6.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// ----- ELEMENTS -----
// #region
enum ElementStatus {
DRAFT
REVIEW
READY
}
enum ElementType {
SC
MC
KPRIM
FREE_TEXT
NUMERICAL
CONTENT
FLASHCARD
SELECTION
CASE_STUDY
QR_SCAN
}
model Element {
id Int @id @default(autoincrement())
version Int @default(1) // used to track question versions, incremented on each update
originalId String?
isArchived Boolean @default(false)
isDeleted Boolean @default(false)
name String
content String // markdown content
explanation String? // markdown content
basePoints Boolean @default(true) // flag to determine if base points should be awarded for answers to this question
pointsMultiplier Int @default(1) // currently only relevant for QUESTION types
/// [PrismaElementOptions]
options Json
status ElementStatus @default(READY)
type ElementType
// Opaque authoring/print secret for QR_SCAN elements. It is deliberately
// stored outside the participant-facing elementData JSON snapshot.
qrScanCode String? @unique
tags Tag[]
elementInstances ElementInstance[]
feedbacks ElementFeedback[]
answerCollectionItems AnswerCollectionEntry[] @relation("ElementAnswerCollectionUsedItems")
answerCollection AnswerCollection? @relation(fields: [answerCollectionId], references: [id], onDelete: SetNull, onUpdate: Cascade)
answerCollectionId Int?
directPermissions Permission[]
permissions DerivedPermission[]
accessRequests AccessRequest[]
catalogAssignments CatalogCollectionAssignment[]
activityLog ActivityLogEntry[]
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade, onUpdate: Cascade)
ownerId String @db.Uuid
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum ElementInstanceType {
LIVE_QUIZ
PRACTICE_QUIZ
MICROLEARNING
GROUP_ACTIVITY
}
model ElementInstance {
id Int @id @default(autoincrement())
type ElementInstanceType
elementType ElementType
order Int
/// [PrismaElementInstanceOptions]
options Json // contains element type specific settings (resetTimeDays for LE instances, pointsMultiplier where relevant)
/// [PrismaElementData]
elementData Json // contains a copy of relevant element data
/// [PrismaElementResults]
results Json // contains the collection of gathered results by logged in participants
/// [PrismaElementResults]
anonymousResults Json // contains the collection of gathered results by anonymous participants
isVersionOutdated Boolean @default(false) // flag to indicate if the element version has changed since the instance was created
responses QuestionResponse[]
detailResponses QuestionResponseDetail[]
liveQuizResponses LiveQuizResponse[]
feedbacks ElementFeedback[]
instanceStatistics InstanceStatistics?
instancePerformance InstancePerformance?
corrections PointCorrection[]
element Element @relation(fields: [elementId], references: [id], onDelete: Cascade, onUpdate: Cascade)
elementId Int
elementStack ElementStack? @relation(fields: [elementStackId], references: [id], onDelete: Cascade, onUpdate: Cascade)
elementStackId Int?
elementBlock ElementBlock? @relation(fields: [elementBlockId], references: [id], onDelete: Cascade, onUpdate: Cascade)
elementBlockId Int?
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade, onUpdate: Cascade)
ownerId String @db.Uuid
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([type, elementStackId, order])
@@unique([type, elementBlockId, order])
}
model InstanceStatistics {
anonymousCorrectCount Int?
anonymousPartialCorrectCount Int?
anonymousWrongCount Int?
// aggregated element feedbacks of all students (only last feedback)
upvoteCount Int?
downvoteCount Int?
// only logged in participants impact the following counts (consistent with results)
correctCount Int @default(0)
partialCorrectCount Int @default(0)
wrongCount Int @default(0)
firstCorrectCount Int?
firstPartialCorrectCount Int?
firstWrongCount Int?
lastCorrectCount Int?
lastPartialCorrectCount Int?
lastWrongCount Int?
// only logged in participants impact the following counts (consistent with results and counts above)
uniqueParticipantCount Int @default(0)
averageTimeSpent Float? @db.Real // computed based on averageTimeSpent per participant
elementInstance ElementInstance @relation(fields: [elementInstanceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
elementInstanceId Int @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum ElementStackType {
PRACTICE_QUIZ
MICROLEARNING
GROUP_ACTIVITY
}
model ElementStack {
id Int @id @default(autoincrement())
type ElementStackType
order Int
displayName String?
description String?
elements ElementInstance[]
bookmarkedBy Participation[]
practiceQuiz PracticeQuiz? @relation(fields: [practiceQuizId], references: [id], onDelete: Cascade, onUpdate: Cascade)
practiceQuizId String? @db.Uuid
microLearning MicroLearning? @relation(fields: [microLearningId], references: [id], onDelete: Cascade, onUpdate: Cascade)
microLearningId String? @db.Uuid
groupActivity GroupActivity? @relation(fields: [groupActivityId], references: [id], onDelete: Cascade, onUpdate: Cascade)
groupActivityId String? @unique @db.Uuid
course Course? @relation(fields: [courseId], references: [id])
courseId String? @db.Uuid
@@unique([type, practiceQuizId, order])
@@unique([type, microLearningId, order])
@@unique([type, groupActivityId, order])
}
enum ElementBlockStatus {
SCHEDULED
ACTIVE
EXECUTED
}
model ElementBlock {
id Int @id @default(autoincrement())
order Int
timeLimit Int?
expiresAt DateTime?
randomSelection Int?
execution Int @default(0)
status ElementBlockStatus @default(SCHEDULED)
startedAt DateTime?
closedAt DateTime?
elements ElementInstance[]
liveQuiz LiveQuiz @relation(fields: [liveQuizId], references: [id], onDelete: Cascade, onUpdate: Cascade)
liveQuizId String @db.Uuid
activeInLiveQuiz LiveQuiz[] @relation(name: "ActiveElementBlock")
escapeRoomConfig EscapeRoomConfig?
escapeRoomAttempts EscapeRoomAttempt[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([liveQuizId, order])
}
// #endregion
// ----- TAGS AND SKILLS -----
// #region
model Tag {
id Int @id @default(autoincrement())
name String
order Int @default(0)
questions Element[]
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade, onUpdate: Cascade)
ownerId String @db.Uuid
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([ownerId, name])
}
// #endregion