jac241 / anki_killstreaks

A Halo and Call of Duty inspired add-on to gamify Anki and make reviewing more bearable
GNU Affero General Public License v3.0
17 stars 8 forks source link

Feature Request: Support for Different Profiles #21

Open mnhende2 opened 4 years ago

mnhende2 commented 4 years ago

@jac241 Thanks for the great add-on. My boys (and I) love it.

That said, in our family we have 5 family members that use Anki, and we have a number of different communal computers that we all do Anki on.

Right now, Anki Killstreaks doesn't support Anki's built-in multiple profiles. So, when we switch between profiles, the Anki Killstreak stats and current streak, continue into the new user/profile.

It would be great if each Anki profile could have it's on unique Anki Killstreaks profile.

If you are willing to build in this feature, we'd be glad to do some beta testing on it for you.

jac241 commented 4 years ago

As far as I can tell switching profiles through anki is already supported. It was designed with this in mind already. Switching AnkiAchievements.com profiles within the same anki profile will reupload all the medals to the other account. If you set up two different anki profiles and log in to separate AnkiAchievements.com profiles in each it should work as intended. image image

jac241 commented 4 years ago

Any word on this one?

mnhende2 commented 4 years ago

Today is a holiday in the country I'm in, and we had guests over all day.. I'll have to update Killstreaks on a two computers and then I'll get back to you. Apologies for the delay.

jac241 commented 4 years ago

No problem! Hope the holiday is/was awesome!

mnhende2 commented 4 years ago

@jac241: So, today, I have put in hours and hours trying to get this solved and it just isn't happening, but let me first describe the setting.

5 different users. 5 different workstations. All users five users have a profile on all five workstations. (All in one family).

Each person has an Killstreaks (KS) profile. The problem is that when we are in Anki and switch from one Anki profile to another (Ctrl + Shift + P) or when we close Anki and then re-open later to another user, Anki KS will usually, but not always show that a person is logged in, but the person logged in may or may not match the actual Anki profile. It seems totally random as to who is actually going to be logged in on KS.

So, if I go from User A and then ensure that I am logged into the proper KS profile, and then Ctrl + Shift + P to User B and then ensure that I am logged into the proper KS profile, and then Ctrl + Shift + P to User C and ensure that I am logged in to the proper KS profile and then on through User D and User E, then I randomly jump back to one of the users, quite regularly, KS is logged into a wrong (and seemingly random) different family member. So, I fix it, and then go to another user, and it too has seemingly randomly changed. It seems that the KS profile does not automatically read the Anki Profile and thus does not pull the correct account.

But a 2 or 3 times today, I have been able to get all users logged into the right account A --> B --> C --> D --> E and then roll back though A --> E and it all stays correct. Then I do it a third time, and all is correct. Then I close Anki, open it back up, open an Anki profile and then the KS profile seems to be randomly scrambled again. I just can't pattern it. It isn't the prior user. It doesn't always get the same account mixed up. It just seems random.

This is just within one computer, when we jump between computers, it is the same thing. So, every time, before doing reviews we check to see what KS profile is showing as logged in, and then we log out, log into the correct one, and start reviewing. But ti doesn't seem to persist or stick. Once another profile is switched to or Anki is closed and later re-opened, when going back to the user, a KS profile will be logged in, but usually the wrong one.

I wish I had a better description to help with troubleshooting. If I find a pattern, I'll let you know. If you have an specific steps you'd like to to test, please let me know.

mnhende2 commented 4 years ago

@jac241 I have a more detailed update. Unfortunately, no success, but my test might help you as you try to figure out what is happening. In this test, there are our five computers (A, B, C, D, E) and our five users (1, 2, 3, 4, 5).

On computer A, I opened User 1's Anki, and made sure it was logging into User 1's KS profile. Then I did "Empty Cards," "Check Media" and "Check Database", just to make sure everything was good. Then I did a full upload of User 1's collection to Ankiweb. Then I did a full download of User 1's collection to computer B, and found that KS was correct. Then I did a full download of User 1's collection to computer C, and found that KS was correct. Then I did the same for Computer D and E. And found KS was correct. (And I was encouraged).

Then, on computer A, I opened User 2's Anki, and made sure it was logging into User 2's KS profile. Then I did "Empty Cards," "Check Media" and "Check Database", just to make sure everything was good. Then I did a full upload of User 2's collection to Ankiweb. Then I did a full download of User 2's collection to computer B, and found that KS was correct. Then I did a full download of User 2's collection to computer C, and found that KS was correct. Then I did the same for Computer D and E. And found KS was correct. (And I was encouraged).

Then, on computer A, I opened User 3's Anki, and made sure it was logging into User 3's KS profile. Then I did "Empty Cards," "Check Media" and "Check Database", just to make sure everything was good. Then I did a full upload of User 3's collection to Ankiweb. Then I did a full download of User 3's collection to computer B, and found that KS was correct. Then I did a full download of User 3's collection to computer C, and found that KS was correct. Then I did the same for Computer D and E. And found KS was correct. (And I was encouraged).

Then, on computer A, I opened User 4's Anki, and made sure it was logging into User 4's KS profile. Then I did "Empty Cards," "Check Media" and "Check Database", just to make sure everything was good. Then I did a full upload of User 4's collection to Ankiweb. Then I did a full download of User 4's collection to computer B, and found that KS was correct. Then I did a full download of User 4's collection to computer C, and found that KS was correct. Then I did the same for Computer D and E. And found KS was correct. (And I was encouraged).

Then, on computer A, I opened User 5's Anki, and made sure it was logging into User 5's KS profile. Then I did "Empty Cards," "Check Media" and "Check Database", just to make sure everything was good. Then I did a full upload of User 5's collection to Ankiweb. Then I did a full download of User 5's collection to computer B, and found that KS was correct. Then I did a full download of User 5's collection to computer C, and found that KS was correct. Then I did the same for Computer D and E. And found KS was correct. (And I was encouraged).

Then, on Computer A, I synced back to User 1, and KS was correct. Then, on Computer B, I synced back to User 1, and KS was correct. Then, on Computer C, then D, then E. Each time KS was correct for User 1. (And I was encouraged).

Then, on Computer A, I synced back to User 2, and KS was correct. Then, on Computer B, I synced back to User 2, and KS was correct. Then, on Computer C, then D, then E. Each time KS was correct for User 2. (And I was encouraged).

Then, I did the same steps for User 3 on each computer, just like in the prior paragraph. Each time KS was correct for User 3. (And I was encouraged).

Then, for User 4 and then 5 I did the same thing as above. Each time KS was correct for User 4 and then User 5. (And I was encouraged).

I thought we might be nearing success.

Then we closed Anki on all five computers.

Then on Computer A, we opened Anki and randomly opened User 5. And KS was not correct. It was a different family member.

Then on Computer B, we opened Anki and randomly opened User 2. And KS was not correct. It was a different family member.

Then on Computer C, we opened Anki and randomly opened User 3. And KS was not correct. It was a different family member.

Then on Computer D, we opened Anki and randomly opened User 4. And KS was not correct. It was a different family member.

Then on Computer E, we opened Anki and randomly opened User 1. And KS was not correct. It was a different family member.

On each computer, Anki Killstreaks was logged into a different user than the Anki profile. None of them were the correct User profile, and each one seemed random one on each computer.

At that point in time, I was tired and discouraged, so just shut Anki down on all computers and started typing this novel. Apologies for the length, but I hope it is helpful.

jac241 commented 4 years ago

Thank you for the detailed write up. I will investigate. I need to look into what the Empty Cards, Check Media, and Check Data do. The database for Killstreaks is stored per profile in their profile folder in Anki in the anki_killstreaks.db file. This database is what stores the user token that is sent back from the ankiachievements.com server whenever you log a user in. Whenever a profile is loaded in anki, anki sends a message that says "hey a profile was just loaded", and that's when killstreaks initializes everything.

I will try to recreate your scenarios to see if I can figure out what's going on. I just wanted to give you a little background on how those work. If you want to see what each database is storing to see if it is storing the wrong user token or something, there is an app called "DB Browser for SQLite" that you can use to read the database files if interested.

What operating system and Anki version are you using?

-DB Browser for SQLite users table image

mnhende2 commented 4 years ago

@jac241: I'll install the DB viewer and see if I can discern anything from looking at that. I did just want to quickly respond back and say that we are all using various Win 10 machines (HP, Dell x2, Toshiba, Lenovo). Also, all machines are running Anki 2.1.29 (the latest stable build).

As for the "Check Media" and "Empty cards" they shouldn't have any effect at all. The first just checks to see if there are any extra or missing media files in the media folder. That is media files that are referenced on cards, but not present in the media folder, or that are present in the media folder, but not used on cards. It should have no impact. The empty cards checks to see if any note templates that have made any blank cards. Again, it shouldn't have any impact. But I ran them just to make sure my deck was at 100%. I was facing the same problems with KS before doing those checks, but was just trying anything.

For the check database, it checks to see if there are any problems in the collection database, any card with messed up properties, bad data, etc. I would assume this wouldn't have an impact also, but sometimes if a card has bad properties it can affect something like syncing or loading of stats for example. So, I ran Check Database, again to just make sure that the deck was 100%. I was facing the same problems with KS before doing that check, but was just trying anything.

Also, I know you are aware of this issue, but today, mid-way through my son's reviews, he noticed that his score dramatically changed. He had verified that he was logged in before starting, but when his score dramatically changed, he checked the profile, and it had switched to a user/email address, not connected to our family. You can see that in the attached screenshot.

mnhende2 commented 4 years ago

@jac241 So, I downloaded the program, and I am completely confused as to what is happening. I'm going to report what I'm seeing happen, but it makes no sense to me. I wish you the best in being able to use this information.

So, here are some of the things I have seen. This is not a complete list, but just shows some of the seemingly random things that are happening.

1a) I currently have Anki open, and profile open, and go to Killstreaks > Profile Settings to see who is logged in. It shows the incorrect user. But when I go to the users anki_killstreaks.db file > Browse data > Users > and then look at the UID, it shows a different user (it shows the correct user). So what is showing in the .db file is not what is showing in the Anki review window itself.

1b) Then I decided to hit Ctrl + Shift + P (change profile) and when the profile screen came up, I just re-selected the same user. Without me doing anything else, this time it loaded he right user.

2) Another thing I saw, I was logged in as User 5 on Anki and in Anki KS. I checked the .db file and and the UID also matched. All was good. Then without me doing anything in Anki, I checked the .db file after two minutes, and the UID changed. During that time I did not make any adjustments in Anki, nor on any other computer. It just seemingly changed on its own.

3) I opened Anki to User 1, the wrong KS account was logged in (which is what normally happens). It was logged into User 2. But before logging out and logging into the correct account, I wanted to see what the .db UID was. And completely to my surprise it was neither User 1, nor User 2, but instead User 4. So, then in Anki, under Killstreaks > Profile Settings > I log out of the incorrect account. Then it gives me a window to login as a new user. Before doing so, I reopen the .db file. It still shows User 4 in the .db file. So, without re-logging in, I just close Anki, with me logged out of KS on User 1. Then I re-check the .db file. It still shows my UID as User 4. Then I re-open Anki, and User 1. I check the KS profile in Anki, and now I am logged in as User 4 (which was not who I was logged into when I closed). I logout of KS again. And now login as the correct User (user 1). It shows me as successfully logged into KS. I did a few reviews to make sure that the score looked right and it did. Then I checked the Killstreaks > Profile Setting and it still showed User 1 as the correct user. I checked the .db file and it the UID was now corrected to User 1. So, then I closed Anki. I checked the .db file, and all was still good. I re-open Anki, User 1 and KS shows correct, so the does .db file.

Then I Ctrl + Shift + P and go to User 4. (Just to pick a different user). I check the KS profile and User 4 is logged in as User 1. I check the .db file and it too shows User 1 as the UID. I do nothing. I decide to just go to a different profile (User 5), however, before doing that. I open his .db file and it shows the correct User 5 in the UID. So, I go to his profile in Anki expecting to see him logged into Anki KS. When I go to Killstreaks > Profile Setting, instead I find User 1 showing as logged in. I check the UID in the .db and there is properly shows User 5 (which is different than what is showing logged in during the Anki reviews). So, I just do nothing and close Anki. I then re-open Anki, and User 4 (who I was just on), now it shows User 4 with the right account.

I am sure there is a pattern in here somewhere, and I wish you well in finding it.

On idea I have is that I sense that shifting between profiles (without closing Anki -- using Ctrl + Shift + P) is handled differently than when Anki is fully closed and re-opened to a new profile.

But that doesn't explain other random things happening (like watching the .db UID change without me doing anything in Anki).

Wishing you the best in solving this, and may somehow this problem solving help you in med school.

Best, mnhende2