fix typing of cloze answer

This commit is contained in:
Damien Elmes 2012-04-22 09:12:45 +09:00
parent 53f6dacf62
commit 8ea44cb3bf

View file

@ -282,22 +282,18 @@ img { max-width: 95%; max-height: 95%; }
return buf return buf
fld = m.group(1) fld = m.group(1)
# if it's a cloze, extract data # if it's a cloze, extract data
if fld.startswith("cq:"): if fld.startswith("cloze:"):
# get field and cloze position # get field and cloze position
m = re.match("cq:(\d+):(.+)", fld) clozeIdx = self.card.ord + 1
if not m: fld = fld.split(":")[1]
return re.sub(
self.typeAnsPat, _("Type answer: invalid cloze pattern"),
buf)
clozeIdx = m.group(1)
fld = m.group(2)
# loop through fields for a match # loop through fields for a match
for f in self.card.model()['flds']: for f in self.card.model()['flds']:
if f['name'] == fld: if f['name'] == fld:
self.typeCorrect = self.card.note()[f['name']] self.typeCorrect = self.card.note()[f['name']]
if clozeIdx: if clozeIdx:
# narrow to cloze # narrow to cloze
self.typeCorrect = self._contentForCloze(self.typeCorrect, clozeIdx) self.typeCorrect = self._contentForCloze(
self.typeCorrect, clozeIdx)
self.typeFont = f['font'] self.typeFont = f['font']
self.typeSize = f['size'] self.typeSize = f['size']
break break