2023-06-24 20:39:55 +08:00
|
|
|
|
// SiYuan - Refactor your thinking
|
2023-03-19 11:50:15 +08:00
|
|
|
|
// Copyright (c) 2020-present, b3log.org
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
package conf
|
|
|
|
|
|
|
2023-09-28 22:22:17 +08:00
|
|
|
|
import (
|
|
|
|
|
|
"bytes"
|
|
|
|
|
|
"fmt"
|
2024-08-28 18:17:46 +08:00
|
|
|
|
|
2024-09-11 11:44:06 +08:00
|
|
|
|
"github.com/open-spaced-repetition/go-fsrs/v3"
|
2023-09-28 22:22:17 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2023-03-19 11:50:15 +08:00
|
|
|
|
type Flashcard struct {
|
2023-03-22 10:57:11 +08:00
|
|
|
|
NewCardLimit int `json:"newCardLimit"` // 新卡上限 https://github.com/siyuan-note/siyuan/issues/7695
|
|
|
|
|
|
ReviewCardLimit int `json:"reviewCardLimit"` // 复习卡上限 https://github.com/siyuan-note/siyuan/issues/7703
|
2023-03-28 10:04:28 +08:00
|
|
|
|
Mark bool `json:"mark"` // 是否启用标记制卡 https://github.com/siyuan-note/siyuan/issues/7794
|
2023-03-22 10:57:11 +08:00
|
|
|
|
List bool `json:"list"` // 是否启用列表块制卡 https://github.com/siyuan-note/siyuan/issues/7701
|
|
|
|
|
|
SuperBlock bool `json:"superBlock"` // 是否启用超级块制卡 https://github.com/siyuan-note/siyuan/issues/7702
|
2023-10-04 11:17:35 +08:00
|
|
|
|
Heading bool `json:"heading"` // 是否启用标题块制卡 https://github.com/siyuan-note/siyuan/issues/9005
|
2023-03-22 10:57:11 +08:00
|
|
|
|
Deck bool `json:"deck"` // 是否启用卡包制卡 https://github.com/siyuan-note/siyuan/issues/7724
|
2024-02-24 10:33:00 +08:00
|
|
|
|
ReviewMode int `json:"reviewMode"` // 复习模式,0:新旧混合,1:新卡优先,2:旧卡优先 https://github.com/siyuan-note/siyuan/issues/10303
|
2023-09-28 22:22:17 +08:00
|
|
|
|
|
|
|
|
|
|
// Apply result optimized by FSRS optimizer https://github.com/siyuan-note/siyuan/issues/9309
|
|
|
|
|
|
RequestRetention float64 `json:"requestRetention"`
|
2023-09-28 22:39:12 +08:00
|
|
|
|
MaximumInterval int `json:"maximumInterval"`
|
2023-09-28 22:22:17 +08:00
|
|
|
|
Weights string `json:"weights"`
|
2023-03-19 11:50:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewFlashcard() *Flashcard {
|
2023-09-28 22:22:17 +08:00
|
|
|
|
param := fsrs.DefaultParam()
|
2023-03-19 11:50:15 +08:00
|
|
|
|
return &Flashcard{
|
2023-09-28 22:22:17 +08:00
|
|
|
|
NewCardLimit: 20,
|
|
|
|
|
|
ReviewCardLimit: 200,
|
|
|
|
|
|
Mark: true,
|
|
|
|
|
|
List: true,
|
|
|
|
|
|
SuperBlock: true,
|
2023-10-04 11:17:35 +08:00
|
|
|
|
Heading: true,
|
2023-09-28 22:22:17 +08:00
|
|
|
|
Deck: false,
|
2024-02-24 10:33:00 +08:00
|
|
|
|
ReviewMode: 0,
|
2023-09-28 22:22:17 +08:00
|
|
|
|
RequestRetention: param.RequestRetention,
|
2023-09-28 22:39:12 +08:00
|
|
|
|
MaximumInterval: int(param.MaximumInterval),
|
2025-10-22 22:08:38 +08:00
|
|
|
|
Weights: DefaultFSRSWeights(),
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func DefaultFSRSWeights() string {
|
|
|
|
|
|
buf := bytes.Buffer{}
|
|
|
|
|
|
defaultWs := fsrs.DefaultWeights()
|
|
|
|
|
|
for i, w := range defaultWs {
|
|
|
|
|
|
buf.WriteString(fmt.Sprintf("%v", w))
|
|
|
|
|
|
if i < len(defaultWs)-1 {
|
|
|
|
|
|
buf.WriteString(", ")
|
|
|
|
|
|
}
|
2023-03-19 11:50:15 +08:00
|
|
|
|
}
|
2025-10-22 22:08:38 +08:00
|
|
|
|
return buf.String()
|
2023-03-19 11:50:15 +08:00
|
|
|
|
}
|