🎨 Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564

This commit is contained in:
Daniel 2023-11-16 11:37:56 +08:00
parent 84b29657f8
commit 37b099dfa5
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 99 additions and 2 deletions

View file

@ -27,6 +27,28 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
func resetRiffCards(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
typ := arg["type"].(string) // notebook, tree, deck
id := arg["id"].(string) // notebook ID, root ID, deck ID
blockIDsArg := arg["blockIDs"] // 如果不传入 blockIDs (或者传入实参为空数组),则重置所有卡片
var blockIDs []string
if nil != blockIDsArg {
for _, blockID := range blockIDsArg.([]interface{}) {
blockIDs = append(blockIDs, blockID.(string))
}
}
model.ResetFlashcards(typ, id, blockIDs)
}
func getNotebookRiffCards(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
@ -76,7 +98,7 @@ func getRiffCards(c *gin.Context) {
deckID := arg["id"].(string)
page := int(arg["page"].(float64))
blocks, total, pageCount := model.GetFlashcards(deckID, page)
blocks, total, pageCount := model.GetDeckFlashcards(deckID, page)
ret.Data = map[string]interface{}{
"blocks": blocks,
"total": total,