Challenges
On this page, we will explore some use cases to consider during QA.
Challenge Types
There are two types of challenges: individual challenges and group challenges.
- Individual challenges can be joined by users at any time.
- Group challenges have a defined start date and end date based on the number of weeks.
Challenge Visibility Rules
A challenge will be visible on the user dashboard only if:
- The user’s language is enabled for the challenge.
- It is not disabled for the user’s store.
Challenge Weeks
When creating a new challenge, you set the number of weeks. Those weeks are generated on create. After that, add or remove weeks one at a time with StoreChallengeWeek and DeleteChallengeWeek. The week count is not rewritten on a later challenge update.
Challenge Leaderboards
Leaderboards allow users to upload their scores and compete with each other by displaying rankings.
A challenge can have several enabled leaderboards if their active_from / active_to ranges do not overlap (UniqueEnabledChallengeLeaderboard).
Leaderboard Visibility Rules
A leaderboard will be visible on the user dashboard only if:
- The challenge is a group challenge.
- The user’s language is enabled for the leaderboard.
- It is enabled.
Group Challenges
- The start date and number of weeks cannot be updated if there is an active leaderboard.
RemoveGroupChallengeMarkForExpiredGroupChallengesclearsis_group_challengeaftergroup_end_dateplusconfig('challenges.signup_expiration_time_in_days')(7 days).
Uploading a leaderboard score
Users can upload scores multiple times. The app stores one value per week. If a user uploads a score 10 times in a week, only the last uploaded score is stored.
At the start of each new week, when a user uploads a score, the app stores the new value. Users can upload scores for the current week and for previous weeks.
After the challenge is completed, users can keep uploading scores until the end of the expiration period.
To hide weeks after the challenge has completed (weeks in the expiration period), CanBeAGroupChallengeInStores exposes restricted_current_week_of_group_challenge. That accessor is min($this->current_week_of_group_challenge, $this->weeks) and throws if the challenge is not a group challenge.