Merge pull request #150 from corollari/master

Complete 975c069 fixes
This commit is contained in:
Alex Yatskov 2020-04-04 11:32:14 -07:00 committed by GitHub
commit 521398870c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 15 deletions

View File

@ -819,22 +819,12 @@ class AnkiConnect:
name = info['name']
fields[name] = {'value': note.fields[order], 'order': order}
if getattr(card, 'question', None) is None:
question = card._getQA()['q']
else:
question = card.question(),
if getattr(card, 'answer', None) is None:
answer = card._getQA()['a']
else:
answer = card.answer()
result.append({
'cardId': card.id,
'fields': fields,
'fieldOrder': card.ord,
'question': question,
'answer': answer,
'question': util.getQuestion(card),
'answer': util.getAnswer(card),
'modelName': model['name'],
'deckName': self.deckNameFromId(card.did),
'css': model['css'],
@ -1081,15 +1071,14 @@ class AnkiConnect:
order = info['ord']
name = info['name']
fields[name] = {'value': note.fields[order], 'order': order}
if card is not None:
buttonList = reviewer._answerButtonList()
return {
'cardId': card.id,
'fields': fields,
'fieldOrder': card.ord,
'question': card.question(),
'answer': card.answer(),
'question': util.getQuestion(card),
'answer': util.getAnswer(card),
'buttons': [b[0] for b in buttonList],
'nextReviews': [reviewer.mw.col.sched.nextIvlStr(reviewer.card, b[0], True) for b in buttonList],
'modelName': model['name'],

View File

@ -44,6 +44,22 @@ def api(*versions):
return decorator
def getQuestion(card):
if getattr(card, 'question', None) is None:
question = card._getQA()['q']
else:
question = card.question(),
return question
def getAnswer(card):
if getattr(card, 'answer', None) is None:
answer = card._getQA()['a']
else:
answer = card.answer()
return answer
def setting(key):
defaults = {
'apiKey': None,