Documentation
¶
Overview ¶
Package progress implements mastery scoring, SM-2 spaced repetition, streaks, and XP tracking.
Index ¶
- Constants
- func DeltaToQuality(delta float64) int
- func FormatProgressBar(score float64, width int) string
- func FormatProgressReport(items []ProgressItem, totalXP int, streak int) string
- func IsMastered(score float64) bool
- func IsStreakMilestone(days int) bool
- func StreakMilestoneMessage(days int) string
- type MemoryStreakTracker
- type MemoryTracker
- func (m *MemoryTracker) GetAllProgress(userID string) ([]ProgressItem, error)
- func (m *MemoryTracker) GetDueReviews(userID string) ([]ProgressItem, error)
- func (m *MemoryTracker) GetMastery(userID, syllabusID, topicID string) (float64, error)
- func (m *MemoryTracker) ResetAll(userID string) error
- func (m *MemoryTracker) SetMastery(userID, syllabusID, topicID string, score float64) error
- func (m *MemoryTracker) UpdateMastery(userID, syllabusID, topicID string, delta float64) error
- type MemoryXPTracker
- type PostgresTracker
- func (p *PostgresTracker) GetAllProgress(userID string) ([]ProgressItem, error)
- func (p *PostgresTracker) GetDueReviews(userID string) ([]ProgressItem, error)
- func (p *PostgresTracker) GetMastery(userID, syllabusID, topicID string) (float64, error)
- func (p *PostgresTracker) SetMastery(userID, syllabusID, topicID string, score float64) error
- func (p *PostgresTracker) UpdateMastery(userID, syllabusID, topicID string, delta float64) error
- type ProgressItem
- type SM2Result
- type Streak
- type StreakTracker
- type Tracker
- type XPEntry
- type XPSource
- type XPTracker
Constants ¶
const ( XPSession = 10 // per teaching session message exchange XPQuizCorrect = 20 // per correct quiz answer XPMasteryUp = 50 // when mastery threshold crossed for a topic XPStreakMilestone = 100 // on streak milestones (3, 7, 14, 30, etc.) XPChallengeWin = 30 // winning a peer challenge XPReviewCompleted = 50 // completing post-challenge review )
XP award amounts.
const MasteryThreshold = 0.75
MasteryThreshold is the score at or above which a topic is considered mastered.
Variables ¶
This section is empty.
Functions ¶
func DeltaToQuality ¶
DeltaToQuality converts a mastery delta (0.0-1.0) to an SM-2 quality rating (0-5).
func FormatProgressBar ¶
FormatProgressBar creates a Unicode progress bar.
func FormatProgressReport ¶
func FormatProgressReport(items []ProgressItem, totalXP int, streak int) string
FormatProgressReport creates a text report of all progress items.
func IsMastered ¶
IsMastered returns true if the score meets or exceeds MasteryThreshold.
func IsStreakMilestone ¶
IsStreakMilestone returns true if the streak count is a milestone worth celebrating.
func StreakMilestoneMessage ¶
StreakMilestoneMessage returns a celebration message for milestone streaks.
Types ¶
type MemoryStreakTracker ¶
type MemoryStreakTracker struct {
// contains filtered or unexported fields
}
MemoryStreakTracker is an in-memory implementation for testing.
func NewMemoryStreakTracker ¶
func NewMemoryStreakTracker() *MemoryStreakTracker
NewMemoryStreakTracker creates a new in-memory streak tracker.
func (*MemoryStreakTracker) GetStreak ¶
func (t *MemoryStreakTracker) GetStreak(userID string) (Streak, error)
func (*MemoryStreakTracker) RecordActivity ¶
func (t *MemoryStreakTracker) RecordActivity(userID string, at time.Time) error
func (*MemoryStreakTracker) ResetAll ¶
func (t *MemoryStreakTracker) ResetAll(userID string) error
ResetAll removes all streak data for a user.
type MemoryTracker ¶
type MemoryTracker struct {
// contains filtered or unexported fields
}
MemoryTracker is an in-memory implementation of Tracker for testing and development.
func NewMemoryTracker ¶
func NewMemoryTracker() *MemoryTracker
NewMemoryTracker creates a new in-memory tracker.
func (*MemoryTracker) GetAllProgress ¶
func (m *MemoryTracker) GetAllProgress(userID string) ([]ProgressItem, error)
func (*MemoryTracker) GetDueReviews ¶
func (m *MemoryTracker) GetDueReviews(userID string) ([]ProgressItem, error)
func (*MemoryTracker) GetMastery ¶
func (m *MemoryTracker) GetMastery(userID, syllabusID, topicID string) (float64, error)
func (*MemoryTracker) ResetAll ¶
func (m *MemoryTracker) ResetAll(userID string) error
ResetAll removes all progress data for a user.
func (*MemoryTracker) SetMastery ¶
func (m *MemoryTracker) SetMastery(userID, syllabusID, topicID string, score float64) error
SetMastery directly sets a topic's mastery score (dev/testing only).
func (*MemoryTracker) UpdateMastery ¶
func (m *MemoryTracker) UpdateMastery(userID, syllabusID, topicID string, delta float64) error
type MemoryXPTracker ¶
type MemoryXPTracker struct {
// contains filtered or unexported fields
}
MemoryXPTracker is an in-memory implementation for testing.
func NewMemoryXPTracker ¶
func NewMemoryXPTracker() *MemoryXPTracker
NewMemoryXPTracker creates a new in-memory XP tracker.
func (*MemoryXPTracker) ResetAll ¶
func (t *MemoryXPTracker) ResetAll(userID string) error
ResetAll removes all XP entries for a user.
type PostgresTracker ¶
type PostgresTracker struct {
// contains filtered or unexported fields
}
PostgresTracker is a PostgreSQL-backed implementation of Tracker.
func NewPostgresTracker ¶
func NewPostgresTracker(pool *pgxpool.Pool, tenantID string) *PostgresTracker
NewPostgresTracker creates a new PostgreSQL-backed tracker. tenantID is the UUID of the tenant for row-level isolation.
func (*PostgresTracker) GetAllProgress ¶
func (p *PostgresTracker) GetAllProgress(userID string) ([]ProgressItem, error)
func (*PostgresTracker) GetDueReviews ¶
func (p *PostgresTracker) GetDueReviews(userID string) ([]ProgressItem, error)
func (*PostgresTracker) GetMastery ¶
func (p *PostgresTracker) GetMastery(userID, syllabusID, topicID string) (float64, error)
func (*PostgresTracker) SetMastery ¶
func (p *PostgresTracker) SetMastery(userID, syllabusID, topicID string, score float64) error
SetMastery directly sets a topic's mastery score (dev/testing only).
func (*PostgresTracker) UpdateMastery ¶
func (p *PostgresTracker) UpdateMastery(userID, syllabusID, topicID string, delta float64) error
type ProgressItem ¶
type ProgressItem struct {
UserID string
SyllabusID string
TopicID string
MasteryScore float64
EaseFactor float64
IntervalDays int
Repetitions int
NextReviewAt time.Time
LastStudied time.Time
}
ProgressItem represents a student's progress on a single topic.
type Streak ¶
type Streak struct {
UserID string
CurrentStreak int
LongestStreak int
LastActiveDate time.Time // truncated to date
}
Streak holds a user's streak data.
type StreakTracker ¶
type StreakTracker interface {
RecordActivity(userID string, at time.Time) error
GetStreak(userID string) (Streak, error)
}
StreakTracker defines the interface for streak tracking.
type Tracker ¶
type Tracker interface {
UpdateMastery(userID, syllabusID, topicID string, delta float64) error
GetMastery(userID, syllabusID, topicID string) (float64, error)
GetAllProgress(userID string) ([]ProgressItem, error)
GetDueReviews(userID string) ([]ProgressItem, error)
}
Tracker defines the interface for mastery progress tracking.