From bbeb6282d665665b37730af2f3fa1fc7f85d5a40 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 16 Nov 2023 23:45:50 +0800 Subject: [PATCH 1/7] :art: Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564 --- kernel/model/flashcard.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index fc88f26bc..21b377a6d 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -52,7 +52,7 @@ func ResetFlashcards(typ, id, deckID string, blockIDs []string) { case "notebook": for i := 1; ; i++ { pagedBlocks, _, _ := GetNotebookFlashcards(id, i) - if 1 > len(blocks) { + if 1 > len(pagedBlocks) { break } blocks = append(blocks, pagedBlocks...) @@ -63,7 +63,7 @@ func ResetFlashcards(typ, id, deckID string, blockIDs []string) { case "tree": for i := 1; ; i++ { pagedBlocks, _, _ := GetTreeFlashcards(id, i) - if 1 > len(blocks) { + if 1 > len(pagedBlocks) { break } blocks = append(blocks, pagedBlocks...) @@ -74,7 +74,7 @@ func ResetFlashcards(typ, id, deckID string, blockIDs []string) { case "deck": for i := 1; ; i++ { pagedBlocks, _, _ := GetDeckFlashcards(id, i) - if 1 > len(blocks) { + if 1 > len(pagedBlocks) { break } blocks = append(blocks, pagedBlocks...) From 259606e995563053311fe1dc08a93cbbb149f112 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 16 Nov 2023 23:48:31 +0800 Subject: [PATCH 2/7] :art: Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564 --- kernel/model/flashcard.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 21b377a6d..7e6b695f2 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -43,7 +43,7 @@ func ResetFlashcards(typ, id, deckID string, blockIDs []string) { // Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564 if 0 < len(blockIDs) { - resetFlashcards(id, blockIDs) + resetFlashcards(deckID, blockIDs) return } From 97c33f14d963b42665e43acecfedf4cdc50875e8 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 16 Nov 2023 23:52:20 +0800 Subject: [PATCH 3/7] :art: Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564 --- kernel/model/flashcard.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 7e6b695f2..240727ba0 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -43,6 +43,10 @@ func ResetFlashcards(typ, id, deckID string, blockIDs []string) { // Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564 if 0 < len(blockIDs) { + if "" == deckID { + deckID = builtinDeckID + } + resetFlashcards(deckID, blockIDs) return } From 342f76484053d2f180aa67450dc8618774ba2e35 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 16 Nov 2023 23:59:46 +0800 Subject: [PATCH 4/7] :art: Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564 --- kernel/model/flashcard.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 240727ba0..191459133 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -44,10 +44,20 @@ func ResetFlashcards(typ, id, deckID string, blockIDs []string) { if 0 < len(blockIDs) { if "" == deckID { + for _, deck := range Decks { + allBlockIDs := deck.GetBlockIDs() + for _, blockID := range blockIDs { + if gulu.Str.Contains(blockID, allBlockIDs) { + deckID = deck.ID + break + } + } + resetFlashcards(deckID, blockIDs) + } deckID = builtinDeckID + } else { + resetFlashcards(deckID, blockIDs) } - - resetFlashcards(deckID, blockIDs) return } From c4174ea191c0ad0a5312d9de89f5707e437a6755 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 17 Nov 2023 00:01:52 +0800 Subject: [PATCH 5/7] :art: Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564 --- kernel/model/flashcard.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 191459133..00d0c39ac 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -54,10 +54,10 @@ func ResetFlashcards(typ, id, deckID string, blockIDs []string) { } resetFlashcards(deckID, blockIDs) } - deckID = builtinDeckID - } else { - resetFlashcards(deckID, blockIDs) + return } + + resetFlashcards(deckID, blockIDs) return } From f78c5ab3c8727326dd029e9a63b10b144f10c5b9 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 17 Nov 2023 00:04:15 +0800 Subject: [PATCH 6/7] :art: Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564 --- kernel/model/flashcard.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 00d0c39ac..9cc7a7f60 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -52,6 +52,9 @@ func ResetFlashcards(typ, id, deckID string, blockIDs []string) { break } } + if "" == deckID { + continue + } resetFlashcards(deckID, blockIDs) } return From d81dfc503c37666eab7170dcd8ecee078345479b Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 17 Nov 2023 00:05:30 +0800 Subject: [PATCH 7/7] :art: Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564 --- kernel/model/flashcard.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 9cc7a7f60..7ec61925d 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -44,6 +44,7 @@ func ResetFlashcards(typ, id, deckID string, blockIDs []string) { if 0 < len(blockIDs) { if "" == deckID { + // 从全局管理进入时不会指定卡包 ID,这时需要遍历所有卡包 for _, deck := range Decks { allBlockIDs := deck.GetBlockIDs() for _, blockID := range blockIDs { @@ -53,6 +54,7 @@ func ResetFlashcards(typ, id, deckID string, blockIDs []string) { } } if "" == deckID { + logging.LogWarnf("deck not found for blocks [%s]", strings.Join(blockIDs, ",")) continue } resetFlashcards(deckID, blockIDs)