A privacy-first, self-hosted, fully open source personal knowledge management software, written in typescript and golang. (PERSONAL FORK)
1// SiYuan - Refactor your thinking
2// Copyright (c) 2020-present, b3log.org
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Affero General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Affero General Public License for more details.
13//
14// You should have received a copy of the GNU Affero General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17package conf
18
19import (
20 "bytes"
21 "fmt"
22
23 "github.com/open-spaced-repetition/go-fsrs/v3"
24)
25
26type Flashcard struct {
27 NewCardLimit int `json:"newCardLimit"` // 新卡上限 https://github.com/siyuan-note/siyuan/issues/7695
28 ReviewCardLimit int `json:"reviewCardLimit"` // 复习卡上限 https://github.com/siyuan-note/siyuan/issues/7703
29 Mark bool `json:"mark"` // 是否启用标记制卡 https://github.com/siyuan-note/siyuan/issues/7794
30 List bool `json:"list"` // 是否启用列表块制卡 https://github.com/siyuan-note/siyuan/issues/7701
31 SuperBlock bool `json:"superBlock"` // 是否启用超级块制卡 https://github.com/siyuan-note/siyuan/issues/7702
32 Heading bool `json:"heading"` // 是否启用标题块制卡 https://github.com/siyuan-note/siyuan/issues/9005
33 Deck bool `json:"deck"` // 是否启用卡包制卡 https://github.com/siyuan-note/siyuan/issues/7724
34 ReviewMode int `json:"reviewMode"` // 复习模式,0:新旧混合,1:新卡优先,2:旧卡优先 https://github.com/siyuan-note/siyuan/issues/10303
35
36 // Apply result optimized by FSRS optimizer https://github.com/siyuan-note/siyuan/issues/9309
37 RequestRetention float64 `json:"requestRetention"`
38 MaximumInterval int `json:"maximumInterval"`
39 Weights string `json:"weights"`
40}
41
42func NewFlashcard() *Flashcard {
43 param := fsrs.DefaultParam()
44 return &Flashcard{
45 NewCardLimit: 20,
46 ReviewCardLimit: 200,
47 Mark: true,
48 List: true,
49 SuperBlock: true,
50 Heading: true,
51 Deck: false,
52 ReviewMode: 0,
53 RequestRetention: param.RequestRetention,
54 MaximumInterval: int(param.MaximumInterval),
55 Weights: DefaultFSRSWeights(),
56 }
57}
58
59func DefaultFSRSWeights() string {
60 buf := bytes.Buffer{}
61 defaultWs := fsrs.DefaultWeights()
62 for i, w := range defaultWs {
63 buf.WriteString(fmt.Sprintf("%v", w))
64 if i < len(defaultWs)-1 {
65 buf.WriteString(", ")
66 }
67 }
68 return buf.String()
69}