cloze generation needs to use provided fields, not field 0

This commit is contained in:
Damien Elmes 2012-04-21 07:25:35 +09:00
parent 014dc3d987
commit 9fab2834da

View file

@ -509,9 +509,16 @@ select id from notes where mid = ?)""" % " ".join(map),
return avail return avail
def _availClozeOrds(self, m, flds): def _availClozeOrds(self, m, flds):
ret = [int(m)-1 for m in re.findall( sflds = splitFields(flds)
"{{c(\d+)::[^}]*?}}", splitFields(flds)[0])] map = self.fieldMap(m)
return list(set(ret)) 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 # Sync handling
########################################################################## ##########################################################################