This commit is contained in:
Alex Yatskov 2017-06-28 21:17:11 -07:00
parent 54ab68feb4
commit 7c410ee64a

View File

@ -435,14 +435,13 @@ class AnkiBridge:
def guiGetNextCard(self): def guiGetNextCard(self):
if self.window().reviewer.card is None or self.window().state != 'review': window = self.window()
self.window().moveToState('review') if window.reviewer.card is None or window.state != 'review':
window.moveToState('review')
card = self.window().reviewer.card card = window.reviewer.card
if card is not None:
if card:
return { return {
'success': True,
'id': card.id, 'id': card.id,
'question': card._getQA()['q'], 'question': card._getQA()['q'],
'answer': card._getQA()['a'], 'answer': card._getQA()['a'],
@ -452,34 +451,32 @@ class AnkiBridge:
'fields': card.note(reload).fields, 'fields': card.note(reload).fields,
'fieldMap': card.note(reload)._fmap 'fieldMap': card.note(reload)._fmap
} }
else:
return 'There are no cards left to review.'
def guiShowQuestion(self): def guiShowQuestion(self):
if self.window().reviewer.card is None or self.window().state != 'review': window = self.window()
self.window().moveToState('review') if window.reviewer.card is None or window.state != 'review':
window.moveToState('review')
self.window().reviewer._showQuestion() window.reviewer._showQuestion()
return True
def guiShowAnswer(self): def guiShowAnswer(self):
if self.window().reviewer.mw.state != 'review': window = self.window()
return 'Window state is not review.' if window.reviewer.mw.state == 'review':
else:
self.window().reviewer._showAnswer() self.window().reviewer._showAnswer()
return True
def guiAnswerCard(self, id, ease): def guiAnswerCard(self, cardId, ease):
if self.window().reviewer.mw.state != 'review': window = self.window()
return 'Window state is not review.' if window.reviewer.mw.state != 'review':
elif self.window().reviewer.state != 'answer': return False
return 'Reviewer state is not answer.' elif window.reviewer.state != 'answer':
elif self.window().reviewer.card.id != id: return False
return 'Given card does not match.' elif window.reviewer.card.id != cardId:
elif self.window().col.sched.answerButtons(self.window().reviewer.card) < ease: return False
return 'Invalid ease provided.' elif window.col.sched.answerButtons(window.reviewer.card) < ease:
return False
else: else:
self.window().reviewer._answerCard(ease) self.window().reviewer._answerCard(ease)
return True return True
@ -487,7 +484,6 @@ class AnkiBridge:
def guiCheckState(self): def guiCheckState(self):
return { return {
'success': True,
'windowState': self.window().state, 'windowState': self.window().state,
'reviewerState': self.window().reviewer.state 'reviewerState': self.window().reviewer.state
} }