Get your streak on…!

Get your streak on…! ?

While this feature wasn’t considered necessary for r4nkt’s initial release, it was always considered a must-have. Well, over the last week, initial support for streaks has been deployed to production. This makes it v…


This content originally appeared on DEV Community and was authored by Travis Elkins

Get your streak on...! ?

While this feature wasn't considered necessary for r4nkt's initial release, it was always considered a must-have. Well, over the last week, initial support for streaks has been deployed to production. This makes it very easy for you to define achievement criteria in terms of streaks.

We are very excited to have rolled this functionality out and hope that you and your users will enjoy the new possibilities that are now available.

What are streaks? ?

In terms of r4nkt achievement criteria, a streak is when a player has performed some sort of action(s) over a consecutive series of time intervals. Some examples:

  • A salesperson has closed at least one sale for 10 days in a row.
  • A student has passed the daily quiz 5 days in a row.
  • A user has walked at least 100 steps 8 hours in a row.

How does it work? ?

R4nkt's streaks are defined on the individual criteria. The criterion resource has a new property: streak. Like similar properties, it takes a string that matches the following pattern: interval:amount.

The interval can be one of the following:

  • days
  • hours

Both require an amount, which indicates the number of days or hours that the streak should be.

So, if we take some of the examples from above, we can see how easy it is to define streaks:

  • days:10: 10 days in a row.
  • days:5: 5 days in a row.
  • hours:8: 8 hours in a row.

Very simple and straightforward...! ?

Take it to the next level

For many, the basic use of streak criteria will be sufficient, but when you combine them with criteria conditions and custom data references, then you can really start to come up with very complex and interesting achievements. There are so many possibilities...! ?

Imagine that you develop an e-learning application or service and your students are allowed to take a daily quiz. You could define an achievement for students that pass the daily quiz by 95% or more for three straight days.

To do so, you would need your achievement, which we'll call The Triple, your primary criteria group, and a single criterion.

You'll also have an action, which might be called Pass Quiz and give a custom ID of pass.quiz. You will report it whenever a player passes a quiz. And, you'll want to pass the result in the activity's custom data, like so:

"custom_data": {"result": 97}

Then, your criterion will have the following properties:

  • custom_action_id: pass.quiz
  • rule: gte:1
  • streak: days:3

These properties let r4nkt know that the criterion is met when the player has passed at least one quiz each day for three (or more) consecutive days.

But what if they don't get a result of 95 or more...?

Well, that's where criteria conditions come into play. For this scenario, you'll have a criteria condition on either your criteria group or your criterion with the following definition:

"conditions": {
    "groups":  [
        {
            "conditions":  [
                "activityData:result,gte,95"
            ]
        }
    ]
}

So, by defining the activityData criteria condition, you make sure that only activities that have a custom data result of 95 or greater will be considered. This is applied and then the criterion's rule and streak are considered. That is, once all "Pass Quiz" activities for the player that did not meet the criteria conditions (result >= 95) have been filtered out, then r4nkt will look to see if at least one such activity exists per day for three (or more) consecutive days.

That's pretty great, don't you think. ?

I want to learn more

You can check out our ever-improving documentation or you can also join our Discord server and ask for help or make suggestions. ⚡️

Coming Soon

There are still more streak-related features that are in the pipeline. Obviously, we're going to expand the available time intervals and you will soon have the ability to define streaks in terms of the following time intervals:

  • weekly
  • monthly
  • yearly
  • minutely...? ?

More may be added, but we'll allow your needs to drive those efforts. ?

If you want to be notified when these new features are added, if you'd like to suggest one, or if you'd just like to be kept abreast of what we're doing, then follow us on twitter. We'll keep you posted. ?


This content originally appeared on DEV Community and was authored by Travis Elkins


Print Share Comment Cite Upload Translate Updates
APA

Travis Elkins | Sciencx (2021-04-09T12:24:58+00:00) Get your streak on…!. Retrieved from https://www.scien.cx/2021/04/09/get-your-streak-on/

MLA
" » Get your streak on…!." Travis Elkins | Sciencx - Friday April 9, 2021, https://www.scien.cx/2021/04/09/get-your-streak-on/
HARVARD
Travis Elkins | Sciencx Friday April 9, 2021 » Get your streak on…!., viewed ,<https://www.scien.cx/2021/04/09/get-your-streak-on/>
VANCOUVER
Travis Elkins | Sciencx - » Get your streak on…!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/09/get-your-streak-on/
CHICAGO
" » Get your streak on…!." Travis Elkins | Sciencx - Accessed . https://www.scien.cx/2021/04/09/get-your-streak-on/
IEEE
" » Get your streak on…!." Travis Elkins | Sciencx [Online]. Available: https://www.scien.cx/2021/04/09/get-your-streak-on/. [Accessed: ]
rf:citation
» Get your streak on…! | Travis Elkins | Sciencx | https://www.scien.cx/2021/04/09/get-your-streak-on/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.