Convert card to new model
AdrienLemaire opened this issue ยท 10 comments
I tried to modify a Basic card and convert it as a Cloze card, but the operation is ignored and the card stays a Basic card.
# Note
nid: 1479342529723
- model: Basic
+ model: Cloze
deck: Kanji in Context
tags: KanjiInContext
markdown: false
Would it be possible to support that operation? Or to add another option in the review editor n: Change Note type
?
From experience, Anki will ask for a full re-upload of the db in that case, which is slow and problematic if for example I already started my reviews from my phone (the sync would lose that data).
Instead, it would be preferable to create a new note with the desired model, then delete the original one (no syncing issue).
I tried to modify a Basic card and convert it as a Cloze card, but the operation is ignored and the card stays a Basic card.
Yes, this is currently not supported.
Would it be possible to support that operation? Or to add another option in the review editor
n: Change Note type
?
Yes, I think it should be possible.
From experience, Anki will ask for a full re-upload of the db in that case, which is slow and problematic if for example I already started my reviews from my phone (the sync would lose that data).
Instead, it would be preferable to create a new note with the desired model, then delete the original one (no syncing issue).
I think Anki is converting between models/note types and also trying to preserve the review state of the cards. Not 100% sure, but I guess that would explain why it needs a full sync.
A simple implementation in apy would be something like you suggest: n: change note type
: Changes the type of the current note and resets progress on all cards. I think it could be implemented sort of like this:
- Copy note content into python object.
- Add new note with the target model/note type, prefill the fields (perhaps only the first field?) with contents of the old note type.
- If we successfully added the new note, then delete the old note. Else abort.
This would have the benefit of not needing any full sync, as well as being simple and it should "just work". However, as mentioned, it would reset the state of the associated cards (since the old cards are deleted!).
What do you think?
I think Anki is converting between models/note types and also trying to preserve the review state of the cards
I believe you're correct.
Add new note with the target model/note type, prefill the fields (perhaps only the first field?) with contents of the old note type.
I'm not sure to understand this one.
When I check Anki's "Change note type" dialog, I see
I personally need all fields to be copied (I put most of my text in the Basic/Back or Cloze/Extra field). How about you abort the conversion if there is not a correct association of fields:
given we want to convert model A to model B
then model B must have at least as many fields as model A
and fields will be copied naively, matched by their index
it would reset the state of the associated cards (since the old cards are deleted!)
I'm totally fine with it.
I personally need all fields to be copied (I put most of my text in the Basic/Back or Cloze/Extra field). How about you abort the conversion if there is not a correct association of fields:
Yes, of course, sorry. I was not quite clear. My initial thought was to evade the problems with differing number of fields between source note type and target note type. I thought we could simple do something like this:
-
Old note
# Note ... ## Field1 text1 ## Field2 text2 ## Field3 text3
-
New note
# Note ... ## NewField1 text1 text2 text3 ## NewField2
Since we are presented with the new note in the editor (Vim), moving the text is very straightforward and easy. So this would "just work" and has zero complexity.
Of course, we could try to map fields, but that adds a lot of complexity, and I think it would not be much faster.
it would reset the state of the associated cards (since the old cards are deleted!)
I'm totally fine with it.
Great. Then I'll look into implementing this (but not right now, perhaps tomorrow or next week).
Since we are presented with the new note in the editor (Vim), moving the text is very straightforward and easy. So this would "just work" and has zero complexity.
I didn't think about that. Indeed, that sounds nice and easy to use, thanks!
Great, I'll keep the issue open until I've found time to add this, then!
I've added this now; it seems to work well at least for me. Can you test?
@lervag this is perfect
Might be worth documenting #31 (comment) a bit in the readme, because new users might be confused when seeing the old note fields in the new note.
Anyways, closing this issue, thanks for your awesome work!
Glad to hear it! Do you have a concrete suggestion for how to update the README?
Not sure how to put it simply in a few words. And maybe people won't be confused after all. Sorry, I don't know ^^'
Ok. I'll leave it as it is, then, as I don't have a clear idea how to write this better. Feel free to suggest improvements if you have any ideas!