genanki icon indicating copy to clipboard operation
genanki copied to clipboard

Set SRS mastery data

Open holocronweaver opened this issue 8 years ago • 2 comments

I am using genanki to convert data from an SRS app to Anki. I want to translate the SRS mastery data so the Anki items are due roughly when they would have been in the original SRS app.

How can I accomplish this using genanki?

Near as I can tell the fields in Card.write_to_db control this, but I am not sure what the SRS-related fields mean. I guess I will have to look at the Anki source to figure it out. AnkiDroid has some convenient documentation.

I would prefer to set SRS data at the Note level.

I plan to implement this feature, but thought I would ask for some guidance first.

holocronweaver avatar Aug 06 '17 07:08 holocronweaver

Further, I would like to customize deck settings, such as learning intervals. If we have a dict of default deck values which can be user customized, then we can simply do APKG_COL.format(values).

holocronweaver avatar Aug 09 '17 18:08 holocronweaver

Re: the SRS progress data, please add due, ivl, factor, reps, etc. as properties of Card (I'm actually not super familiar with how these affect the SRS algorithm/which fields are relevant). Make them keyword args to init that default to 0, and update Card.write_to_db to use them.

Then, when you instantiate your Note, you can iterate over your_note.cards and update the fields appropriately. You may want to add higher-level helper functions like set_suspended to make it easier to do certain things.

Re: deck settings, feel free to send a PR, I'm also not very familiar with how they work. In general to figure these things out you have to create a dummy deck in the Anki desktop app, tweak the settings you care about, then export it to an apkg, unzip it, and inspect the collection.anki2 file with sqlite. Also don't call .format on APKG_COL, use prepared statements instead (example https://github.com/kerrickstaley/genanki/commit/8ab8549e76a65337547a188028b3727a423e72d9).

kerrickstaley avatar Aug 10 '17 07:08 kerrickstaley