Stvad / CrowdAnki

Plugin for Anki SRS designed to facilitate cooperation on creation of notes and decks.
MIT License
533 stars 44 forks source link

Export/import a deck without configuration #31

Open axelboc opened 6 years ago

axelboc commented 6 years ago
  1. Let's say I have a deck in Anki with configuration A = 10 new cards + 100 reviews / day.
  2. I export the deck with CrowdAnki.
  3. I switch the deck to configuration B = 5 new cards + 50 reviews / day.
  4. I re-import the deck.
  5. Deck has configuration A again instead of B.

This behaviour is problematic notably when users try to update a deck to a newer version. Is there any way exporting/importing a deck could not export/import the deck configuration? I tried removing keys deck_configurations and deck_config_uiid from the exported JSON before re-importing it, but I get an error 😢 :

Traceback (most recent call last):
  File "...\addons\crowd_anki\main.py", line 23, in on_import_action
    AnkiJsonImporter.import_deck(aqt.mw.col, import_directory)
  File "...\addons\crowd_anki\anki_importer.py", line 68, in import_deck
    importer.load_from_directory(directory_path, import_media)
  File "...\addons\crowd_anki\anki_importer.py", line 44, in load_from_directory
    self.load_from_file(directory_path.joinpath(directory_path.name).with_suffix(DECK_FILE_EXTENSION))
  File "...\addons\crowd_anki\anki_importer.py", line 27, in load_from_file
    deck = Deck.from_json(deck_json)
  File "...\addons\crowd_anki\representation\deck.py", line 154, in from_json
    deck.deck_config_uuid = json_dict["deck_config_uuid"]
KeyError: 'deck_config_uuid'
Stvad commented 6 years ago

I don't think you can get there by modifying JSON. To get this functionality, this has to be made explicitly configurable

johnlawrenceaspden commented 5 years ago

It does seem really bad to fiddle with the configurations, they're not part of the deck, they're part of how the particular anki user is using the deck. Two people sharing the same deck might want different learning rates, e.g.

It would probably be best to drop this config/import export entirely, and if you import a new deck, give it the user's default configuration.

Stvad commented 5 years ago

I see that this can be problematic, but I also see the value in the "full export", so the deck would be fully self-contained.
I believe that making this configurable would be valuable

gabbard commented 5 years ago

@Stvad : I second @johnlawrenceaspden that this can be a big problem; in my case I'm trying to coordinate an evolving deck between five people, all of whom need different deck configurations because they are different ages!

I would be happy to take a stab at making this configurable when I have some free time in mid-November, if no one else has fixed it by then.

johnlawrenceaspden commented 5 years ago

Having thought about this in the intervening months, and used crowdanki in anger a great deal, I think it's [config export/import] a really bad feature. As well as being one more thing to go wrong, it means that every time you re-import the deck it destroys your configuration, and even changes the configuration of other unrelated decks which are using the same config.

When you first import a deck, then ok, bring the deck's config in (although personally I'd prefer it to just use my default config), but I think the default when importing a deck that already exists should be not to touch configurations at all.

If there's a case for exporting a deck 's config at all, then make that a once-and-for all option, rather than making the user choose every time. Exporting already involves far too much error-prone clicking!

In fact it would be much better if "CrowdAnki:Export to disk" were a separate option on the File menu, like importing is, so that it could remember where to export it to! And maybe "Export to disk with configuration" could be a separate option on that menu?

ohare93 commented 5 years ago

Completely agree, this is a major issue. I want CrowdAnki to have nothing to do with my deck configurations, to me it is all about the notes themselves.

This seems linked to Issue #23 as both are about options for the user to export/import their deck content in the way that they like.

For people managing their decks in Github the option to export/import a file with simply:


{
    "__type__": "DeckWithoutHeaders"
}

as the header would be wonderful. Instead of:

{
    "__type__": "Deck",
    "children": [],
    "crowdanki_uuid": "3cc64d84-e410-11e9-960e-d8cb8ac9abf0",
    "deck_config_uuid": "3cc64d85-e410-11e9-960e-d8cb8ac9abf0",
    "deck_configurations": [
        {
            "__type__": "DeckConfig",
            "autoplay": true,
            "crowdanki_uuid": "3cc64d85-e410-11e9-960e-d8cb8ac9abf0",
            "currentValue": 120,
            "dyn": false,
            "lapse": {
                "delays": [
                    10,
                    1440
                ],
                "leechAction": 1,
                "leechFails": 8,
                "minInt": 1,
                "mult": 0.25
            },
            "maxLife": 120,
            "maxTaken": 60,
            "name": "LL Default",
            "new": {
                "bury": false,
                "delays": [
                    1,
                    15
                ],
                "initialFactor": 2500,
                "ints": [
                    5,
                    10,
                    7
                ],
                "order": 0,
                "perDay": 10,
                "separate": true
            },
            "recover": 5,
            "replayq": true,
            "rev": {
                "bury": true,
                "ease4": 1.5,
                "fuzz": 0.05,
                "hardFactor": 1.2,
                "ivlFct": 1.5,
                "maxIvl": 36500,
                "minSpace": 1,
                "perDay": 70
            },
            "timer": 0
        }
    ],
    "desc": "",
    "dyn": 0,
    "extendNew": 10,
    "extendRev": 50,
    "name": "LL::1. Vocab"
}

I also may have time in about a month, I hope we can collaborate and get this sorted :+1:

ohare93 commented 5 years ago

Not working on this one just now, busy with other things :disappointed:

@gabbard if you're still up for trying to fix this issue this month or whenever, please make it a config setting :+1: see PR #66, and the new config window in Anki :grin: :+1:

gabbard commented 5 years ago

@ohare93 : I was just cloning this repository to work on this task this week. :-)

ohare93 commented 4 years ago

@gabbard any progress on this? 🙂

gabbard commented 4 years ago

@ohare93 : Unfortunately I didn't get the chance to work on it when I hoped I would. :-( I might have some time over Christmas break, but I can't promise anything, so anyone else who'd like to take a stab at it should feel free.

ohare93 commented 4 years ago

Going to bring this review comment in PR #72 about "Deck Headers" out to the top level here into this issue as it got rather long, and I'd be interested in the opinions of others here as it is very related to Deck Configurations/Options. See https://github.com/Stvad/CrowdAnki/pull/72/files/2e97a78e92ff825dd64e8f5d0e370a6c3740f632#r449796912 for full context (not too long)

I'm not sure if it's useful to combine all those things together. I find it confusing, I think I won't be alone. Deck options can be separated out and it makes sense to do so #31 But CrowdAnki is build on the notion of the Deck, I'd say it wont be straightforward to diverse it from the notion of a deck and I'm not sure if it makes sense to do so either

@Stvad

"Deck Headers" are just my description to make sense of all the other stuff in an export that isn't Media, Notes, or Note Models. Could you draw a more concrete separation of which are deck 'options' and which are deck 'info' (or whatever other word) in your opinion? The only concrete one I would currently agree with is the deck description, that is obviously a part of the deck but not the options. However the options themselves are merely settings on the deck, so I would say, and thus I place them all under the term "headers" (of an import).

I am happy to separate them out into different options, more user choice is always better! In the end I want users to have the following options. Whether to:

Import a deck

If Yes

If No

Import deck 'options' (the review schedule info)

If Yes, and Import Deck is also Yes

If Yes, but Import Deck is No

If No

You can see the end result for each is pretty intertwined and almost identical, that is why I bundle these two things together in my mind :shrug: Again, happy to give a separate option to the users, but they are part of the same whole to me.

When these are all optional it will be possible to import a CrowdAnki file which does not contain these entries and the Import Window will simply auto mark these options as unchecked, and make users unable to check them (as they do not exist). Old versions of CrowdAnki would not be able to import a file without these, but since the only way to currently make such a CrowdAnki file is by doing it yourself or with a separate program then that is a decision or Deck Maintainers. At least until the CrowdAnki export gets the same Import Config Window treatment :wink: but that's a bridge we'll cross later!

But CrowdAnki is build on the notion of the Deck, I'd say it wont be straightforward to diverse it from the notion of a deck and I'm not sure if it makes sense to do so either

As to that comment, I repeat my statement from earlier in this issue.

I want CrowdAnki to have nothing to do with my deck configurations, to me it is all about the notes themselves.

I posit that there is not one person in existence that uses/desires CrowdAnki to export/import Deck Config options! :laughing: especially those of other shared decks that are not their own. Deck options are very personal to the individual and change constantly with circumstance. I can understand if a users wishes to back up their own personal config options once in a while, perhaps, but I really do not think anyone actually gets use out of that :raised_eyebrow: It should stay as an option for imports, but I hope we'll get to a future where CrowdAnki files do not require it (and at that point I posit that most of them will no longer have it).

axelboc commented 4 years ago

I posit that there is not one person in existence that uses/desires CrowdAnki to export/import Deck Config options!

I totally agree. The term crowd in CrowdAnki does make it clear that the add-on is about sharing decks between many people, and nobody wants someone else's deck config. IMO, exporting/importing deck configs is a feature that would be more relevant to a backup add-on of some sort.

That being said, it doesn't cost much to keep this feature in CrowdAnki, but it should definitely be optional and disabled by default.

I couldn't find the actual comment you mention about "deck headers", in #72, but a UI of this sort could make sense to me:

  1. Top-level checkbox labelled "Import the deck".
    • Ticked by default.
    • If unticked, notes are just updated in place like the "Do Not Move Existing Cards" option.
  2. Checkbox group labelled "Import deck headers".
    • Disabled if first checkbox is unticked.
    • Contains one checkbox per deck header part (deck description, deck config)

That being said, I don't see a use case for importing the deck without its description, and if you remove this checkbox from the group, all that's left is the deck config... unless there are other deck header parts ? If not, then perhaps the checkbox group could just be a checkbox labelled "Import deck config", unticked by default.

Back to the first checkbox, if I understand correctly, not importing the deck is like ticking the "Do Not Move Existing Cards" option, except that new cards are added to the standard deck. Using the standard deck for new cards seems to make more sense, since users who move cards into other decks would want to move new cards as well, and I believe the standard deck disappears when it contains no more cards (thus, they don't have to delete the imported deck after moving the cards). Therefore, I think this could replace the Do Not Move Existing Cards option.

ccalvaro commented 3 years ago

Hello,

I have had this problem and founded this issue after "resolving" it. My problem was that all decks changed the options to the imported deck options when importing Ultimate Geography deck through CrowdAnki.

Thank God I have noticed the problem shortly after and had the opportunity to use the "on next sync, force the changes in one direction" option.

I want to share this just in case anybody has the same problem before somebody resolves this issue.

To import the deck without the options be changed automatically, I created another user only for this, imported the deck through CrowdAnki and after exported it as an apkg file. I removed that created user and after that imported it as a regular deck on my user.

Hope this helps somebody,

Greetings