Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locking #19

Open
koxu1996 opened this issue Feb 20, 2018 · 4 comments
Open

Locking #19

koxu1996 opened this issue Feb 20, 2018 · 4 comments
Assignees

Comments

@koxu1996
Copy link

I am looking for a way to lock achievement. Is is possible?

@gabs-simon
Copy link
Contributor

Locking, as in making the achievement unable to be completed but allowing everyone that already has it to keep it?

@gabs-simon
Copy link
Contributor

Still not an existing feature. I'll set this as a feature request and work on it!

@koxu1996
Copy link
Author

I meant opposite of unlocking. For example if user unlocked achievement for completing all exercises in category and there is new one added, then I want to revoke his achievement.

@gabs-simon
Copy link
Contributor

Currently the API does not expose a way to lock an achievement again. But I have a suggestion on how you should proceed in your use case.

The function that checks if an achievement is unlocked do the following checks:

  1. Is there a date for when this achievement was unlocked for this user? If yes, return true.
  2. Has this user already reached the required progress points to unlock the achievement? If yes, return true.
  3. Return false.

In your use case, you are adding a new exercise and want the users to reach this new progress point in order to unlock the achievement. Assuming that you're tracking the progress numerically (i.e. you have X exercises and set the achievement to be unlocked with X progress points) his is how I suggest you do it:

  1. Increment the amount of points required to unlock the achievement on the Achievement class (this change will automatically be synchronized to the database);
  2. Create a database migration that sets unlock_date = NULL for all records on achievement_progress that matches the database ID for the achievement.

If that's not clear, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants