mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
forward/reverse models
This commit is contained in:
parent
c9b3d89d44
commit
da856552b2
2 changed files with 36 additions and 1 deletions
|
@ -26,6 +26,38 @@ def addBasicModel(col):
|
||||||
|
|
||||||
models.append((lambda: _("Basic"), addBasicModel))
|
models.append((lambda: _("Basic"), addBasicModel))
|
||||||
|
|
||||||
|
# Forward & Reverse
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
def addForwardReverse(col):
|
||||||
|
mm = col.models
|
||||||
|
m = addBasicModel(col)
|
||||||
|
m['name'] = _("Basic (and reversed card)")
|
||||||
|
t = mm.newTemplate(_("Card 2"))
|
||||||
|
t['qfmt'] = "{{"+_("Back")+"}}"
|
||||||
|
t['afmt'] = "{{FrontSide}}\n\n<hr id=answer>\n\n"+"{{"+_("Front")+"}}"
|
||||||
|
mm.addTemplate(m, t)
|
||||||
|
return m
|
||||||
|
|
||||||
|
models.append((lambda: _("Forward & Reverse"), addForwardReverse))
|
||||||
|
|
||||||
|
# Forward & Optional Reverse
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
def addForwardOptionalReverse(col):
|
||||||
|
mm = col.models
|
||||||
|
m = addBasicModel(col)
|
||||||
|
m['name'] = _("Basic (optional reversed card)")
|
||||||
|
fm = mm.newField(_("Add Reverse"))
|
||||||
|
mm.addField(m, fm)
|
||||||
|
t = mm.newTemplate(_("Card 2"))
|
||||||
|
t['qfmt'] = "{{#Add Reverse}}{{"+_("Back")+"}}{{/Add Reverse}}"
|
||||||
|
t['afmt'] = "{{FrontSide}}\n\n<hr id=answer>\n\n"+"{{"+_("Front")+"}}"
|
||||||
|
mm.addTemplate(m, t)
|
||||||
|
return m
|
||||||
|
|
||||||
|
models.append((lambda: _("Forward & Optional Reverse"), addForwardOptionalReverse))
|
||||||
|
|
||||||
# Cloze
|
# Cloze
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@ from anki.utils import intTime, ids2str, json
|
||||||
from anki.db import DB
|
from anki.db import DB
|
||||||
from anki.collection import _Collection
|
from anki.collection import _Collection
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
from anki.stdmodels import addBasicModel, addClozeModel
|
from anki.stdmodels import addBasicModel, addClozeModel, addForwardReverse, \
|
||||||
|
addForwardOptionalReverse
|
||||||
|
|
||||||
def Collection(path, lock=True, server=False, sync=True):
|
def Collection(path, lock=True, server=False, sync=True):
|
||||||
"Open a new or existing collection. Path must be unicode."
|
"Open a new or existing collection. Path must be unicode."
|
||||||
|
@ -38,6 +39,8 @@ def Collection(path, lock=True, server=False, sync=True):
|
||||||
elif create:
|
elif create:
|
||||||
# add in reverse order so basic is default
|
# add in reverse order so basic is default
|
||||||
addClozeModel(col)
|
addClozeModel(col)
|
||||||
|
addForwardOptionalReverse(col)
|
||||||
|
addForwardReverse(col)
|
||||||
addBasicModel(col)
|
addBasicModel(col)
|
||||||
col.save()
|
col.save()
|
||||||
if lock:
|
if lock:
|
||||||
|
|
Loading…
Reference in a new issue