Respond Survey Tech Doc - AashnaNarang/SurveyLab GitHub Wiki

APIs

  • Survey API Updates

    We need to update the create survey use case to take in the order of the questions. This order will be specified by the front end.

    • Body update for McQuestion

      {
          "mc_question" : {
              "question" : "What is your favorite pizza",
              "survey_id" : 3,
      				"order": X
          },
          "mc_options" : {
              "options" : [
              "pepperoni",
              "hawian",
              "combo",
              "idk"
          ]
          }
      }
      
    • Body update for TextQuestion

      {
          "question": "how many pears",
          "survey_id": 11,
      		"order" : X
      }
      
    • Need to be able to show an entire survey

    Need to update the show route returns an entire survey all questions included, and example from the mc_questions API, we should organize the questions here too in order to make the job easier on the front end.

    # GET /mc_questions/1 or /mc_questions/1.json
        def show
            render json: @mc_question.to_json(include: :mc_options)
        end
    
  • Text responses API

    POST /api/v1/text_responses/create

    {
        "response": "bla bla bla I like pizza",
        "text_question_id": 1,
        "survey_responder_id": X
    }
    

    Note: on the backend we need to also create a survey_responder entry when this is created

  • MC response API

    POST /api/v1/mc_responses/create

    {
        "mc_option_id": X,
        "mc_question_id": X,
        "survey_responder_id": X
    }
    

    As before we need to create the survey_responder in the backend

  • Survey Responder API

    • POST /api/v1/survey_responders/create

    • PATCH /api/v1/survey_responders/:id

      {
          "respondedAt": *insert date*
      }
      
    • Fix respondedAt value in db schema to be dateTime

Frontend

  • Create Survey Page
    • Create a modal with a the survey link to share to other people
    • Each survey will have a share link that follow this pattern: [localhost:3000/survey/:id](http://localhost:3000/survey/:id).
  • Response Page
    • Render the survey
      • Each survey will have a share link that follow this pattern: [localhost:3000/survey/:id](http://localhost:3000/survey/:id). When this page loads, call the GET http://localhost:3000/api/v1/surveys/:id route to grab all of the questions and call the POST http://localhost:3000/api/v1/survey_responders/create to grab and save a responder ID. Leave “respondedAt” as null.
        • Render the react components for each of the questions.
        • Need to create components for each response, each component should be created in a separate file so that more independent work can occur on them.
          • McQuestion Response
            • This component needs to List out the Question in text above
            • Needs to list out options in a vertical ordering with normal selection bubbles
            • This component will store the question and option ids along with the current selected option in its state, this could come as the index in the array of options which would link to the option_id. Upon submission this would hit the create mc_response route
          • Text Response
            • This component needs to display the question in text above
            • Then it needs to contain a text field for entering a response
            • Are there any react libraries that we can use to filter out bad text?
            • This component will need to contain the text question id and the response in its state, upon submission it will hit the create text_response route
    • Submit survey