M actions/cards.md => actions/cards.md +46 -0
@@ 306,3 306,49 @@
"error": null
}
```
+
+* **forgetCards**
+
+ Forget cards, making the cards new again.
+
+ *Sample request*:
+ ```json
+ {
+ "action": "forgetCards",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048]
+ }
+ }
+ ```
+
+ *Sample result*:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
+
+* **relearnCards**
+
+ Make cards be "relearning".
+
+ *Sample request*:
+ ```json
+ {
+ "action": "relearnCards",
+ "version": 6,
+ "params": {
+ "cards": [1498938915662, 1502098034048]
+ }
+ }
+ ```
+
+ *Sample result*:
+ ```json
+ {
+ "result": null,
+ "error": null
+ }
+ ```
M plugin/__init__.py => plugin/__init__.py +16 -0
@@ 1036,6 1036,22 @@ class AnkiConnect:
@util.api()
+ def forgetCards(self, cards):
+ self.startEditing()
+ scids = anki.utils.ids2str(cards)
+ self.collection().db.execute('update cards set type=0, queue=0, left=0, ivl=0, due=0, odue=0, factor=0 where id in ' + scids)
+ self.stopEditing()
+
+
+ @util.api()
+ def relearnCards(self, cards):
+ self.startEditing()
+ scids = anki.utils.ids2str(cards)
+ self.collection().db.execute('update cards set type=3, queue=1 where id in ' + scids)
+ self.stopEditing()
+
+
+ @util.api()
def cardReviews(self, deck, startID):
return self.database().all(
'select id, cid, usn, ease, ivl, lastIvl, factor, time, type from revlog ''where id>? and cid in (select id from cards where did=?)',
M tests/test_cards.py => tests/test_cards.py +5 -0
@@ 74,6 74,11 @@ class TestCards(unittest.TestCase):
for i, cardInfo in enumerate(cardsInfo):
self.assertEqual(cardInfo['cardId'], cardIds[i])
+ # forgetCards
+ util.invoke('forgetCards', cards=cardIds)
+
+ # relearnCards
+ util.invoke('relearnCards', cards=cardIds)
if __name__ == '__main__':
unittest.main()