Creating a basic note

casper.thalen's Avatar

casper.thalen

18 Jul, 2020 07:57 PM

I'm not an experienced programmer. So I'm running into some very basic problems.
I'm aiming to duplicate the q&a combinations of cloze cards in seperate basic notes.

Right now I have some loop that succesfully loops over all the cards associated with the notes that correspond to the selected cards in the Browser.

def testFunction(self):
    nids = self.selectedNotes()

    for nid in nids:
        cids = mw.col.db.list("select id from cards where nid=?", nid)
        for cid in cids:
            card = mw.col.getCard(cid)
            m = mw.col.models.byName("Basis")
            mw.col.models.setCurrent(m)
            basic = mw.col.newNote(m)
            mw.col.addNote(basic)
            #showInfo(card.answer())
    mw.reset()

Browser.testFunction = testFunction
addHook('browser.setupMenus', onBrowserSetupMenus)

However, the created cards keep being clozes. While I have verified that the line
    m = mw.col.models.byName("Basis")
correctly selects the basic note type.

I'm not able to find it in the addon writing guide, I'm very confused by the anki source code (however I've found multiple answers there already, I know how to read the front and back values of the cloze cards!) and I'm stuck on this for at least 5 hours now. Anybody care to point me in the right direction?

  1. 1 Posted by Guillem Palau-S... on 18 Jul, 2020 09:25 PM

    Guillem Palau-Salvà (contributor user)'s Avatar

    Here is the add-on guide: https://addon-docs.ankiweb.net/#/

    Please use the new forum: https://forums.ankiweb.net/.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac