How to display personal quiz results using conditional logic - Data hooks?

Question:
Can I use Data Hooks to save manipulated Wix Form data into another collection at the same time as the form is submitted.

Using Wix Studio / CMS / Forms

What are you trying to achieve:
I want to build a quiz and display a personalised results summary.
The results displayed are conditional on the answers given in the quiz but it is not a simple correct / incorrect format.

For example:
People will answer a few multi-choice questions about their drinking habits.
Based on a few criteria eg. Above X times per week, above X units per week.
I can write conditional criteria for each one.
They will be flagged as High or Low.

I want to display all the things they’re “high” for on a results page

What have you already tried:
I’ve seen that data hooks are a way to intercept data before submission to manipulate it before it’s saved, but even if I put conditional logic in there and save the results in a new field.
eg. Alcohol level: “High” or “Low”
Its’ not helpful BECAUSE Wix Forms collections are admin read only - so I cant’ display their results on a page, because it wont let them read it, and you can’t change the permissions.

Additional information:
I will probably make it Members only, so the results can be displayed on a members page, and display only data they ~“own” and they can refer back to it.

But also willing to look at ways to do it that dont need that.

You can do that without data hooks
That data hook will only be useful if you want to save the results for later

Furthermore, in such a case where you do add it to the CMS - Since it’s going to be a single record for a single record, just adding fields to the same collection would be far less complex


Simplest: Write the logic that takes the answer data and provides the result, then print it out on the page after submission

1 Like

Ok so as I understand it
I can just write the conditional logic on the page to show the relevant elements and display the “results” immediately

However, I want people to have a saved version to reference back to, and I want an easy way to analyse the data (ie. Just look at what the most popular Highs are etc)

From my understanding there are 2 ways to do this:

Create a custom members page
Conditional logic on a custom members page
Recall the data that they own from the form collection
Display results based on the conditional logic
(similarly i could do this manipulation on a dashboard page to analyse the data)

or

save a simplified version of the results in a new collection ie. a list of High / lows.
That would require the use of data hooks?
Do the data hooks assign an “owner” to this data that would align with the member submitting the answers? or is this something that needs to be explicitly coded in.

(I’ve literally never used data hooks, I’ve only ever done simple coding to show elements on a page)

Seems you have a pretty good grasp of it, yes

I’d use the beforeInsert data hook, all it does is allows you to modify (or cancel) the contents of an entry before its submission

That changing a record’s ownership doesn’t make sense, (it may be possible to do that if one would want but that is beside the point, it doesn’t happen automatically so you needn’t worry)

The hooks are quite simple really

1 Like