Giter VIP home page Giter VIP logo

bored-panda-quizz's Introduction

Bored Panda Task

Create a simple quiz form consisting of three pages: an intro page, quiz page, and ending page. The quiz should provide results based on the user's responses.

Intro Page:

  • Provide a brief overview of the quiz, the total number of questions, and a "Start Quiz" button.

Quiz Page:

  • Present one question at a time from a predefined set of questions.
  • Each question should come with a list of multiple answers.
  • Users must select a single answer for each question.
  • Establish a scoring system on the user's answers.

Ending Page:

  • Display one of several pre-determined results corresponding to the user's score.

Tech Stack:

  • Feel free to use your preferred tech stack.

Examples of Quizzes:


Project link

https://bored-panda-quizz-1d9df4349b72.herokuapp.com/

Explanation

When building this system I’ve decided to use a monolithic approach, mainly because of these reasons:

  1. With a monolithic approach, it’s easier to implement server-side rendering.

    SSR allows to have faster initial page load, better SEO, improved caching, and has reduced Time to Interactive (TTI) - all crucial to BoredPanda webpage;

  2. It’s the simplest approach when building MVPs / POC;

  3. It’s perfectly suited for such a task, given the provided context.

For the tech stack, I’ve decided to use the latest versions of PHP, MySQL, and Laravel for the backend, Vue2, Intertia.js, and Tailwind CSS for the frontend.

The application has two routes:

  • / returns all quizzes
  • /quizzess/{slug} returns a quizz if found, 404 page otherwise

Results are cached for 24 hours.

All calculations (determining score, picking an outcome) are implemented on the client side.

Database Schema

db_schema.png

Testing

I’ve written unit tests for Quizz model, QuizzTransformerFactoryTest and PickCorrectAnswerTransformerTest.

I’ve also written integration tests for ImageRepository class.

I’ve decided to not write more tests, because they would look pretty much the same as the ones mentioned.

In a real world application, I would write tests for all of the Services/ and Repositories/.

For the frontend, I’ve decided to do manual testing.

Tasks to do after POC

  • implement quizz pagination for / route
  • write missing unit / integration tests
  • write E2E tests for the frontend
  • serve content (images/webpages) using CDN (Cloudflare)

Reflection

During the task, I had to decide if I should build a monolith or split the codebase into API and Single page application with server side rendering. I’ve found a Javascript library called Intertia.js which allows to rapidly build monolithic codebases with Laravel for backend and Vue for frontend. I believe it was a perfect choice for such application.

When working on database schema, I’ve tried to make Quizz entity flexible. There currently can be quizzes of two types: OUTCOME or PICK_CORRECT.

When quizz has a type of OUTCOME, each answer will vote towards that outcome. At the end of the quizz, the system calculates outcome with the most votes and choses it as the determined outcome.

When quizz has a type of PICK_CORRECT, each question will have a corresponding correct answer. Each correct answer increments score by 1. At the end of the quizz, the total score is shown.

I’ve hosted the webapp on Heroku for demo purposes only. In a real world application, I would probably use AWS.


Installation

Make sure Docker is running in the background, then run:

make start

which will start the containers, run the migrations, seed the database and compile the frontend assets.

To stop the dev environment, run:

make stop

Running tests

make run-tests

bored-panda-quizz's People

Contributors

simonasposka avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.