Complicated Quiz Sorting

I’m making a fairly involved app. One section has a Jungian quiz with 72 questions that correspond to the 12 archetypes (6 questions each). I am having difficulties finding a simple way like a repeating group and pulling data from the repeating group’s multiple cells (I couldn’t figure out the extraction) or how to make the questions change by an incrementing slider.

I’m currently working on the slider, I can’t figure out how to increment it by one with a button. I have it changing the question. If I can manage to increment it then I can do all of this in a single panel and save a LOT of load times.

I don’t want to admit to how many times I have typed all 72 questions in various DB structures to get my thought process to work with Bubble’s structure. Downside of being new and adapting from too many other languages.

image

Hi there, @justin.guy… incrementing (or decrementing) a slider input’s value by 1 is pretty easy to do by using a custom state (or a value saved to the database, if you need the value to persist across page loads).

In this example, I have a custom state (number) on the page (index) called slider value, and the slider input’s Initial content is set to the custom state’s value.

Then, when an icon that should increment the slider’s value is clicked, the following workflow is run. Note that in my example, the slider input has a max value of 10.

Anyway, that’s one way to go here, and I hope this helps.

Best…
Mike

For database structure I would have a data type called Junigan Quiz. I would also have a data type called Question. On the Question data type I would have data fields, one is a related field to the data type of Junigan Quiz, other fields would be a text type for question and another field of type number for question order.

I would then have a group on a page that has the type of content set to be Junigan quiz and in that group I would put a repeating group that is of type question and make datasource a search for data type question with a constraint being the junigan quiz (related data field) is equal to the groups Junigan Quiz…this way the repeating group will have all of the questions related to the Junigan Quiz the group is set to.

You can then set up your datasource on the repeating group with some operators such as items from and items until. If you want to show 6 questions at a time have the items until value set to 6, if you want to show only 1 question at a time set the items until value set to 1. Then for the items from value, I would create a custom state that is of type number and make the items from value equal to the custom state value.

Then your slider, or button, can trigger workflows to set the custom state value to increment by the value you wish. I would for this, actually have a custom state value of type number which would also be used for the items until value (so if I change the custom state value from 6 to 1 I will show 1 question instead of 6)…when setting custom state for the items from I would increment by the custom state value of items until so that it will increment by the number of questions I wish to show at one time.

Knowing you have only 72 questions per quiz you can then set up a conditional on the workflows to make it so that once you have reached the final set of questions you can do what you would like to indicate the quiz is complete.

1 Like

Thank you both, these are both helpful.

1 Like

image

I went with the custom state. I actually ++ the state instead of the slider to the same result. Then set it to < 72 since that is my ultimate outcome. My next step is to set a decrement on the back arrow.

This worked, very well, I just hid the lower slider (and it works the same).

1 Like

This is the kind if nonsense I am resorting to, but it works:

Avoid using searches in your workflows, especially for a situation like this. As much as possible in your apps reduce the amount of times you need to touch the database.

If you want to keep track of what has been answered, instead of searching the database in your workflow, you can reference the groups current question.

1 Like

Thanks, I’ll code it correctly once I have my mind wrapped around it. I do one section at a time. Troubleshoot all the issues and make the code over and over again until it is properly optimized. You are seeing my thought process in building super early in the alpha stages.

This is how I plan on remaking the DB to make it simpler. Should give me access to everything. This is very much thanks to this discussion and spitballing with a friend of mine to get my mind back from its rabbit hole.

image

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.