diff --git a/ankiqt/ui/modelproperties.py b/ankiqt/ui/modelproperties.py
index a99793ebd..e0540dc6f 100644
--- a/ankiqt/ui/modelproperties.py
+++ b/ankiqt/ui/modelproperties.py
@@ -293,7 +293,20 @@ class ModelProperties(QDialog):
self.dialog.cardAnswer.setPlainText(card.aformat.replace("
", "\n"))
self.dialog.questionInAnswer.setChecked(card.questionInAnswer)
self.dialog.allowEmptyAnswer.setChecked(card.allowEmptyAnswer)
- self.dialog.typeAnswer.setChecked(card.typeAnswer)
+ self.dialog.typeAnswer.clear()
+ self.fieldNames = self.deck.s.column0("""
+select fieldModels.name as n from fieldModels, cardModels
+where cardModels.modelId = fieldModels.modelId
+and cardModels.id = :id
+order by n""", id=card.id)
+ s = [_("Don't ask me to type in the answer")]
+ s += [_("Compare with field '%s'") % f for f in self.fieldNames]
+ self.dialog.typeAnswer.insertItems(0, QStringList(s))
+ try:
+ idx = self.fieldNames.index(card.typeAnswer)
+ except ValueError:
+ idx = -1
+ self.dialog.typeAnswer.setCurrentIndex(idx + 1)
self.updateToggleButtonText(card)
def enableCardMoveButtons(self):
@@ -330,7 +343,11 @@ class ModelProperties(QDialog):
changed = changed or changed2
self.updateField(card, 'questionInAnswer', self.dialog.questionInAnswer.isChecked())
self.updateField(card, 'allowEmptyAnswer', self.dialog.allowEmptyAnswer.isChecked())
- self.updateField(card, 'typeAnswer', self.dialog.typeAnswer.isChecked())
+ idx = self.dialog.typeAnswer.currentIndex()
+ if not idx:
+ self.updateField(card, 'typeAnswer', u"")
+ else:
+ self.updateField(card, 'typeAnswer', self.fieldNames[idx-1])
if changed:
# need to generate all question/answers for this card
self.deck.updateCardsFromModel(self.m)
diff --git a/ankiqt/ui/view.py b/ankiqt/ui/view.py
index 84e1ffd90..efda0e21d 100644
--- a/ankiqt/ui/view.py
+++ b/ankiqt/ui/view.py
@@ -136,27 +136,32 @@ class View(object):
"Show the answer."
a = self.main.currentCard.htmlAnswer()
if self.main.currentCard.cardModel.typeAnswer:
- cor = stripHTML(self.main.currentCard.answer)
- given = unicode(self.main.typeAnswerField.text())
- res = []
- if len(given) < len(cor):
- given += " " * (len(cor) - len(given))
- sz = self.main.currentCard.cardModel.answerFontSize
- ok = "background: %s; color: #000; font-size: %dpx" % (
- passedCharColour, sz)
- bad = "background: %s; color: #000; font-size: %dpx;" % (
- failedCharColour, sz)
- for (i, c) in enumerate(given):
- try:
- yes = c == cor[i]
- except IndexError:
- yes = False
- if yes:
- res.append(
- "%s" % (ok, c))
- else:
- res.append("%s" % (bad, c))
- a = "".join(res) + "
" + a
+ try:
+ cor = stripHTML(self.main.currentCard.fact[
+ self.main.currentCard.cardModel.typeAnswer])
+ except KeyError:
+ cor = ""
+ if cor:
+ given = unicode(self.main.typeAnswerField.text())
+ res = []
+ if len(given) < len(cor):
+ given += " " * (len(cor) - len(given))
+ sz = self.main.currentCard.cardModel.answerFontSize
+ ok = "background: %s; color: #000; font-size: %dpx" % (
+ passedCharColour, sz)
+ bad = "background: %s; color: #000; font-size: %dpx;" % (
+ failedCharColour, sz)
+ for (i, c) in enumerate(given):
+ try:
+ yes = c == cor[i]
+ except IndexError:
+ yes = False
+ if yes:
+ res.append(
+ "%s" % (ok, c))
+ else:
+ res.append("%s" % (bad, c))
+ a = "".join(res) + "
" + a
self.write(self.center('' +
self.mungeQA(self.main.deck, a)))
if self.state != self.oldState:
diff --git a/designer/modelproperties.ui b/designer/modelproperties.ui
index 7a51394e9..695ccf2fb 100644
--- a/designer/modelproperties.ui
+++ b/designer/modelproperties.ui
@@ -387,13 +387,6 @@
- -
-
-
- Hide the question when showing answer
-
-
-
-
@@ -457,13 +450,6 @@
- -
-
-
- Allow the answer to be blank
-
-
-
-
@@ -490,10 +476,20 @@
- -
-
+
-
+
+
+ -
+
- Ask me to type in the answer
+ Hide the question when showing answer
+
+
+
+ -
+
+
+ Allow the answer to be blank
@@ -544,9 +540,6 @@
cardName
cardQuestion
cardAnswer
- questionInAnswer
- allowEmptyAnswer
- typeAnswer
buttonBox
@@ -558,8 +551,8 @@
accept()
- 248
- 254
+ 252
+ 513
157
@@ -574,8 +567,8 @@
reject()
- 316
- 260
+ 320
+ 513
286