Skip to content

hashims/quiz-app

Repository files navigation

Quiz Application

A RESTful quiz application built with NestJS and Fastify.

Quick Start

Prerequisites:

  • Docker
  • Docker Compose

To run the application, use either:

./start.sh

or

docker-compose up

That's it! The application will be available at http://localhost:3000

Swagger will be available at http://localhost:3000/api/docs

API Endpoints

  • POST /quiz - Create a new quiz
  • GET /quiz/:id - Get a specific quiz
  • POST /quiz/:quizId/questions/:questionId/answer - Submit an answer
  • GET /quiz/:quizId/:userId - Get quiz results

Example Request

Create a quiz:

curl -X POST http://localhost:3000/quiz \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Math Quiz",
    "description": "Basic math questions",
    "questions": [
      {
        "id": "q1",
        "text": "What is 2+2?",
        "options": ["3", "4", "5", "6"],
        "correct_option": 1
      }
    ]
  }'

Sample Data:

{
  "id": 1,
  "title": "Random Quiz",
  "questions": [
    {
      "id": 1,
      "question": "What is the capital of France?",
      "options": ["Berlin", "Madrid", "Paris", "Rome"],
      "correct_option": 3
    },
    {
      "id": 2,
      "question": "Which planet is known as the Red Planet?",
      "options": ["Earth", "Mars", "Jupiter", "Saturn"],
      "correct_option": 2
    },
    {
      "id": 3,
      "question": "Who developed the theory of relativity?",
      "options": ["Isaac Newton", "Albert Einstein", "Galileo Galilei", "Nikola Tesla"],
      "correct_option": 2
    },
    {
      "id": 4,
      "question": "What is the largest ocean on Earth?",
      "options": ["Atlantic Ocean", "Indian Ocean", "Arctic Ocean", "Pacific Ocean"],
      "correct_option": 4
    },
    {
      "id": 5,
      "question": "Which element has the chemical symbol 'O'?",
      "options": ["Oxygen", "Osmium", "Ozone", "Oxygenium"],
      "correct_option": 1
    }
  ]
}

Running Tests

# Unit tests
docker-compose exec api npm run test

# E2E tests
docker-compose exec api npm run test:e2e

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages