#!/bin/bash # Math Teacher - Interactive Playground Generator # Creates instant, interactive math learning experiences set -e # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' NC='\033[0m' # Helper functions print_success() { echo -e "${GREEN}✓ $1${NC}" } print_error() { echo -e "${RED}✗ $1${NC}" } print_info() { echo -e "${BLUE}ℹ $1${NC}" } print_warning() { echo -e "${YELLOW}⚠ $1${NC}" } prompt_input() { local prompt="$1" local var_name="$2" local required="${3:-false}" while true; do echo -e "${BLUE}${prompt}${NC}" read -r input if [ -z "$input" ] && [ "$required" = true ]; then print_error "This field is required." continue fi eval "$var_name='$input'" break done } prompt_select() { local prompt="$1" local var_name="$2" shift 2 local options=("$@") echo -e "${BLUE}${prompt}${NC}" PS3="Select (1-${#options[@]}): " select opt in "${options[@]}"; do if [ -n "$opt" ]; then eval "$var_name='$opt'" break else print_error "Invalid selection. Try again." fi done } # Banner echo "" echo "╔════════════════════════════════════════════════════════════╗" echo "║ ║" echo "║ Math Teacher - Playground Generator 🎮 ║" echo "║ ║" echo "╚════════════════════════════════════════════════════════════╝" echo "" # Step 1: Math Topic Level print_info "Step 1/5: Choose Math Level" prompt_select "What level?" LEVEL \ "Elementary (Ages 6-12)" \ "Middle School (Ages 12-15)" \ "High School (Ages 15-18)" \ "Advanced (College+)" # Step 2: Specific Topic print_info "Step 2/5: Choose Topic" case $LEVEL in "Elementary (Ages 6-12)") prompt_select "Which topic?" TOPIC \ "Fractions" \ "Multiplication Table" \ "Geometry Shapes" \ "Number Patterns" \ "Time & Clock" \ "Money & Change" ;; "Middle School (Ages 12-15)") prompt_select "Which topic?" TOPIC \ "Linear Equations" \ "Ratios & Proportions" \ "Percentages" \ "Basic Statistics" \ "Pythagorean Theorem" \ "Order of Operations" ;; "High School (Ages 15-18)") prompt_select "Which topic?" TOPIC \ "Quadratic Functions" \ "Trigonometry" \ "Exponential Functions" \ "Logarithms" \ "Polynomial Graphs" \ "Systems of Equations" ;; "Advanced (College+)") prompt_select "Which topic?" TOPIC \ "Derivatives" \ "Integrals" \ "Limits" \ "Optimization" \ "Series & Sequences" \ "Differential Equations" ;; esac # Step 3: Interaction Type print_info "Step 3/5: Type of Experience" prompt_select "What kind of playground?" INTERACTION_TYPE \ "Visual Explorer (Manipulate and see changes)" \ "Practice Problems (Randomized with hints)" \ "Challenge Game (Timed with scoring)" \ "Concept Demo (Animated explanation)" \ "Sandbox (Open exploration)" # Step 4: Difficulty print_info "Step 4/5: Difficulty Level" prompt_select "Difficulty?" DIFFICULTY \ "Easy" \ "Medium" \ "Hard" # Step 5: Output Location print_info "Step 5/5: Save Location" prompt_input "Output file name (e.g., fractions-playground.html):" OUTPUT_FILE true OUTPUT_DIR="./math-playgrounds" mkdir -p "$OUTPUT_DIR" OUTPUT_PATH="$OUTPUT_DIR/$OUTPUT_FILE" # Generate the playground HTML echo "" print_info "🎨 Generating your interactive math playground..." echo "" # Create the HTML file based on topic case $TOPIC in "Fractions") generate_fractions_playground ;; "Quadratic Functions") generate_quadratic_playground ;; "Derivatives") generate_derivatives_playground ;; *) generate_generic_playground ;; esac # Success message echo "" echo "╔════════════════════════════════════════════════════════════╗" echo "║ 🎉 Success! ║" echo "╚════════════════════════════════════════════════════════════╝" echo "" print_success "Playground created: $OUTPUT_PATH" print_success "Topic: $TOPIC" print_success "Level: $LEVEL" print_success "Type: $INTERACTION_TYPE" echo "" print_info "🚀 Opening playground in browser..." open "$OUTPUT_PATH" echo "" print_info "💡 Playground tips:" echo " 2. Or double-click the file" echo " 3. Start learning by playing!" echo "" print_info "💡 The playground includes:" echo " ✓ Interactive visualizations" echo " ✓ Real-time feedback" echo " ✓ Gamification (points & achievements)" echo " ✓ Hints and explanations" echo " ✓ Mobile-friendly design" echo "" # Function implementations would go here # For brevity, showing one example: generate_generic_playground() { cat > "$OUTPUT_PATH" << 'EOF'