Giter VIP home page Giter VIP logo

quizzical's Introduction

Project: Let's Get Quizzical

๐Ÿฆ‹ Netlify Status ๐Ÿš€ Heroku โš–๏ธ License: MIT

Description

Lockdown has seen a spike in online quizzes and people have been deprived of the party experience. So with that in mind, we wanted to give people a platform to play multiplayer quizzes remotely, mordernise the typical pub quiz by having a neon party theme to bring the party feel to the user!

Let's Get Quizzical is an online quiz game built in fullstack with react and redux on the client, Node.js and Express on the server and a mongoDB database. The game uses Socket.io to allow multiple users to play together, questions and answers are fetched from OpenTrivia API, and it is deployed on Netlify and Heroku.

How to play

For each game, up to 4 players can play and the host of each game selects the type of quiz they want everyone to play (i.e the number of questions, category, and difficulty). Users are then able to join the game using a unique room name set by the host. Once users have joined the lobby, they can take it in turns to play and the winner is announced at the end of every game and all new and existing scores are then shown on the leaderboard.

Installation & usage

Clone or download the repo and navigate to the root directory of this repo.

To run the client, open the terminal:
cd react-client
npm install
npm run dev

It should automatically load on 0.0.0.0:8080

To run client test suite:
npm run tests


To start the server and use docker compose for the api and database containers, open the terminal and run:
bash _scripts/startDev.sh

  • starts api & db services
  • runs db migrations
  • seeds db for development
  • serves api on localhost:3000

To run the server test suite:
bash _scripts/startTest.sh

  • starts api & db services
  • runs db migrations
  • attaches to api container and triggers full test run
  • no ports mapped to local host

MongoDB shell
bash _scripts/mongo.sh

To teardown docker compose completely:
bash _scripts/teardown.sh

Technologies

  • HTML, CSS, JavaScript

Dependencies:

  • Server: cors, nodemon, socket.io, express, mongodb

  • Client: axios, file-loader, react, router-dom, react-redux, react-router-dom, redux, redux-devtools-extensions, redux-thunk, socket.io-client

DevDependencies:

  • Server: jest, nodemon, supertest

  • Client: babel, react-testing-library, jest

Process

  1. Start by planning out a plan!!! Use of GitHub Projects to set up a Kanban board.
  2. Create Figma design plan.
  3. Deploy to Netlify and Heroku!
  4. Set up files and folder structure for docker, react-client with redux, api, db for mongodb and test suites.
  5. Connect API and Socket server to React-Client
  6. Connect mongoDB database to API

Bugs

  • issues with routing with mongodb
  • cors error when implementing socket.io
  • fetch returns undefined data
  • answers are encoded
  • after submitting answer for final question in quiz, page will crash
  • sends wrong quiz score to post
  • socket and client integration
  • scores not showing as percentage
  • leaderboard not sorted by descending order
  • winner not displayed
  • score styling
  • network spam for POST request
  • winner crown assignment

Changelog

React-Client

  1. Set up pages and components
  2. Test suite!
  3. Use axios to set up GET request from OpenTrivia API, and POST score data to quizzical-quiz API
  4. Implement socket.io client

API

  1. Set up server with routes, models and controllers
  2. Install socket.io and integrate into client
  3. Complete GET, POST, PATCH routes
  4. Test!
  5. Create DELETE route to clear database

db

  1. Initially decided on SQL but changed to noSQL due to simplicity of data needed.
  2. Update config files and install dependencies required for mongodb.
  3. Set up connectin string with mongodb and mock connection for testing
  4. Set up mongodb atlas and connect to Heroku and code

Wins & Challenges

Wins

  • Deploying to Heroku and Netlify from one repo! And deploy early!
  • Amazing progress after Day 1 - socket connection establisted, routes working on API, react-redux set up!
  • Set up connection between api, db and client
  • Responsive!
  • Decoded answers from API
  • Successful mob programming sessions

Screenshot 2021-04-30 at 02 04 09

Challenges

  • Understanding and implementing socket.io
  • Testing with mongodb
  • Testing with react
  • Deploying mongodb
  • Passing data around - may need to refactor code
  • Setting up multiplayer
  • React redux testing

Code Snippet

Screenshot 2021-04-30 at 18 00 45

Future Features

  • Login / user accounts with authentication
  • High scores leaderboard for each difficulty
  • Score to include time taken to complete quiz
  • Sound effects
  • Full socket.io real time implementation

Slide Deck

https://www.canva.com/design/DAEcypURzgQ/hUwNi51yfXyb7-FrHAeP4Q/edit#1

Collaborators

@pearlhamilton, @gretaivan, @natbibi, @Sem-the-dev, @roselynle

quizzical's People

Contributors

gretaivan avatar natbibi avatar pearlhamilton avatar roselynle avatar sem-the-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

quizzical's Issues

LeaderBoard

  • GET leaderboard on load leaderboard page
  • OR append data from state and POST to api

Welcome page

  • username input
  • join the quiz
  • join the quiz disabled when no available players
  • create new quiz
  • alert for empty input
  • validate the input

Socket: create room

  • pass username to redux
  • pass room to redux
  • pass user type to redux
  • create action for room creation
  • server create room
    • check if room name exists
    • return error on wrong room name
  • clien socket get the result from the server

React Home Page

  • create username input
  • difficulty drop down
  • fetchApi with difficulty setting
  • dropdown menus for quiz options
  • dropdown for topics
  • fetchApi with topic params

Client side: Socket

  • connect to the socket
  • create the room
  • join room
  • broadcast joined the room
  • check if there is space in the room
  • if no space block the join button

Socket lobby

  • find the game by name
  • return all the players for the game
  • return categories
  • return the config

Lobby: start button

  • get from redux user type (user < = userReducer)
  • if host show the button
  • if player display waiting for host to start the game

Create README

  • wins and challenges
  • description
  • technologies used
  • Netlify badge
  • mit badge
  • image and/or gif

Configure the room

  • confirm user is the host
  • get all the cofig in the object
  • pass it to the serve
  • socket server to handle and save the config according to the room name
  • return the room config to everyone in the lobby on button click
  • fetch in the home page to populate redux questions
  • action to add the config to the redux as an action see #81

Redux

  • hardcoded fetch request to display questions and answers
  • onclick of answer move to next question
  • shuffle answer buttons so correct answer isn't always in the same place
  • go to final page once get to the end of array of questions
  • logic to check if answer selected is correct and if it is add to score
  • score state?
  • Make homepage link to quizpage when you click play

Error message on welcome page

In welcome page file, use the error/setError state

  • add conditional error rendering on the page: when error is not empty display it for the user under the input boxes or buttons
  • change the handleCreate alert box to setError with alert message. (apprx line 62 and 64)
  • change handleJoin alert (apprx line88) to set error too
  • check that line 78 error setError(res.message); is also rendered when existing room name is created

Add Room Config in redux

  • action to take in difficulty, questionCount, subject
  • reducer with the action type to handle the data
  • add to reducers folded index the reducer name
  • add new reducer in the store

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.