Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 89x 2x 2x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 8405x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | // Tutorial system type definitions
export interface TutorialStep {
id: string
title: string
problem: string
description: string
startValue: number
targetValue: number
highlightBeads?: Array<{
placeValue: number
beadType: 'heaven' | 'earth'
position?: number // for earth beads, 0-3
}>
// Progressive step-based highlighting with directions
stepBeadHighlights?: Array<{
placeValue: number
beadType: 'heaven' | 'earth'
position?: number // for earth beads, 0-3
stepIndex: number // Which instruction step this bead belongs to
direction: 'up' | 'down' | 'activate' | 'deactivate' // Movement direction
order?: number // Order within the step (for multiple beads per step)
}>
totalSteps?: number // Total number of instruction steps
expectedAction: 'add' | 'remove' | 'multi-step'
actionDescription: string
tooltip: {
content: string
explanation: string
}
// errorMessages removed - bead diff tooltip provides better guidance
multiStepInstructions?: string[]
position?: number // Position in unified tutorial flow
}
// Skill-based system for practice problem generation
export interface SkillSet {
// Five complements for ADDITION (single-column operations)
// e.g., +4 = +5-1 means "add 4 by adding 5 and subtracting 1"
fiveComplements: {
'4=5-1': boolean
'3=5-2': boolean
'2=5-3': boolean
'1=5-4': boolean
}
// Ten complements for ADDITION (carrying operations)
// e.g., +9 = +10-1 means "add 9 by adding 10 and subtracting 1"
tenComplements: {
'9=10-1': boolean
'8=10-2': boolean
'7=10-3': boolean
'6=10-4': boolean
'5=10-5': boolean
'4=10-6': boolean
'3=10-7': boolean
'2=10-8': boolean
'1=10-9': boolean
}
// Five complements for SUBTRACTION (single-column operations)
// e.g., -4 = -5+1 means "subtract 4 by subtracting 5 and adding 1"
fiveComplementsSub: {
'-4=-5+1': boolean
'-3=-5+2': boolean
'-2=-5+3': boolean
'-1=-5+4': boolean
}
// Ten complements for SUBTRACTION (borrowing operations)
// e.g., -9 = +1-10 means "subtract 9 by adding 1 and borrowing 10"
tenComplementsSub: {
'-9=+1-10': boolean
'-8=+2-10': boolean
'-7=+3-10': boolean
'-6=+4-10': boolean
'-5=+5-10': boolean
'-4=+6-10': boolean
'-3=+7-10': boolean
'-2=+8-10': boolean
'-1=+9-10': boolean
}
// Basic operations
basic: {
directAddition: boolean // Can add 1-4 directly
heavenBead: boolean // Can use heaven bead (5)
simpleCombinations: boolean // Can do 6-9 without complements
directSubtraction: boolean // Can subtract 1-4 directly
heavenBeadSubtraction: boolean // Can remove heaven bead (5)
simpleCombinationsSub: boolean // Can do 6-9 subtraction without complements
}
// Advanced operations involving multiple place values
advanced: {
/** Carry cascades across 2+ columns (e.g., 999 + 1 = 1000) */
cascadingCarry: boolean
/** Borrow cascades across 2+ columns (e.g., 1000 - 1 = 999) */
cascadingBorrow: boolean
}
}
export interface PracticeStep {
id: string
title: string
description: string
// Problem generation settings
problemCount: number
maxTerms: number // max numbers to add in a single problem
// Skill-based constraints
allowedSkills: SkillSet // Skills student is allowed to use (whitelist)
targetSkills?: Partial<SkillSet> // Skills to specifically practice (optional)
forbiddenSkills?: Partial<SkillSet> // Skills user hasn't learned yet (optional)
// Advanced constraints (optional)
numberRange?: { min: number; max: number }
sumConstraints?: { maxSum: number; minSum?: number }
// Legacy support for existing system
skillLevel?: 'basic' | 'heaven' | 'five-complements' | 'mixed'
// Tutorial integration
position?: number // Where in tutorial flow this appears
}
export interface Problem {
id: string
terms: number[]
userAnswer?: number
isCorrect?: boolean
}
// Utility functions for skill management
export function createEmptySkillSet(): SkillSet {
return {
basic: {
directAddition: false,
heavenBead: false,
simpleCombinations: false,
directSubtraction: false,
heavenBeadSubtraction: false,
simpleCombinationsSub: false,
},
fiveComplements: {
'4=5-1': false,
'3=5-2': false,
'2=5-3': false,
'1=5-4': false,
},
tenComplements: {
'9=10-1': false,
'8=10-2': false,
'7=10-3': false,
'6=10-4': false,
'5=10-5': false,
'4=10-6': false,
'3=10-7': false,
'2=10-8': false,
'1=10-9': false,
},
fiveComplementsSub: {
'-4=-5+1': false,
'-3=-5+2': false,
'-2=-5+3': false,
'-1=-5+4': false,
},
tenComplementsSub: {
'-9=+1-10': false,
'-8=+2-10': false,
'-7=+3-10': false,
'-6=+4-10': false,
'-5=+5-10': false,
'-4=+6-10': false,
'-3=+7-10': false,
'-2=+8-10': false,
'-1=+9-10': false,
},
advanced: {
cascadingCarry: false,
cascadingBorrow: false,
},
}
}
export function createBasicSkillSet(): SkillSet {
return {
basic: {
directAddition: true,
heavenBead: false,
simpleCombinations: false,
directSubtraction: false,
heavenBeadSubtraction: false,
simpleCombinationsSub: false,
},
fiveComplements: {
'4=5-1': false,
'3=5-2': false,
'2=5-3': false,
'1=5-4': false,
},
tenComplements: {
'9=10-1': false,
'8=10-2': false,
'7=10-3': false,
'6=10-4': false,
'5=10-5': false,
'4=10-6': false,
'3=10-7': false,
'2=10-8': false,
'1=10-9': false,
},
fiveComplementsSub: {
'-4=-5+1': false,
'-3=-5+2': false,
'-2=-5+3': false,
'-1=-5+4': false,
},
tenComplementsSub: {
'-9=+1-10': false,
'-8=+2-10': false,
'-7=+3-10': false,
'-6=+4-10': false,
'-5=+5-10': false,
'-4=+6-10': false,
'-3=+7-10': false,
'-2=+8-10': false,
'-1=+9-10': false,
},
advanced: {
cascadingCarry: false,
cascadingBorrow: false,
},
}
}
export interface Tutorial {
id: string
title: string
description: string
category: string
difficulty: 'beginner' | 'intermediate' | 'advanced'
estimatedDuration: number // in minutes
steps: TutorialStep[]
practiceSteps?: PracticeStep[]
tags: string[]
author: string
version: string
createdAt: Date
updatedAt: Date
isPublished: boolean
}
export interface TutorialProgress {
tutorialId: string
userId?: string
currentStepIndex: number
completedSteps: string[] // step ids
startedAt: Date
lastAccessedAt: Date
completedAt?: Date
score?: number
timeSpent: number // in seconds
}
export interface TutorialSession {
id: string
tutorial: Tutorial
progress: TutorialProgress
currentStep: TutorialStep
isDebugMode: boolean
debugHistory: Array<{
stepId: string
timestamp: Date
action: string
value: number
success: boolean
}>
}
// Editor specific types
export interface TutorialTemplate {
name: string
description: string
defaultSteps: Partial<TutorialStep>[]
}
export interface StepValidationError {
stepId: string
field: string
message: string
severity: 'error' | 'warning'
}
export interface TutorialValidation {
isValid: boolean
errors: StepValidationError[]
warnings: StepValidationError[]
}
// Access control types (future-ready)
export interface UserRole {
id: string
name: string
permissions: Permission[]
}
export interface Permission {
resource: 'tutorial' | 'step' | 'user' | 'system'
actions: ('create' | 'read' | 'update' | 'delete' | 'publish')[]
conditions?: Record<string, any>
}
export interface AccessContext {
userId?: string
roles: UserRole[]
isAuthenticated: boolean
isAdmin: boolean
canEdit: boolean
canPublish: boolean
canDelete: boolean
}
// Navigation and UI state types
export interface NavigationState {
currentStepIndex: number
canGoNext: boolean
canGoPrevious: boolean
totalSteps: number
completionPercentage: number
}
export interface UIState {
isPlaying: boolean
isPaused: boolean
isEditing: boolean
showDebugPanel: boolean
showStepList: boolean
autoAdvance: boolean
playbackSpeed: number
}
// Event types for tutorial interaction
export type TutorialEvent =
| { type: 'STEP_STARTED'; stepId: string; timestamp: Date }
| {
type: 'STEP_COMPLETED'
stepId: string
success: boolean
timestamp: Date
}
| { type: 'BEAD_CLICKED'; stepId: string; beadInfo: any; timestamp: Date }
| {
type: 'VALUE_CHANGED'
stepId: string
oldValue: number
newValue: number
timestamp: Date
}
| { type: 'ERROR_OCCURRED'; stepId: string; error: string; timestamp: Date }
| {
type: 'TUTORIAL_COMPLETED'
tutorialId: string
score: number
timestamp: Date
}
| {
type: 'TUTORIAL_ABANDONED'
tutorialId: string
lastStepId: string
timestamp: Date
}
// API response types
export interface TutorialListResponse {
tutorials: Tutorial[]
total: number
page: number
limit: number
hasMore: boolean
}
export interface TutorialDetailResponse {
tutorial: Tutorial
userProgress?: TutorialProgress
canEdit: boolean
canDelete: boolean
}
export interface SaveTutorialRequest {
tutorial: Omit<Tutorial, 'id' | 'createdAt' | 'updatedAt'>
}
export interface SaveTutorialResponse {
tutorial: Tutorial
validation: TutorialValidation
}
|