The main goal of this application is to allow users to create and respond to surveys. The stack consists of Ruby on Rails and React.
A visitor to the site may view the listing of registered users, each user's profile, and the listing of published surveys without needing to register. To access other resources, such as responding to a survey or creating a new survey, registration is required. Creation and storage of hashed passwords, user authentication, and session management is handled by Rails. Access to certain resources is limited even to logged in users. For example, the current user's profile page shows unpublished surveys; such data about other users is neither rendered nor exposed by Rails.
A registered user can create a survey and add questions and response options. The text of each item can be edited, and the order of the questions and response options can be adjusted. All or part of a survey can be deleted. The app saves the survey automatically with each edit, and only the author of the survey can make these changes. If a survey has a title, at least one question, and each question has at least two response options, the survey is eligible to be published, at which point it is accessible by all users.
A registered user may submit a response to any published survey. The app prevents submitting a response until each question in the survey has been answered. All responses are accessible to all registered users. Each survey links to a listing of all responses to the survey, and each users public profile links to each of the users responses.
responsive.mov
Technologies used: Ruby on Rails, Reactjs, Postgres, HTML, Tailwind CSS.
The Rails backend for this project was adapted from Votey; the React frontend was adapted from Survey. Portions of the styling were adapted from Tail-kit.
GET /api/surveys
- Get all surveysPOST /api/surveys
- Create a new surveyGET /api/surveys/:id
- Get a specified surveyPUT /api/surveys/:id
- Edit the title of an existing survey; publish the survey.DELETE /api/surveys/:id
- Delete an existing survey; Rails associations triggers deletion of associated Question and ResponseOption database entriesGET /api/users/:user_id/surveys
- Return all surveys authored by the specified user; unpublished surveys are only returned in the case that the specified user is the current user of the appGET /api/publish_status/:id
- Get information to determine whether a specified survey meets the criteria for publishing
POST /api/surveys/:survey_id/questions
- Create a new question on a specified surveyGET /api/surveys/:survey_id/questions
- Get all questions on a specified surveyPUT /api/questions/:id
- Edit the title and/or position of an existing questionDELETE /api/questions/:id
- Delete an existing question; Rails associations triggers deletion of associated ResponseOption database entries
POST /api/questions/:question_id/response_options
- Create a new response option to a specified questionGET /api/questions/:question_id/response_options
- Get all response options to a specified questionPUT /api/response_options/:id
- Edit the title and/or position of an existing response optionDELETE /api/response_options/:id
- Delete an existing response option
POST /api/responses
- Create a new response associated to a specified respondent and surveyGET /api/responses/:id
- Get a specified responseDELETE /api/responses/:id
- Delete a specified response
POST /api/responses/:response_id/answers
- Add a new answer to a specified response; this endpoint can accept multiple answers so that creating a response to a survey requires exactly one call to this endpointGET /api/responses/:response_id/answers
- Get all answers in a specified response
POST /api/users
- Create a new userGET /api/users
- Get all users;GET /api/users/:id
- Get a specified userDELETE /api/users
- Delete a specified user
POST /api/session
- Create a new session and login a new or returning userGET /api/session
- Fetch the user associated with the current sessionDELETE /api/session
- Delete the session, setting current user tonull
and facilitating user logout