Code Monkey home page Code Monkey logo

tandemcodingchallenge's Introduction

Tandemonium

Tandemonium is a quiz app that allows users to take random quizzes, see their scores, and compare them to other user's top scores. Tandemonium also allows users to chat live while taking their quizzes.

Live site: https://tandemonium.herokuapp.com

Technologies

  • Frontend: React, Webpack
  • Backend: Ruby on Rails, Action Cable/WebSockets
  • Database: Postgres
  • Hosting: Heroku

Envirornment/engines:

  • ruby 2.5.1
  • node 10.3.0
  • npm 6.4.1

How To Run Locally

  • Clone this respository
  • npm install and bundle install
  • Start up Postgres
  • rails db:setup
  • Start rails server (rails s)
  • Navigate to http://localhost:3000

Quiz

The quiz is managed though several React components. State is used to keep track of the currently selected answers, and then some helper function calculate the number of correct answers upon submission.

Live Chat

Action Cable was used to implement WebSockets with the Rails backend. An example of a subscription to the chat room is shown below:

App.cable.subscriptions.create(
    {channel: "ChatChannel", },
    {
        received: data => {
            this.setState({
                messages: [...this.state.messages, [data.message, data.username, data.color]],
            })
        },
        speak: function(data) {
            return this.perform("speak", data)
        }
    }
)

And on the backend

def subscribed
    # stream_from "some_channel"
    stream_for "chat_room"
  end

  def speak(data)
    broadcastMessage = {message: data['body'], username: data['username'], color: data['color']}
    ChatChannel.broadcast_to("chat_room", broadcastMessage)
  end

Testing and Future Goals

I setup the project for Unit Testing with Jest / Enzyme. I did not get to write any tests yet, but that will be a future endevor.

tandemcodingchallenge's People

Contributors

ccoombsesmail avatar

Watchers

James Cloos avatar  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.