Closed benthayer closed 3 years ago
@kerrickstaley Have you seen this yet?
Sorry I haven't responded on this PR. One thing that I noticed is that when you generate Anki decks using genanki with these Basic cards, Anki will still create a duplicate card type, even though the card template is exactly the same as the built-in card type. This reduces the benefit of having these built-in card types because you still get extra card types in Anki. I wanted to investigate this before merging this PR but never got around to it.
I still think having this PR is valuable and will work on reviewing/merging it sometime in the next week. Thanks for your contribution to genanki!
Interesting, I'm not sure why it does that, even with the persistent id. But if you point me into the right direction, I might be able to help! I'm happy to contribute!
Unfortunately, this PR has a few issues:
Front
and Back
).methods.py
generates a deck ID for the user. I'm not sure this is the best approach; I think it's better to expose the deck ID to the user. It's definitely true that users need to care about their model IDs: we can't just generate a random one each time, otherwise Anki would create a different note type for each version of the deck you export. I'm not fully sure how deck ID is used but I'm worried similar issues could come up if we just randomly generate it each time.make_deck
is very helpful; it's not generic (only works for simple_model
) and just replaces a few lines of code; it's not super useful as a helper function I think.I created a thread on Anki's discussion forum about the duplicate note types: https://forums.ankiweb.net/t/exported-basic-cards-create-duplicate-card-types-when-imported-by-other-users/959
I think a good way forward is to create a file called stock_models.py
that defines BasicModel
, BasicAndReversedCardModel
, BasicOptionalReversedCardModel
, and BasicTypeInTheAnswerModel
, and uses the exact same fields and templates as the built-in models (you can create a test deck with one note of each type, export it, then unzip the .apkg
file and open the .anki2
file in sqlite3 and do select models from col
to see the generated model definitions). For the model names, I would call them Basic (genanki)
, Basic (and reversed card) (genanki)
, etc. so that it does not generate the annoying Basic-123ab
note type names.
If you have time and want to do the above change, feel free! Otherwise I will do it sometime in the next 2 weeks or so.
Fixed in ec5847e0faea8de225aa079d101b85f7e08652a6. Turns out 2 weeks ended up being more like 3.5 months :slightly_smiling_face:
I was building a project and wrote these methods anyways, so I figured I'd add them to your project. I'm open to changing names or taking suggestions, but this is just something simple that I think would be beneficial.
closes #2