NiloCK / vue-skuilder

3 stars 0 forks source link

Examine CrowdAnki plugin #9

Open NiloCK opened 6 years ago

NiloCK commented 6 years ago

Download, install, and play with CrowdAnki anki plugin in order to get a sense for parsing / importing anki decks (including card-review history),

NiloCK commented 6 years ago

Good news: decks are output as a JSON file, with arrays of Card Templates (note_models) and of Notes.

Bad news: scheduling information on cards is not available.

Template

{
"__type__": "NoteModel", 
"crowdanki_uuid": "383671d6-79af-11e8-94bb-40f02f569107", 
"css": ".card {\n font-family: arial;\n font-size: 40px;\n text-align: center;\n color: black;\n background-color: white;\n}\n", 
"flds": [
    {
        "font": "Arial", 
        "media": [], 
        "name": "Front", 
        "ord": 0, 
        "rtl": false, 
        "size": 20, 
        "sticky": false
    }, 
    {
        "font": "Arial", 
        "media": [], 
        "name": "Back", 
        "ord": 1, 
        "rtl": false, 
        "size": 20, 
        "sticky": false
    }
], 
"latexPost": "\\end{document}", 
"latexPre": "\\documentclass[12pt]{article}\n\\special{papersize=3in,5in}\n\\usepackage[utf8]{inputenc}\n\\usepackage{amssymb,amsmath}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0in}\n\\begin{document}\n", 
"name": "SiteWord-cef25", 
"req": [
    [
        0, 
        "all", 
        [
            0
        ]
    ]
], 
"sortf": 0, 
"tags": [], 
"tmpls": [
    {
        "afmt": "{{FrontSide}}\n\n<hr id=answer>\n\n{{Back}}\n\n", 
        "bafmt": "", 
        "bqfmt": "", 
        "did": null, 
        "name": "Card 1", 
        "ord": 0, 
        "qfmt": "{{Front}}\n\n<br>\n<br>\n\n<div id=\"pips\"></div>\n\n<script>\nvar div = document.getElementById(\"pips\");\nsetTimeout(function(){\n  //div.innerHTML = div.innerHTML + \"*\";\n}, 3000);\n</script>"
    }
], 
"type": 0, 
"vers": []
}

Note

{
    "__type__": "Note", 
    "data": "", 
    "fields": [
        "the", 
        "[sound:ankidroid_audiorec-2010477767.3gp]"
    ], 
    "flags": 0, 
    "guid": "PpaY6", 
    "note_model_uuid": "38364ac0-79af-11e8-b58c-40f02f569107", 
    "tags": [
        "marked"
    ]
}

Todo:

Stvad commented 5 years ago

Err, not sure what the context of this (just randomly stumbled on it). But feel free to drop me a note or something if you're still looking into this 🙂.

The scheduling info is excluded on purpose as the original design was to enable collaboration, and the scheduling does not really fit that use-case.

NiloCK commented 5 years ago

@Stvad Thanks for reaching out!

Context: this project hopes to be a platform for mass collaborative creation of "interactive tutoring systems", where "interactive tutoring system" is a superset of traditional SRS systems. I'm a long time Anki user myself, and I'd like to be capable of importing Anki decks, enabling users to easily migrate their Anki usage. The system would want to know the scheduling info from a user's deck when it's imported, so that the user wouldn't have to "start over" their work with that deck.

It's been a while since I looked at this issue / your project. I don't have any experience with python; reading source code from Anki and your project was a bit challenging.

Questions which you might be able to answer off the top of your head and which might cause me a weekend of frustration:

Stvad commented 5 years ago

Is there a straightforward way to run your project independently (against a collection.anki2 sqlite file), instead of as an Anki plugin?

No straightforward way, I'm afraid. It relies on Anki runtime right now and does not work with the database directly. I have several thoughts on how to make it work, but they all will require some work.

How is the card scheduling handled in collection.anki2? As far as I can tell (quick glance), scheduling seems to be a function of the did, queue, and due fields of the cards table.

Not sure to be honest, I haven't really looked into that part of Anki code.

Where in your project would I look to make modifications so that this relevant data is included in your json output?

You'd need to create a model class (see classes in this module for an example: https://github.com/Stvad/CrowdAnki/tree/master/crowd_anki/representation)
Actually, I don't believe that would be trivial. The CrowdAnki does not really have a concept of the card - only a note. I think you can still find a way to store scheduling info and then associate it with the cards on import, but I'll need to dive deeper to understand how that could be done.

AlexErrant commented 10 months ago

Not sure how things were in 2019, but these days we can run sqlite in the browser. I'm using sql.js to read a user's collection.anki2 in the browser. Here's my importer, which doesn't actually import the revlog (yet), but it would be trivial to add a select * from revlog and convert its output to JSON or whatever.