Best practice to build a survey

  • lucvs6078-1297508593075097600

    Lucvs

    4 months ago

    Hey guys,

    If you were to build a survey in toddle, with a lot of questions, conditional logic, and answers being saved in local/session storage which approach would you use and why?

    A) One page, with each question in separate divs, hide the div of every question whenever user goes to next question

    B) A lot of pages, separate page for each question, when a question is answered user gets redirected to next page
  • needtheanswers-1297522126407864361

    needtheanswers

    4 months ago

    I would use A) because I think that using 1 page for 1 question would get a little bit messy + you would have to run a request on each page (that is if you are using a db). Also I would definitely use components for that and repeat the component on 1 page based on the list of questions.
  • Tod-1297522128257548354

    Tod

    4 months ago

    Great energy @needtheanswers! Your continuous contribution to the toddle Community just made you advance to Community Level 9!
  • lucasg-1297526523263193138

    Lucas G

    4 months ago

    I built a typeform clone a while back and my approach was to have question and answer components which changed with an array of questions
  • Each answer was saved to the array so user could navigate back and forth and update answers if needed
  • lucasg-1297527157165391904

    Lucas G

    4 months ago

    Something similar could be done and you can save the array after every answer, both locally or to your db
  • lucasg-1297527548028391425

    Lucas G

    4 months ago

    It was all on a single page and no components were repeated. It was all tracked and updated through the array
  • Worked pretty well and didn’t end up with a mess of divs/repeats
  • lucvs6078-1297531537054765156

    Lucvs

    4 months ago

    So you ended up having a component for each question / step in the survey?
  • lucasg-1297533561863405589

    Lucas G

    4 months ago

    No. A question and an answer component
  • The components were updated based on the index (question) in the array
  • lucvs6078-1297533697679167601

    Lucvs

    4 months ago

    Ahh I understand
  • lucasg-1297533775273656384

    Lucas G

    4 months ago

    In my case, it was multiple choice questions
  • Each with different values
  • By values I mean like a 'score' type of thing
  • lucvs6078-1297534214815875092

    Lucvs

    4 months ago

    It sounds like a pretty good approach actually
  • But, if there's conditional logic / calculations in some of the steps, it sounds like I'd have to break up the components
  • Or in essence, one array for each string of questions till page of calculation or whatever it may be
  • lucasg-1297538520298164264

    Lucas G

    4 months ago

    It depends
  • lucasg-1297538829317705772

    Lucas G

    4 months ago

    The logic could be built into the array in some way or you could build the logic that if question 7 has answer 3 then go into this new array, etc
  • The components would stay the same
  • The formulas could dictate what shows
  • lucvs6078-1297541566256381994

    Lucvs

    4 months ago

    Yeah I see, it probably is a pretty flexible approach
  • I guess I could also use style variables to change the styles within each component based on what is shown in a given array right?
  • lucasg-1297553508358164543

    Lucas G

    4 months ago

    Yup, a lot of flexibility with that approach
  • And toddle makes it easy to build all the logic
  • lucasg-1297554012450721864

    Lucas G

    4 months ago

    You could also use classes
  • That only show on certain conditions
  • Might be easier
  • lucvs6078-1297666106236076094

    Lucvs

    4 months ago

    Thanks for your help, will try and see how I can set this up for my project

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.