Forum Academy Marketplace Showcase Pricing Features

Logic for earning rewards after finishing challenges

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.

How about a “prerequisite challenges” list field in the challenge table?

Or a “prerequisites” list field which points to a prerequisite table, if you need more fields to define the prerequisite.

Yeah, recording the data isn’t the hard part, it’s figuring out whether or not a user has completed one or more challenges.

I have to search for all relevant challenges and the result could be a list.

So does that mean I have to use “schedule an API?” Is there another way to iterate over a list?

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.

edit --------------------------------------

I expected to be able to access the Challenge thing’s fields here, because the content of “only_after_chall” is a single Challenge.

The idea was for the expression to be something like “only_after_chall’s qualified_user:contains current user”

Hokay, so, maybe this works.

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?

So this is what I’ve got now. I have an action that does an incomplete search and puts the thing it finds into a custom state.

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.

Two actions seem to be required because there’s no way to reference the thing being acted upon in the Only When conditional.

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