Add "forgetCards" and "relearnCards" (#234)
* Add "forgetCards" and "relearnCards" * Add unit tests Co-authored-by: Tsung-Po Sun <tsungpo.sun@smartnews.com>
This commit is contained in:
parent
131a1c7cfc
commit
a4d723de3e
@ -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
|
||||
}
|
||||
```
|
||||
|
@ -1035,6 +1035,22 @@ class AnkiConnect:
|
||||
return result
|
||||
|
||||
|
||||
@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(
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user