All files / web/scripts generateBlogExamples.ts

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

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                                                                                                                                                                                                                                                                               
// Script to generate example worksheet images for the blog post
// Shows different scaffolding levels for the 2D difficulty blog post

import fs from 'fs'
import path from 'path'
import { generateWorksheetPreview } from '../src/app/create/worksheets/generatePreview'
import { DIFFICULTY_PROFILES } from '../src/app/create/worksheets/difficultyProfiles'

// Output directory
const outputDir = path.join(process.cwd(), 'public', 'blog', 'difficulty-examples')

// Ensure output directory exists
if (!fs.existsSync(outputDir)) {
  fs.mkdirSync(outputDir, { recursive: true })
}

// Generate examples with SAME regrouping level but different scaffolding
// This clearly shows how scaffolding changes while keeping problem complexity constant
const examples = [
  {
    name: 'full-scaffolding',
    filename: 'full-scaffolding.svg',
    description: 'Full Scaffolding: Maximum visual support',
    // Use medium regrouping with full scaffolding
    config: {
      pAllStart: 0.3,
      pAnyStart: 0.7,
      displayRules: {
        carryBoxes: 'always' as const,
        answerBoxes: 'always' as const,
        placeValueColors: 'always' as const,
        tenFrames: 'always' as const,
        problemNumbers: 'always' as const,
        cellBorders: 'always' as const,
        borrowNotation: 'never' as const,
        borrowingHints: 'never' as const,
      },
    },
  },
  {
    name: 'medium-scaffolding',
    filename: 'medium-scaffolding.svg',
    description: 'Medium Scaffolding: Strategic support',
    config: {
      pAllStart: 0.3,
      pAnyStart: 0.7,
      displayRules: {
        carryBoxes: 'whenRegrouping' as const,
        answerBoxes: 'always' as const,
        placeValueColors: 'when3PlusDigits' as const,
        tenFrames: 'never' as const,
        problemNumbers: 'always' as const,
        cellBorders: 'always' as const,
        borrowNotation: 'never' as const,
        borrowingHints: 'never' as const,
      },
    },
  },
  {
    name: 'minimal-scaffolding',
    filename: 'minimal-scaffolding.svg',
    description: 'Minimal Scaffolding: Carry boxes only',
    config: {
      pAllStart: 0.3,
      pAnyStart: 0.7,
      displayRules: {
        carryBoxes: 'whenMultipleRegroups' as const,
        answerBoxes: 'never' as const,
        placeValueColors: 'never' as const,
        tenFrames: 'never' as const,
        problemNumbers: 'always' as const,
        cellBorders: 'always' as const,
        borrowNotation: 'never' as const,
        borrowingHints: 'never' as const,
      },
    },
  },
  {
    name: 'no-scaffolding',
    filename: 'no-scaffolding.svg',
    description: 'No Scaffolding: Students work independently',
    config: {
      pAllStart: 0.3,
      pAnyStart: 0.7,
      displayRules: {
        carryBoxes: 'never' as const,
        answerBoxes: 'never' as const,
        placeValueColors: 'never' as const,
        tenFrames: 'never' as const,
        problemNumbers: 'always' as const,
        cellBorders: 'always' as const,
        borrowNotation: 'never' as const,
        borrowingHints: 'never' as const,
      },
    },
  },
] as const

console.log('Generating blog example worksheets...\n')

for (const example of examples) {
  console.log(`Generating ${example.description}...`)

  const config = {
    pAllStart: example.config.pAllStart,
    pAnyStart: example.config.pAnyStart,
    displayRules: example.config.displayRules,
    problemsPerPage: 4,
    pages: 1,
    cols: 2,
  }

  try {
    const result = await generateWorksheetPreview(config)

    if (!result.success || !result.pages || result.pages.length === 0) {
      console.error(`Failed to generate ${example.name}:`, result.error)
      continue
    }

    // Get the first page's SVG
    const svg = result.pages[0]

    // Save to file
    const outputPath = path.join(outputDir, example.filename)
    fs.writeFileSync(outputPath, svg, 'utf-8')

    console.log(`  ✓ Saved to ${outputPath}`)
  } catch (error) {
    console.error(`  ✗ Error generating ${example.name}:`, error)
  }
}

console.log('\nDone! Example worksheets generated.')
console.log(`\nFiles saved to: ${outputDir}`)