GithubHelp home page GithubHelp logo

tweb-interactive-polls's Introduction

TWEB project : Interactive polls with Pollak

Pollak is a web application which allows you to create and join polls. Everyone can ask and answer questions. The creator has the ability to close the room.

Preview

http://pollak.herokuapp.com (Basic functionalities for now, just to have an idea about how navigation works and what you can do)

alt text

This userflow describes how the application would work.

The frontend application is working but nothing is persisted, because the server development is in progress.

Technologies and frameworks used

The front-end project was generated with Angular CLI.

This project uses the MEAN stack:

Global architecture

  • Users are identified with a unique UUID generated in client and stored in localStorage.
  • This uuid is set in every header request to identify different users
  • A pollroom is identified by a 6 digits random number
  • When a user joins a pollroom, the server adds him to the socket room corresponding to the pollroom he joined
  • Posting requests like questions, answers, votes, etc. are send on endpoints defined in the API.
  • Then the server broadcast the incomed information to every participant of the room with socket io.

Known issues

  • On refresh, the participants are not correctly updated : for the others participant, the number of particpants increase on every page rerefresh
  • The creator of the question can answer his question. He shouldn't.
  • On server side some verifications are missing like when closing a poll for example
  • The room identifier (6 digits number) is pure random.
  • App is available only on http, not https.

Prerequisites

  1. Install Node.js (min. v 6.6.0) and MongoDB (min. v 3.2.10)
  2. Install Angular CLI: npm install angular-cli -g
  3. From the root project, install all the dependencies: npm install

Run local

Create a nodemon.json file at the root project where you define your environment variables of your system. It will be used by nodemon when the Express server starts.

{
  "env": {
    "MONGODB_URI": "mongodb://192.168.99.100:27017/pollak"
  }
}
  1. bash 1: mongod: run MongoDB server (to use Docker, see the tip bellow)
  2. bash 2: ng build -w: build the angular 2 project and listens for file changes
  3. bash 3: npm start: run Express server and serve the app
  4. Open localhost:3000 in your browser

Tip : MongoDB with Docker

Run a MongoDB server: docker run -p 27017:27017 mongo:latest

Connect to the server with MongoDB client: docker run -it mongo:latest mongo --host 192.168.99.100 (depending your Docker configuration)

Deploy on Heroku

Prerequisites : add the remote git configuration with your Heroku app.

Simply push your last commits on Heroku git server. For example :

  1. git push heroku master
  2. The app is available on http://pollak.herokuapp.com (on your Heroku application)

Heroku will automatically install npm dependencies, build the app under the dist/ folder and serve it.

Functionalities

All question are multiple choice questions.

As a user connecting on the landing page

  • Watch some statistics about the app
  • Join a pollroom by entering its identifier (like a number of 6 digits)
  • Join a previously joined pollroom by selecting it in a list
  • Create a poll by entering its name
  • Join a created poll by selecting it in a list

Creating or joining any poll makes the user immediately redirecting him to the pollroom

As a pollroom joiner

  • Watch all questions of the current pollroom
  • Watch in-live which questions are answered by other participants
  • Watch some stats of the current pollroom
    • identifier of the room
    • number of participants
    • number of questions
    • number of answers
  • Watch his current completion of the questions (a progress bar <nb_question_answered>/<nb_question>)
  • Create question (creating it implies publishing it) with associated responses
  • Answer questions once except those created by himself
  • Vote questions (like or dislike) except thos created by himself
  • (not done) Watch stats summarizing the poll when it closes
  • Leave the current pollroom

As a pollroom creator

  • Same as a pollroom joiner
  • Close the poll
  • Close a question : a closed question can't be answered anymore

How a question looks like

  • When the question was created
  • Title of question
  • multiple choices
  • progress bar of answers for each choice (hidden while poll is open)
  • number of answer for each choice in brackets
  • number of total answers
  • Like
  • Vote up
  • Vote down

When a pollroom is closed

  • Display all questions, answers and votes
  • Questions can't be answered anymore
  • Questions can't be created anymore
  • Questions can't be voted anymore
  • A pollroom can still be joined by entering its identifier
  • (not done) Display a graph showing a summary of the poll:
    • graphe one (bar or line chart):
      • axe x: the questions ordered by the most liked to the most disliked
      • axe y: the number of like
    • graphe two (bar chart):
      • axe x : the questions
      • axe y : the participation for the question
      • display the total number of participant as a line in the graph (on axe y)
    • When hovering the graph, show the question with its choices. For each choice, show the number of answer.

Endpoints (for future release)

See the swagger file in /doc

Authors

Damien Rochat & Sébastien Richoz

Skeleton realised with Angular 2 Full Stack project, project where author is Davide Violante

tweb-interactive-polls's People

Contributors

dmnrcht avatar sebastienrichoz avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

sebastienrichoz

tweb-interactive-polls's Issues

GET /stats/

Récupérer les 3 stats pour la landing page (total sur tous les poll existants)

image

GET stats when a poll is closed

  • Liste des questions de la mieux votée à la moins bien votée (ou juste la question la mieux votée)
  • Nombre de participation par question

socket.io for polls interactions

Namespace of our application

  • No custom namespace needed. Use the default /. socket.io is listening on port 3001

Rooms

Socket events with corresponding data

  • 'participantArrived' : A new participant joined the poll
    • backend
    • frontend
  • 'participantLeft': A participant left the poll (it can be the creator
    • backend
    • frontend
  • 'newQuestion', { question: Question } : Publish a question (status open)
    • backend
    • frontend
  • 'editingQuestion', { question_id: number } : edit a question (status pending)
    • backend
    • frontend
  • 'updateQuestion', { question: Question } : publish an edited question
    • backend
    • frontend
  • 'abortEditingQuestion', { question_id: number } : when canceling the editing on a question. Status will be 'open'
    • backend
    • frontend
  • 'closeQuestion', { question_id: number } : close a question (status closed). Shows stats in a progress bar for each response
    • backend
    • frontend
  • 'voteUp', { question_id: number, nb_positives_votes: number } : give a positive vote to a question
    • backend
    • frontend
  • 'voteDown', { question_id: number, nb_negatives_votes: number } : give a negative vote to a question
    • backend
    • frontend
  • 'answerChecked', { answer_id: number } : when the user checks the answer
    • backend
    • frontend
  • 'answerUnchecked', { answer_id: number } : when the user unchecks the answer
    • backend
    • frontend
  • 'closePollroom', { pollroom_id: number } : when the creator closes the room
    • backend
    • frontend

Our questions

  1. For server, A middleware to extract X-Session-ID and the pollroom_id ?
    http://socket.io/docs/server-api/#namespace#use(fn:function):namespace
    http://socket.io/docs/server-api/#socket#request:request
  2. And for client a middleware to set X-Session-ID and the pollroom_id ?

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.