forked from siyuan-note/riff
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard.go
81 lines (62 loc) · 1.98 KB
/
card.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Riff - Spaced repetition.
// Copyright (c) 2022-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 riff
import "time"
// Card 描述了闪卡。
type Card interface {
// ID 返回闪卡 ID。
ID() string
// BlockID 返回闪卡关联的内容块 ID。
BlockID() string
// NextDues 返回每种评分对应的下次到期时间。
NextDues() map[Rating]time.Time
// SetNextDues 设置每种评分对应的下次到期时间。
SetNextDues(map[Rating]time.Time)
// SetDue 设置到期时间。
SetDue(time.Time)
// GetLapses 返回闪卡的遗忘次数。
GetLapses() int
// GetReps 返回闪卡的复习次数。
GetReps() int
// GetState 返回闪卡状态。
GetState() State
// GetLastReview 返回闪卡的最后复习时间。
GetLastReview() time.Time
// Clone 返回闪卡的克隆。
Clone() Card
// Impl 返回具体的闪卡实现。
Impl() interface{}
// SetImpl 设置具体的闪卡实现。
SetImpl(c interface{})
}
// BaseCard 描述了基础的闪卡实现。
type BaseCard struct {
CID string
BID string
NDues map[Rating]time.Time
}
func (card *BaseCard) NextDues() map[Rating]time.Time {
return card.NDues
}
func (card *BaseCard) SetNextDues(dues map[Rating]time.Time) {
card.NDues = dues
}
func (card *BaseCard) ID() string {
return card.CID
}
func (card *BaseCard) BlockID() string {
return card.BID
}