All files / web/src/app/create/worksheets techniques.ts

0% Statements 0/191
0% Branches 0/1
0% Functions 0/1
0% Lines 0/191

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                                                                                                                                                                                                                                                                                                                                                                                               
// Core mathematical techniques for mastery progression
// Techniques are actual skills (carrying, borrowing), not complexity levels

import type { DisplayRules } from './displayRules'

/**
 * Technique IDs
 * These represent actual mathematical procedures/algorithms to learn
 */
export type TechniqueId =
  // Addition Techniques
  | 'basic-addition' // No carrying required
  | 'single-carry' // Carrying in one place value
  | 'multi-carry' // Carrying across multiple place values

  // Subtraction Techniques
  | 'basic-subtraction' // No borrowing required
  | 'single-borrow' // Borrowing from one place value
  | 'multi-borrow' // Borrowing across multiple place values

/**
 * A mathematical technique that can be learned and mastered
 */
export interface Technique {
  id: TechniqueId
  name: string
  description: string
  operator: 'addition' | 'subtraction'

  // What OTHER techniques must be mastered first?
  prerequisites: TechniqueId[]

  // Recommended scaffolding for this technique (baseline)
  // Complexity levels can adjust these
  recommendedScaffolding: Partial<DisplayRules>

  // Which techniques should be reviewed when practicing this one?
  recommendedReview: TechniqueId[]
}

/**
 * All techniques in the learning progression
 */
export const TECHNIQUES: Record<TechniqueId, Technique> = {
  // ============================================================================
  // ADDITION TECHNIQUES
  // ============================================================================

  'basic-addition': {
    id: 'basic-addition',
    name: 'Basic Addition',
    description: 'Simple addition without carrying (no regrouping)',
    operator: 'addition',
    prerequisites: [],
    recommendedScaffolding: {
      carryBoxes: 'never', // No carrying, so no carry boxes needed
      answerBoxes: 'always',
      placeValueColors: 'always',
      tenFrames: 'never', // Ten-frames for regrouping visualization
      problemNumbers: 'always',
      cellBorders: 'always',
      borrowNotation: 'never',
      borrowingHints: 'never',
    },
    recommendedReview: [],
  },

  'single-carry': {
    id: 'single-carry',
    name: 'Single-place Carrying',
    description: 'Addition with carrying (regrouping) in one place value',
    operator: 'addition',
    prerequisites: ['basic-addition'],
    recommendedScaffolding: {
      carryBoxes: 'whenRegrouping', // Show carry boxes when carrying happens
      answerBoxes: 'always',
      placeValueColors: 'always',
      tenFrames: 'whenRegrouping', // Help visualize making ten
      problemNumbers: 'always',
      cellBorders: 'always',
      borrowNotation: 'never',
      borrowingHints: 'never',
    },
    recommendedReview: ['basic-addition'],
  },

  'multi-carry': {
    id: 'multi-carry',
    name: 'Multi-place Carrying',
    description: 'Addition with carrying across multiple place values',
    operator: 'addition',
    prerequisites: ['single-carry'],
    recommendedScaffolding: {
      carryBoxes: 'whenRegrouping',
      answerBoxes: 'always',
      placeValueColors: 'always',
      tenFrames: 'never', // Less scaffolding for advanced students
      problemNumbers: 'always',
      cellBorders: 'always',
      borrowNotation: 'never',
      borrowingHints: 'never',
    },
    recommendedReview: ['single-carry', 'basic-addition'],
  },

  // ============================================================================
  // SUBTRACTION TECHNIQUES
  // ============================================================================

  'basic-subtraction': {
    id: 'basic-subtraction',
    name: 'Basic Subtraction',
    description: 'Simple subtraction without borrowing (no regrouping)',
    operator: 'subtraction',
    prerequisites: ['basic-addition'], // Addition first
    recommendedScaffolding: {
      carryBoxes: 'never',
      answerBoxes: 'always',
      placeValueColors: 'always',
      tenFrames: 'never',
      problemNumbers: 'always',
      cellBorders: 'always',
      borrowNotation: 'never', // No borrowing, so no notation needed
      borrowingHints: 'never',
    },
    recommendedReview: ['basic-addition'],
  },

  'single-borrow': {
    id: 'single-borrow',
    name: 'Single-place Borrowing',
    description: 'Subtraction with borrowing (regrouping) from one place value',
    operator: 'subtraction',
    prerequisites: ['basic-subtraction', 'single-carry'], // Need to understand regrouping concept
    recommendedScaffolding: {
      carryBoxes: 'never',
      answerBoxes: 'always',
      placeValueColors: 'always',
      tenFrames: 'whenRegrouping', // Help visualize breaking apart ten
      problemNumbers: 'always',
      cellBorders: 'always',
      borrowNotation: 'whenRegrouping', // Show scratch work for borrowing
      borrowingHints: 'never', // Start without hints, can add later
    },
    recommendedReview: ['basic-subtraction', 'single-carry'],
  },

  'multi-borrow': {
    id: 'multi-borrow',
    name: 'Multi-place Borrowing',
    description: 'Subtraction with borrowing across multiple place values',
    operator: 'subtraction',
    prerequisites: ['single-borrow'],
    recommendedScaffolding: {
      carryBoxes: 'never',
      answerBoxes: 'always',
      placeValueColors: 'always',
      tenFrames: 'never',
      problemNumbers: 'always',
      cellBorders: 'always',
      borrowNotation: 'whenRegrouping',
      borrowingHints: 'never',
    },
    recommendedReview: ['single-borrow', 'basic-subtraction'],
  },
}

/**
 * Get technique by ID
 */
export function getTechnique(id: TechniqueId): Technique {
  return TECHNIQUES[id]
}

/**
 * Get all techniques for an operator
 */
export function getTechniquesByOperator(operator: 'addition' | 'subtraction'): Technique[] {
  return Object.values(TECHNIQUES).filter((t) => t.operator === operator)
}

/**
 * Check if technique prerequisites are met
 */
export function arePrerequisitesMet(
  techniqueId: TechniqueId,
  masteredTechniques: Set<TechniqueId>
): boolean {
  const technique = TECHNIQUES[techniqueId]
  return technique.prerequisites.every((prereq) => masteredTechniques.has(prereq))
}