From 9fab2834daf8bf18ce0337bef648a4d59437c4c2 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 21 Apr 2012 07:25:35 +0900 Subject: [PATCH] cloze generation needs to use provided fields, not field 0 --- anki/models.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/anki/models.py b/anki/models.py index 77d6cea1b..d1179775f 100644 --- a/anki/models.py +++ b/anki/models.py @@ -509,9 +509,16 @@ select id from notes where mid = ?)""" % " ".join(map), return avail def _availClozeOrds(self, m, flds): - ret = [int(m)-1 for m in re.findall( - "{{c(\d+)::[^}]*?}}", splitFields(flds)[0])] - return list(set(ret)) + sflds = splitFields(flds) + map = self.fieldMap(m) + ords = set() + for fname in re.findall("{{cloze:(.+?)}}", m['tmpls'][0]['qfmt']): + if fname not in map: + continue + ord = map[fname][0] + ords.update([int(m)-1 for m in re.findall( + "{{c(\d+)::[^}]*?}}", sflds[ord])]) + return list(ords) # Sync handling ##########################################################################