diff --git a/AnkiConnect.py b/AnkiConnect.py index 31f116a..5e02670 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -494,17 +494,14 @@ class AnkiBridge: return False - def guiAnswerCard(self, cardId, ease): + def guiAnswerCard(self, ease): if not self.guiReviewActive(): return False reviewer = self.reviewer() - card = reviewer.card - if card.id != cardId: - return False if reviewer.state != 'answer': return False - if ease <= 0 or ease > self.scheduler().answerButtons(card): + if ease <= 0 or ease > self.scheduler().answerButtons(reviewer.card): return False reviewer._answerCard(ease) @@ -622,8 +619,8 @@ class AnkiConnect: return self.anki.guiCurrentCard() - def api_guiAnswerCard(self, cardId, ease): - return self.anki.guiAnswerCard(cardId, ease) + def api_guiAnswerCard(self, ease): + return self.anki.guiAnswerCard(ease) def api_guiShowQuestion(self): diff --git a/README.md b/README.md index f69a3a7..c673b26 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ rather than raw JSON. If you are writing raw requests be sure to send valid JSON * **version** - Gets the version of the API exposed by this plugin. Currently versions `1` through `3` are defined. + Gets the version of the API exposed by this plugin. Currently versions `1` through `4` are defined. This should be the first call you make to make sure that your application and AnkiConnect are able to communicate properly with each other. New versions of AnkiConnect will backwards compatible; as long as you are using actions @@ -336,14 +336,14 @@ rather than raw JSON. If you are writing raw requests be sure to send valid JSON null ``` -* **guiGetNextCard** +* **guiCurrentCard** - Returns next/current card, calling this multiple times will not skip unanswered cards. The low level fields and card direction can be derived from the 'fieldOrder', 'fieldMap' and 'fields' keys in the response. + Returns information about the current card or `null` if not in review mode. *Sample request*: ``` { - action: 'guiGetNextCard', + action: 'guiCurrentCard', params: {} } ``` @@ -351,67 +351,18 @@ rather than raw JSON. If you are writing raw requests be sure to send valid JSON *Sample response*: ``` { - 'success': true, - 'question': 'Hello', - 'fieldMap': { - 'Front': [ - 0, - { - 'name': 'Front', - 'media': [], - 'sticky': false, - 'rtl': false, - 'ord': 0, - 'font': 'Arial', - 'size': 20 - } - ], - 'Back': [ - 1, - { - 'name': 'Back', - 'media': [], - 'sticky': false, - 'rtl': false, - 'ord': 1, - 'font': 'Arial', - 'size': 20 - } - ] - }, - 'answerButtons': [ - [ - 1, - 'Again' - ], - [ - 2, - 'Good' - ], - [ - 3, - 'Easy' - ] - ], - 'modelName': 'Basic', - "fields": [ - "Hello", - "Hola" - ], - 'answer': 'Hello\n\n