From a353135af3e91ffcc5b87c7ba65e878b5f392fca Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 13 Aug 2017 19:41:26 +1000 Subject: [PATCH] add type-in-the-answer note type --- anki/stdmodels.py | 19 +++++++++++++++++++ anki/storage.py | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/anki/stdmodels.py b/anki/stdmodels.py index f1ab0a1b7..aa754631d 100644 --- a/anki/stdmodels.py +++ b/anki/stdmodels.py @@ -26,6 +26,25 @@ def addBasicModel(col): models.append((lambda: _("Basic"), addBasicModel)) +# Basic w/ typing +########################################################################## + +def addBasicTypingModel(col): + mm = col.models + m = mm.new(_("Basic (type in the answer)")) + fm = mm.newField(_("Front")) + mm.addField(m, fm) + fm = mm.newField(_("Back")) + mm.addField(m, fm) + t = mm.newTemplate(_("Card 1")) + t['qfmt'] = "{{"+_("Front")+"}}\n{{type:"+_("Back")+"}}" + t['afmt'] = "{{FrontSide}}\n\n
\n\n"+"{{"+_("Back")+"}}" + mm.addTemplate(m, t) + mm.add(m) + return m + +models.append((lambda: _("Basic (type in the answer)"), addBasicTypingModel)) + # Forward & Reverse ########################################################################## diff --git a/anki/storage.py b/anki/storage.py index fe2006846..b6ca539dc 100644 --- a/anki/storage.py +++ b/anki/storage.py @@ -11,7 +11,7 @@ from anki.db import DB from anki.collection import _Collection from anki.consts import * from anki.stdmodels import addBasicModel, addClozeModel, addForwardReverse, \ - addForwardOptionalReverse + addForwardOptionalReverse, addBasicTypingModel def Collection(path, lock=True, server=False, sync=True, log=False): "Open a new or existing collection. Path must be unicode." @@ -43,6 +43,7 @@ def Collection(path, lock=True, server=False, sync=True, log=False): elif create: # add in reverse order so basic is default addClozeModel(col) + addBasicTypingModel(col) addForwardOptionalReverse(col) addForwardReverse(col) addBasicModel(col)