I’ve tried to set this up a couple times and haven’t figured out a structure that works in Bubble.
We’ve got groups that can define challenges.
The user can do activity that passes a challenge, earning the associated reward.
The challenges can reference each other.
For example, this is what I’m trying to setup at the moment
users can check in to a group, then check out, the total time is recorded
groups can create multiple challenges, each with an amount of time
a challenge can have a condition that it’s only earned after another challenge is earned
Normally I would just use iteration to check the user’s recorded activity against each challenge to see if any of them pass, but I’m not sure how to do iteration in Bubble.
I’d like to find a way to keep the conditions generic so that we can create new ones in the future, such as a geographic location, or another user’s activity.
So like, I can simplify it by restricting the case to a list of one…so I don’t have to deal with iteration.
Maybe a search for Challenge
list of users who earned this challenge does not contain current user
last activity duration time is greater than challenge time
if there’s a prerequisite challenge, it’s been earned by this user - how would I build the expression for this one?
At any rate, if I take the first result from that search then it should be a challenge that the user has passed using the last activity. So I can add the current user to the list of users who earned the Challenge. Then that Challenge won’t show up in subsequent runs of the same search, because the current user already got it.
I can’t access the fields of a thing that is the contents of the thing being searched for. But I can do the partially filtered search and put the result into a custom state. Then I can run an action on the thing in that custom state only when another constraint is true.
See, this is what I expected to be able to do in the search filters. @emmanuel was I doing something wrong?
Then another action adds the user to the qualified_user field on that challeng ONLY WHEN the challenge listed under “only_after_chall”'s own “qualified_user” field already contains the current user. That way it serves as a prerequisite.