diff --git a/anki/collection.py b/anki/collection.py
index 862055135..ed28ad78b 100644
--- a/anki/collection.py
+++ b/anki/collection.py
@@ -443,11 +443,7 @@ select id from notes where id in %s and id not in (select nid from cards)""" %
if type == "q":
format = format.replace("cloze:", "cq:")
else:
- if model['clozectx']:
- name = "cactx:"
- else:
- name = "ca:"
- format = format.replace("cloze:", name)
+ format = format.replace("cloze:", "ca:")
fields = runFilter("mungeFields", fields, model, data, self)
html = anki.template.render(format, fields)
d[type] = runFilter(
diff --git a/anki/decks.py b/anki/decks.py
index 8810cde10..725edbab7 100644
--- a/anki/decks.py
+++ b/anki/decks.py
@@ -224,17 +224,21 @@ class DeckManager(object):
def didsForConf(self, conf):
dids = []
- for deck in self.decks:
+ for deck in self.decks.values():
if deck['conf'] == conf['id']:
dids.append(deck['id'])
return dids
def restoreToDefault(self, conf):
+ oldOrder = conf['new']['order']
new = copy.deepcopy(defaultConf)
new['id'] = conf['id']
new['name'] = conf['name']
self.dconf[str(conf['id'])] = new
self.save(new)
+ # if it was previously randomized, resort
+ if not oldOrder:
+ self.col.sched.resortConf(new)
# Deck utils
#############################################################
diff --git a/anki/models.py b/anki/models.py
index bad5d654d..69697c01e 100644
--- a/anki/models.py
+++ b/anki/models.py
@@ -16,7 +16,6 @@ from anki.consts import *
defaultModel = {
'sortf': 0,
'did': 1,
- 'clozectx': False,
'latexPre': """\
\\documentclass[12pt]{article}
\\special{papersize=3in,5in}
diff --git a/anki/stdmodels.py b/anki/stdmodels.py
index ce243294d..2cbac30c5 100644
--- a/anki/stdmodels.py
+++ b/anki/stdmodels.py
@@ -6,19 +6,32 @@ from anki.lang import _
models = []
+_header = """\
+\n\n"""
+
+def _field(name):
+ return """\
+{{%s}}\n""" % name
+
# Basic
##########################################################################
def addBasicModel(col):
mm = col.models
- m = mm.new(_("Basic"))
+ m = mm.new(_("Basic")) #2 field note"))
fm = mm.newField(_("Front"))
mm.addField(m, fm)
fm = mm.newField(_("Back"))
mm.addField(m, fm)
t = mm.newTemplate(_("Forward"))
- t['qfmt'] = "{{" + _("Front") + "}}"
- t['afmt'] = "{{" + _("Back") + "}}"
+ t['qfmt'] = _header + _field(_("Front"))
+ t['afmt'] = t['qfmt'] + "\n\n
\n\n" + _field(_("Back"))
mm.addTemplate(m, t)
mm.add(m)
return m
@@ -31,17 +44,17 @@ models.append((_("Basic"), addBasicModel))
def addClozeModel(col):
mm = col.models
m = mm.new(_("Cloze"))
- fm = mm.newField(_("Text"))
+ fm = mm.newField(("Text"))
mm.addField(m, fm)
fm = mm.newField(_("Notes"))
mm.addField(m, fm)
for i in range(8):
n = i+1
t = mm.newTemplate(_("Cloze") + " %d" % n)
- t['qfmt'] = ("{{#cloze:%d:Text}}
{{cloze:%d:%s}}
"+
- "{{/cloze:%d:Text}}") % (n, n, _("Text"), n)
- t['afmt'] = ("{{cloze:%d:" + _("Text") + "}}") % n
- t['afmt'] += "
{{" + _("Notes") + "}}"
+ t['qfmt'] = _header + ("{{#cloze:%d:Text}}\n"+
+ _field("cloze:%d:Text" % n)+
+ "{{/cloze:%d:Text}}") % (n, n)
+ t['afmt'] = t['qfmt'] + "
\n"+_field("Notes")
mm.addTemplate(m, t)
mm.add(m)
return m
diff --git a/anki/template/template.py b/anki/template/template.py
index ec9c67b40..ddead788c 100644
--- a/anki/template/template.py
+++ b/anki/template/template.py
@@ -162,8 +162,7 @@ class Template(object):
# to process
return "[[%s]]" % tag_name
elif (tag_name.startswith("cq:") or
- tag_name.startswith("ca:") or
- tag_name.startswith("cactx:")):
+ tag_name.startswith("ca:")):
m = re.match("c(.+):(\d+):(.+)", tag_name)
(type, ord, tag) = (m.group(1), m.group(2), m.group(3))
txt = get_or_attr(context, tag)
@@ -184,15 +183,8 @@ class Template(object):
txt = re.sub(reg%ord, "[...(\\3)]", txt)
else:
txt = re.sub(reg%ord, "[...]", txt)
- elif type == "actx":
+ elif type == "a":
txt = re.sub(reg%ord, "\\1", txt)
- else:
- # just the answers
- ans = re.findall(reg%ord, txt)
- ans = [""+a[0]+"" for a in ans]
- ans = ", ".join(ans)
- # but we want to preserve the outer field styling
- return ans
# and display other clozes normally
return re.sub(reg%".*?", "\\1", txt)
diff --git a/tests/test_collection.py b/tests/test_collection.py
index 5f5fb1cb1..f60232276 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -69,7 +69,7 @@ def test_noteAddDelete():
assert deck.cardCount() == 4
# check q/a generation
c0 = f.cards()[0]
- assert re.sub("?.+?>", "", c0.q()) == u"three"
+ assert "three" in c0.q()
# it should not be a duplicate
assert not f.dupeOrEmpty()
# now let's make a duplicate
diff --git a/tests/test_models.py b/tests/test_models.py
index f4f498b1a..56fe7ccc7 100644
--- a/tests/test_models.py
+++ b/tests/test_models.py
@@ -35,7 +35,7 @@ def test_fields():
m = d.models.current()
# make sure renaming a field updates the templates
d.models.renameField(m, m['flds'][0], "NewFront")
- assert m['tmpls'][0]['qfmt'] == "{{NewFront}}"
+ assert "{{NewFront}}" in m['tmpls'][0]['qfmt']
h = d.models.scmhash(m)
# add a field
f = d.models.newField(m)
@@ -127,11 +127,6 @@ def test_cloze():
f['Text'] = "hello {{c1::world}}"
assert d.addNote(f) == 1
assert "hello [...]" in f.cards()[0].q()
- # the default is no context
- assert "world" in f.cards()[0].a()
- assert "hello world" not in f.cards()[0].a()
- # check context works too
- f.model()['clozectx'] = True
assert "hello world" in f.cards()[0].a()
# and with a comment
f = d.newNote()
@@ -150,11 +145,10 @@ def test_cloze():
assert "world bar" in c2.a()
# if there are multiple answers for a single cloze, they are given in a
# list
- f.model()['clozectx'] = False
f = d.newNote()
f['Text'] = "a {{c1::b}} {{c1::c}}"
assert d.addNote(f) == 1
- assert "b, c" in (
+ assert "b c" in (
f.cards()[0].a())
# clozes should be supported in sections too
m = d.models.current()
@@ -196,14 +190,14 @@ def test_modelChange():
# switch cards
c0 = f.cards()[0]
c1 = f.cards()[1]
- assert stripHTML(c0.q()) == "b"
- assert stripHTML(c1.q()) == "f"
+ assert ">b<" in c0.q()
+ assert "f" in c1.q()
assert c0.ord == 0
assert c1.ord == 1
deck.models.change(basic, [f.id], basic, None, map)
f.load(); c0.load(); c1.load()
- assert stripHTML(c0.q()) == "f"
- assert stripHTML(c1.q()) == "b"
+ assert "f" in c0.q()
+ assert ">b<" in c1.q()
assert c0.ord == 1
assert c1.ord == 0
# .cards() returns cards in order
diff --git a/tests/test_sched.py b/tests/test_sched.py
index a482e92f4..73cffb4fa 100644
--- a/tests/test_sched.py
+++ b/tests/test_sched.py
@@ -50,7 +50,7 @@ def test_new():
qs = ("2", "3", "2", "3")
for n in range(4):
c = d.sched.getCard()
- assert(stripHTML(c.q()) == qs[n])
+ assert qs[n] in c.q()
d.sched.answerCard(c, 2)
def test_newLimits():