Closed SrivatsaRUpadhya closed 7 months ago
@swasthikshetty10 @SrivatsaRUpadhya
Cool! But Could we have the options as string and the options are separated by commas. And we could have questions and quizzes as separate tables. Something like this:
model Quiz {
id String @id @default(cuid())
name String
description String?
Questions Question[]
QuizSubmissions QuizSubmission[]
//Add branch and other event details for which the quiz is conducted
}
model Question {
id String @id @default(cuid())
quizId String
Quiz Quiz @relation(fields: [quizId], references: [id], onDelete: Cascade)
question String
options String //Options separated by comma
image String?
answer Int @default(-1) //Index of the correct answer (0-based)
userChoice Int? @default(-1) //Index of the user answer (0-based)
userId Int?
User User? @relation(fields: [userId], references: [id], onDelete: SetNull)
@@index([quizId])
@@index([userId])
}
model QuizSubmission {
id String @id @default(cuid())
userId Int
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
quizId String
Quiz Quiz @relation(fields: [quizId], references: [id], onDelete: Cascade)
score Int
createdAt DateTime @default(now())
@@index([userId])
@@index([quizId])
}
Bro, what if we keep userchoice in separate table like Ex: Userchoice { id string PK questionId string FK userChoice Int? @default(-1) //Index of the user answer (0-based) userId Int? User User? } So that question details need not be repeated for each user.
Sounds good
//Schemas for Quizzing enum QuestionType { MCQ FITB }
model Quiz { id String @id @default(cuid()) Round Round @relation(fields: [roundEventId, roundRoundNo], references: [eventId, roundNo]) name String description String startTime DateTime endTime DateTime Question Question[] roundEventId Int roundRoundNo Int
@@index([roundEventId, roundRoundNo]) }
model Question { id String @id question String image String? points Int @default(1) negativePoints Int @default(-1) type QuestionType Quiz Quiz @relation(fields: [quizId], references: [id],onDelete: Cascade) quizId String Options Options[] FITBAns FITBAns[]
@@index([quizId]) }
model Options { id String @id @default(cuid()) Question Question @relation(fields: [questionId], references: [id],onDelete: Cascade) questionId String value String isAnswer Boolean Answers Answers[]
@@index([questionId]) }
model Answers { Options Options @relation(fields: [optionId], references: [id],onDelete: Cascade) optionId String @id User User @relation(fields: [userId], references: [id],onDelete: Cascade) userId Int
@@index([optionId]) @@index([userId]) }
model FITBAns { id String @id @default(cuid()) value String User User @relation(fields: [userId], references: [id],onDelete: Cascade) userId Int Question Question @relation(fields: [questionId], references: [id],onDelete: Cascade) questionId String
@@index([userId]) @@index([questionId]) }
check this vro...lemme know the things to correct...specially the RoundID as foreign key in Quiz model...
the schema is ready already, check the PR by Srivatsa
Make a quiz platform to conduct quizzes for first round of events
Requirements - Organizers [ ] Dashboard to create quiz [ ] View submissions and results [ ] Download results
- Participants [ ] Answer quiz [ ] View results