codeforboston / urban-league-heat-pump-accelerator

Urban League Heat Pump Accelerator Project
MIT License
33 stars 22 forks source link

Surveyor View: On survey page, survey questions with an "other" option give user 2 inputs to specify "other" #367

Closed LWest001 closed 1 year ago

LWest001 commented 1 year ago

image

image

mikelynch commented 1 year ago

Not sure if this is based on the dummy survey we looked at or whether this is something from the UI component. At present, we have explicit separate “if other, please specify” questions. Originally, the idea was that we had questions like: What type of heating system? (Forced hot air/Radiators/Other), then a separate question with “if other, what”?

If the UI is smart enough to handle showing a separate text box for other, I think we'd be fine to remove the separate question – ultimately in the database, we store survey_answers with a text answer field – so if the recipient picks “forced hot air”, we'll store that, and if they select “Other” and then write another response, we could store that instead.

LWest001 commented 1 year ago

Not sure if this is based on the dummy survey we looked at or whether this is something from the UI component. At present, we have explicit separate “if other, please specify” questions. Originally, the idea was that we had questions like: What type of heating system? (Forced hot air/Radiators/Other), then a separate question with “if other, what”?

If the UI is smart enough to handle showing a separate text box for other, I think we'd be fine to remove the separate question – ultimately in the database, we store survey_answers with a text answer field – so if the recipient picks “forced hot air”, we'll store that, and if they select “Other” and then write another response, we could store that instead.

@mikelynch I like that idea. In that case, is this an issue that can be handled on the backend and we can leave the UI the same?

mikelynch commented 1 year ago

I think so – so basically the survey would something like:

{
  "id": 1,
  "title": "Draft Survey",
  "survey_questions": [
    …,
    {
      "id": 10,
      "display_order": 10,
      "text": "So we can report back on your potential savings, what type of heating system do you have? (Across the whole home, not just in individual rooms)",
      "response_type": "radio",
      "response_options": [
          "Forced hot air – vents",
          "Radiators – water",
          "Radiators – steam",
          "Basebaord – water",
          "Baseboard – electric",
          "Other"
      ]
    }
  ]
}

and then your JS would detect that there was an "other" option, and show the second box. In the response, the front end would submit something like (note this is nested within a survey visit, but I'm doing this off the top of my head and not looking it all up):

{
  "survey_id": 1,
  "survey_answers": [
    {
      "survey_question_id": 10,
      "answer": "Forced hot air – vents"
    }
  ]
}

or if they did Other something like:

{
  "survey_id": 1,
  "survey_answers": [
    {
      "survey_question_id": 10,
      "answer": "Jumping up and down"
    }
  ]
}

@LWest001 , does that make sense?

LWest001 commented 1 year ago

@mikelynch Yes it does.

LWest001 commented 1 year ago

@mikelynch can I assign this issue to you?

mikelynch commented 1 year ago

I didn't think this required anything on the backend, no? Happy to clean up the dummy questions to remove the “if other, please specify”, but I think the rest is frontend logic.

LWest001 commented 1 year ago

Right now the UI pulls up an "other" field when an "other" option is selected (as intended), so I think we just need to remove the "if other, please specify" from the survey questions. I may have misunderstood your previous comment!

mikelynch commented 1 year ago

As far as I know, we don't have the “real“ (i.e. final) survey questions – I just put together some dummy ones. Happy to remove those extra questions but we probably need to update them all anyway.

LWest001 commented 1 year ago

As far as I know, we don't have the “real“ (i.e. final) survey questions – I just put together some dummy ones. Happy to remove those extra questions but we probably need to update them all anyway.

Gotcha. I think we can just close the issue for now and keep it in mind when we put the final surveys together!