From 82636b024a17009bc76f11b25aa8b1ecbe50c245 Mon Sep 17 00:00:00 2001 From: Charles Henry Date: Wed, 16 Aug 2017 13:04:05 +0100 Subject: [PATCH] Add guiStartCardTimer function --- AnkiConnect.py | 16 ++++++++++++++++ README.md | 20 ++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/AnkiConnect.py b/AnkiConnect.py index e70cffb..c5c16ce 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -631,6 +631,17 @@ class AnkiBridge: } + def guiStartCardTimer(self): + if not self.guiReviewActive(): + return False + + card = self.reviewer().card + + if card is not None: + card.startTimer() + return True + + def guiShowQuestion(self): if self.guiReviewActive(): self.reviewer()._showQuestion() @@ -894,6 +905,11 @@ class AnkiConnect: return self.anki.guiCurrentCard() + @webApi + def guiStartCardTimer(self): + return self.anki.guiStartCardTimer() + + @webApi def guiAnswerCard(self, ease): return self.anki.guiAnswerCard(ease) diff --git a/README.md b/README.md index 9d16bfc..65ffe30 100644 --- a/README.md +++ b/README.md @@ -533,7 +533,7 @@ Below is a list of currently supported actions. Requests with invalid actions or "Japanese::JLPT N3": [1502298036657, 1502298033753] } ``` - + * **changeDeck** @@ -554,7 +554,7 @@ Below is a list of currently supported actions. Requests with invalid actions or ``` null ``` - + * **deleteDecks** Deletes decks with the given names. If `cardsToo` is `true` (defaults to `false` if unspecified), the cards within @@ -672,6 +672,22 @@ Below is a list of currently supported actions. Requests with invalid actions or } ``` +* **guiStartCardTimer** + + Starts or resets the 'timerStarted' value for the current card. This is useful for deferring the start time to when it is displayed via the API, allowing the recorded time taken to answer the card to be more accurate when calling guiAnswerCard. + + *Sample request*: + ``` + { + "action": "guiStartCardTimer" + } + ``` + + *Sample response*: + ``` + true + ``` + * **guiShowQuestion** Shows question text for the current card; returns `true` if in review mode or `false` otherwise.