WeightWager New Quiz Implementation Plan
🎯 Overview
This document outlines the complete implementation plan for the new comprehensive onboarding quiz flow, designed to provide detailed health assessments and viral shareable results.
📋 Implementation Phases
Phase 1: Database Schema Migration (Week 1)
#### 1.1 Safe Migration Strategy
- ✅ Backup Strategy: Create backup tables before any changes
- ✅ Additive Changes: Only ADD new fields, never remove existing ones
- ✅ Rollback Capability: Function to rollback changes if needed
#### 1.2 Files Created
- `src/utils/migration-new-quiz-schema.sql` - Complete migration script
- `src/utils/new-quiz-questions.js` - New question configuration
- `src/components/DetailedHealthResults.tsx` - Results display component
#### 1.3 Database Changes
```sql
-- New fields added to health_quiz_data table:
- self_ranking_guess (pre-quiz self-assessment)
- date_of_birth (replaces age)
- mile_time_minutes, max_running_distance_miles, hundred_meter_time_seconds
- pull_ups_count, push_ups_count, sit_ups_count
- shoulder_circumference_inches, wrist_circumference_inches
- body_composition_score, activity_level_score, lifestyle_habits_score, sleep_quality_score, overall_health_index
-- New table: detailed_health_results
- Complete results breakdown with national comparisons
- Personalized insights and recommendations
- Shareable content generation
```
Phase 2: Question Flow Implementation (Week 1-2)
#### 2.1 New Question Structure
- Pre-Assessment: Self-ranking question
- Section 1: Demographics (DOB, sex, height, weight, ethnicity)
- Section 2: Strength & Endurance (mile time, running distance, 100m, 1RM lifts, bodyweight exercises)
- Section 3: Body Measurements (waist, body fat, shoulder, wrist circumference)
- Section 4: Lifestyle & Health (steps, exercise, sleep, smoking, alcohol, calorie tracking)
- Account: Email only (no password required)
- Results: Detailed health assessment
#### 2.2 Question Types
- `date` - Date of birth input
- `number` - Numeric inputs with validation
- `select` - Single choice options
- `email` - Email validation
- `results` - Results display screen
#### 2.3 Files to Update
- `src/app/onboarding/page.tsx` - Replace questions array
- `src/hooks/useHealthQuiz.ts` - Update data handling
- `src/utils/supabaseClient.ts` - Update database operations
Phase 3: Enhanced Health Scoring (Week 2)
#### 3.1 New Scoring Algorithm
```javascript
// Category-based scoring with national comparisons
const healthScoreWeights = {
bodyComposition: 0.40, // 40%
activityLevel: 0.25, // 25%
lifestyleHabits: 0.15, // 15%
sleepQuality: 0.20 // 20%
};
```
#### 3.2 National Averages Integration
Based on CDC/NHANES 2023-2024 data:
- Height: Male 5'9", Female 5'4"
- Weight: Male 198 lbs, Female 171 lbs
- BMI: Male 29.1, Female 29.6
- Waist: Male 40.5", Female 38.7"
- Steps: 4,800 per day average
- Alcohol: 4 drinks per week average
#### 3.3 Scoring Functions
- `calculateBodyCompositionScore()` - BMI, waist-to-height ratio, body fat
- `calculateActivityLevelScore()` - Steps, exercise frequency, strength metrics
- `calculateLifestyleHabitsScore()` - Smoking, alcohol, health conditions
- `calculateSleepQualityScore()` - Sleep duration and consistency
Phase 4: Results Page Redesign (Week 2-3)
#### 4.1 Results Components
- Executive Summary - Overall percentile and category breakdown
- Category Breakdown Table - Detailed scores vs national averages
- National Comparisons - How user compares to average American
- Detailed Insights - Category-specific analysis and recommendations
- Improvement Tips - Personalized next steps
- Shareable Content - Social media ready results
#### 4.2 Results Format
Exact format as specified in onboarding-quiz.md:
- Executive summary with percentile ranking
- Category breakdown table with scores and verdicts
- National comparison charts
- Detailed insights for each category
- Personalized improvement recommendations
- Shareable social media content
Phase 5: Analytics & Testing (Week 3)
#### 5.1 Enhanced Analytics Tracking
```javascript
// New analytics events
track('Pre-Quiz Self-Assessment', { selfRanking: data.selfRankingGuess });
track('Quiz Section Completed', { section: 'demographics|strength|measurements|lifestyle' });
track('Detailed Results Generated', { overallScore: results.overallHealthIndex });
track('Results Shared', { platform: 'social|email|link' });
```
#### 5.2 Testing Strategy
- Unit Tests: Individual scoring functions
- Integration Tests: Complete quiz flow
- User Testing: A/B test new vs old flow
- Performance Testing: Database query optimization
🛠️ Technical Implementation
Database Migration Steps
1.
Backup existing data2.
Run migration script (`migration-new-quiz-schema.sql`)
3.
Verify data integrity4.
Test new functionality5.
Deploy to productionCode Changes Required
1.
Update questions array in onboarding page
2.
Modify data handling in useHealthQuiz hook
3.
Implement new scoring algorithm4.
Create results components5.
Update analytics trackingData Safety Measures
- ✅ Backup tables created before any changes
- ✅ Additive schema changes only
- ✅ Rollback function available
- ✅ Data validation on all new fields
- ✅ Existing data preserved completely
📊 Expected Outcomes
User Experience
- More engaging quiz with comprehensive health assessment
- Detailed results with national comparisons
- Shareable content for viral growth
- No password requirement for easier signup
Analytics Benefits
- Detailed conversion tracking through each section
- Drop-off analysis at each question
- Health score distribution insights
Business Impact
- Higher engagement with detailed health insights
- Viral sharing potential with shareable results
- Better user segmentation based on health scores
- Improved conversion rates with no password barrier
🚀 Deployment Strategy
Phase 1: Development
- [ ] Run database migration in development
- [ ] Test new question flow
- [ ] Verify data integrity
- [ ] Test scoring algorithm
Phase 2: Staging
- [ ] Deploy to staging environment
- [ ] Test complete user flow
- [ ] Verify analytics tracking
Phase 3: Production
- [ ] Backup production database
- [ ] A/B test with existing flow
📈 Success Metrics
Technical Metrics
- Database migration success (100% data preservation)
- Quiz completion rate (target: >80%)
- Results sharing rate (target: >30%)
- Page load performance (<2 seconds)
Business Metrics
- Signup conversion rate (target: +25% improvement)
- User engagement (time spent on results page)
- Viral coefficient (shares per user)
- Health score distribution (user segmentation)
🔧 Rollback Plan
If issues arise:
1. Stop new user registrations
2. Run rollback function: `SELECT rollback_quiz_migration();`
3. Revert code to previous version
4. Restore from backup tables if needed
5. Investigate and fix issues
6. Re-deploy when ready
---
Last Updated: January 2025
Status: Ready for Implementation
Next Steps: Begin Phase 1 - Database Migration