Skip to content

esraaMohamed/UdacityWouldYouRather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Would You Rather Project

This is the starter code for the final assessment project for Udacity's React & Redux course.

The _DATA.js file represents a fake database and methods that let you access the data. The only thing you need to edit in the _DATA.js file is the value of avatarURL. Each user should have an avatar, so you’ll need to add the path to each user’s avatar.

Using the provided starter code, you'll build a React/Redux front end for the application. We recommend using the Create React App to bootstrap the project.

TL;DR

To get started developing right away:

  • install all project dependencies with npm install or yarn install
  • start the development server with npm start or yarn start

What You're Getting

├── README.md - This file.
├── package.json # npm package manager file. It's unlikely that you'll need to modify this.
├── public
│   ├── favicon.ico # React Icon, You may change if you wish.
│   ├── manifest.json #DO NOT MODIFY
│   └── index.html # DO NOT MODIFY
└── src
    ├── components
    │   ├── App.js # This is the root of your app.
    │   ├── AddQuestion # The add question component
    │   ├── AnsweredQuestion # This component shows the answered question
    │   ├── Error # the error component 
    │   ├── Home # this is the default landing page it displays the unanswered and answered 
    │   ├── LeaderBoard # this is the Leader board component
    │   ├── Login # This is the login screen
    │   ├── Logout # this is the logout component
    │   ├── MainContainer # this is the main container 
    │   ├── Nav # This is the navigation component
    │   ├── UnansweredQuestion # This component shows the unanswered question
    │   ├── UserInfo # This is the user info component
    │   └── ViewQuestions #This is the view question poll of unanswered questions
    ├── actions
    │   ├── AuthUser # handles setting the authed user
    │   ├── Questions # handles retrieving questions, adding question and adding answer to a question
    │   ├── Shared # handles shared actions
    │   └── Users # handles retrieving the users 
    ├── middleware
    │   ├── index.js # exports default middleware by using `applyMiddleware()`
    │   └── logger.js # creates a logger middleware
    ├── reducers
    │   ├── authedUserReducer
    │   ├── index.js # contains combine reducers 
    │   ├── questionsReducer
    │   └── usersReducer
    ├── utils
    │   └── _DATA.js # A JavaScript API for the provided Udacity backend. Instructions for the methods are below.
    ├── index.css # Global styles.
    └── index.js # You should not need to modify this file. It is used for DOM rendering only.

Data

There are two types of objects stored in our database:

  • Users
  • UnansweredQuestions

Users

Users include:

Attribute Type Description
id String The user’s unique identifier
name String The user’s first name and last name
avatarURL String The path to the image file
questions Array A list of ids of the polling questions this user created
answers Object The object's keys are the ids of each question this user answered. The value of each key is the answer the user selected. It can be either 'optionOne' or 'optionTwo' since each question has two options.

UnansweredQuestions

UnansweredQuestions include:

Attribute Type Description
id String The question’s unique identifier
author String The author’s unique identifier
timestamp String The time when the question was created
optionOne Object The first voting option
optionTwo Object The second voting option

Voting Options

Voting options are attached to questions. They include:

Attribute Type Description
votes Array A list that contains the id of each user who voted for that option
text String The text of the option

Your code will talk to the database via 4 methods:

  • _getUsers()
  • _getQuestions()
  • _saveQuestion(question)
  • _saveQuestionAnswer(object)
  1. _getUsers() Method

Description: Get all of the existing users from the database.
Return Value: Object where the key is the user’s id and the value is the user object.

  1. _getQuestions() Method

Description: Get all of the existing questions from the database.
Return Value: Object where the key is the question’s id and the value is the question object.

  1. _saveQuestion(question) Method

Description: Save the polling question in the database.
Parameters: Object that includes the following properties: author, optionOneText, and optionTwoText. More details about these properties:

Attribute Type Description
author String The id of the user who posted the question
optionOneText String The text of the first option
optionTwoText String The text of the second option

Return Value: An object that has the following properties: id, author, optionOne, optionTwo, timestamp. More details about these properties:

Attribute Type Description
id String The id of the question that was posted
author String The id of the user who posted the question
optionOne Object The object has a text property and a votes property, which stores an array of the ids of the users who voted for that option
optionTwo Object The object has a text property and a votes property, which stores an array of the ids of the users who voted for that option
timestamp String The time when the question was created
  1. _saveQuestionAnswer(object) Method

Description: Save the answer to a particular polling question in the database. Parameters: Object that contains the following properties: authedUser, qid, and answer. More details about these properties:

Attribute Type Description
authedUser String The id of the user who answered the question
qid String The id of the question that was answered
answer String The option the user selected. The value should be either "optionOne" or "optionTwo"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published