I’m trying to figure out if I can reproduce this
along with its scoring system
Something that’s causing me problems is that each answer for each question has its own score weight, which isn’t shown to the user.
Ideally the end result would be one new record in a “completed_survey” thing where there would be a field for the user’s answer to each question and a few more fields for the final calculated score.
But I don’t know how to dynamically address a particular field on a record from within a repeating group. That means the questions need to be hard coded in order to store their answer in the right field.
One way to solve for this is to have the user’s answer choices stored in a custom state on the UI as they fill out the RG. Then, store that data in the database at the end. You could combine the user’s answers with weights for the questions at the end, as well, and store it.
Is there a way to do that without hand-coding the logic for every option of every question?
Yeah. Put the custom state on, say, the page. Make it a list of things. When page loads, load a list of default values that’s as long as the questionnaire (e.g., 36 values each set to, say, “0”). Then anytime the user clicks a value for the 1st question, simple change the 1st value in that list to the user’s selected value.
The way to do the 1st question (through nth question) dynamically is to reference the current cell’s index.
How would you build the actual interface to gather the value? If I use a radio button I get a text value I have to manually convert into a numeric score, hand coding the conditions for each option. If I use a slider at least I get a number but I still have to manually convert the number into a score based on the lookup table.
I usually make my own radio buttons because I think it’s better UX to have the whole option look obviously clickable. And, then when someone selects that value, just run a workflow to replace the custom-state’s value for the nth item in the list. Perhaps if it’s the 1st answer choice, make it a 1, if it’s the 2nd make it a 2, etc.
And, if you put all of the questions in the database and load them through the RG, then you only need to code this for each question layout (e.g., 1x for vertical list of questions + 1x for yes/no + 3 others it looks like).
Do you have an example I could look at?
Not really. I’ve implemented these concepts but not in a single survey with multiple question types/layouts that are all dynamic like you’re suggesting.
Any success here? @sridharan.s your explanation went a bit over my head (Im about a 1.5 months in). Anyway you could dumb that down even more?
Im trying to build a questionnaire (a user takes it to scale their relationship to a personal reference) that uses the format of Strongly Agree to Strongly Disagree and calculate a numerical value from the answers (Strongly Agree is 6 and Strongly Disagree is 1) to determine the nature of the relationship.
Im also (attempting) to make conditions for the amount of answers visible. Meaning you can scale multiple people at the same time without having to take the questionnaire several times in a row just to add each person individually. So if they choose to add 1 person then 1 row of bubbles appears and so on up to 5 max like the photo above.
I then submit those results automatically to an email for the reference(s) in question to validate their identity and to “adjust” the answers to their preferences. Then I take an average of both results to give a visual reference of the intimacy of the relationship. This is just a range of images conditioned to appear based of the numerical results.
Would I have better luck with yes/no values? I cant seem to find too much on the relationship between what defines something as being a data type vs a field of that data type in relation to what Im doing specifically. This is what is tripping me up. As if Im scared to “make a thing” incorrectly according to parent/child relationship (at least that’s how I’m looking at it, but maybe that’s wrong and too confined of an analogy). Im best with analogies incase you’ve got any good ones when it comes to creating data in general.
Any advice is appreciated! Thanks!
Also I have those Strongly Agree to Disagree circles set as icons with conditions of appearing differently when hovered or clicked… Should they be something else like a button of sorts?
This thread has been super helpful. Could you explain how to, as you put it, “change the 1st value in that list to the user’s selected value.” Would it be possible for the user to return to a question to change his/her answer? Thanks!