This is a Quiz App built with Next.js and Prisma. It allows users to take quizzes and calculates their scores based on their answers.
- Fetch all quizzes with questions and answers
- Submit quiz answers and calculate scores
-
Clone the repository:
git clone https://github.com/micrometre/nexjs-quiz.git cd nexjs-quiz -
Install dependencies:
npm install
-
Set up the database:
npx prisma migrate dev --name init
-
Start the development server:
npm run dev
Fetch all quizzes with their questions and answers.
[
{
"id": 1,
"title": "Sample Quiz",
"questions": [
{
"id": 1,
"text": "Sample Question?",
"answers": [
{ "id": 1, "text": "Answer 1", "isCorrect": false },
{ "id": 2, "text": "Answer 2", "isCorrect": true }
]
}
]
}
]Submit quiz answers and calculate the score
{
"quizId": 1,
"answers": {
"1": 2
}
}{
"score": 1,
"total": 1
}This project is licensed under the MIT License.