#!/usr/bin/env python3 """ quiXzoom Academy — English version builder """ import json import os from pathlib import Path # Load English content with open('academy-content-en.json', 'r', encoding='utf-8') as f: data = json.load(f) # SVG illustrations (same as Swedish) SVG_ILLUSTRATIONS = { 'm1l1': ''' šŸ“ø Welcome to quiXzoom Become a Master Zoomer ''', 'm2l1': ''' šŸ“· Original → šŸ¤– AI Analysis ''', 'm2l2': ''' šŸŒ‘ Too Dark ā˜€ļø Perfect šŸ’” Too Bright ''', 'm2l3': ''' šŸ˜µā€šŸ’« Blurry ✨ Sharp ''', 'm2l4': ''' šŸŒ‰ Main Subject ''', 'm3l1': ''' šŸ“± šŸ›°ļø šŸ›°ļø Accurate āœ“ ''', 'm4l1': ''' šŸ‘· šŸ“± Safe Distance šŸš— ''', 'm5l1': ''' A B C D 🚓 ''', 'm6l1': ''' šŸ“ø Approved → šŸ¤– AI Review → āœ“ Approval → šŸ’° Payout ''' } DEFAULT_SVG = ''' šŸ“š quiXzoom Academy ''' def generate_content_html(lesson_data): """Generate HTML content for a lesson""" content = lesson_data['content'] html_parts = [] if 'intro' in content: html_parts.append(f'
\n

{content["intro"]}

\n
') if 'tips' in content: tips_html = '\n'.join([f'

• {tip}

' for tip in content['tips']]) html_parts.append(f'
\nšŸ’” Tips\n{tips_html}\n
') if 'requirements' in content: req_html = '\n'.join([f'
  • {req}
  • ' for req in content['requirements']]) html_parts.append(f'
    \n

    What You Need

    \n\n
    ') if 'steps' in content: steps_html = '\n'.join([f'
  • Step {i+1}: {step}
  • ' for i, step in enumerate(content['steps'])]) html_parts.append(f'
    \n

    Step by Step

    \n
      \n{steps_html}\n
    \n
    ') if 'factors' in content: factors_html = '\n'.join([f'
  • {factor}
  • ' for factor in content['factors']]) html_parts.append(f'
    \n

    Key Factors

    \n\n
    ') if 'examples' in content: examples_html = '\n'.join([f'

    • {example}

    ' for example in content['examples']]) html_parts.append(f'
    \n

    Example

    \n{examples_html}\n
    ') if 'best_practices' in content: bp_html = '\n'.join([f'
  • {bp}
  • ' for bp in content['best_practices']]) html_parts.append(f'
    \n

    Best Practices

    \n\n
    ') if 'common_errors' in content: errors_html = '\n'.join([f'
  • {error}
  • ' for error in content['common_errors']]) html_parts.append(f'
    \n

    Common Errors

    \n\n
    ') if 'solutions' in content: sol_html = '\n'.join([f'
  • {sol}
  • ' for sol in content['solutions']]) html_parts.append(f'
    \n

    Solutions

    \n\n
    ') if 'safety_rules' in content: rules_html = '\n'.join([f'
  • {rule}
  • ' for rule in content['safety_rules']]) html_parts.append(f'
    \n

    Safety Rules

    \n\n
    ') if 'rules' in content: rules_html = '\n'.join([f'
  • {rule}
  • ' for rule in content['rules']]) html_parts.append(f'
    \n

    Rules

    \n\n
    ') if 'strategies' in content: strat_html = '\n'.join([f'
  • {strat}
  • ' for strat in content['strategies']]) html_parts.append(f'
    \n

    Strategies

    \n\n
    ') if 'levels' in content: levels_html = '\n'.join([f'
  • {level}
  • ' for level in content['levels']]) html_parts.append(f'
    \n

    Levels

    \n\n
    ') if 'payment_schedule' in content: pay_html = '\n'.join([f'
  • {pay}
  • ' for pay in content['payment_schedule']]) html_parts.append(f'
    \n

    Payments

    \n\n
    ') if 'deductions' in content: ded_html = '\n'.join([f'
  • {ded}
  • ' for ded in content['deductions']]) html_parts.append(f'
    \n

    Deductions You Can Claim

    \n\n
    ') if 'warning' in content: html_parts.append(f'
    \nāš ļø Important\n

    {content["warning"]}

    \n
    ') if 'quiz' in content: quiz = content['quiz'] options_html = '\n'.join([ f'
  • \n{chr(65+i)}\n{opt}\n
  • ' for i, opt in enumerate(quiz['options']) ]) html_parts.append(f'''
    {quiz['question']}
    ''') return '\n\n'.join(html_parts) def generate_lesson_html(module, lesson, prev_lesson, next_lesson): """Generate complete HTML for a lesson""" if prev_lesson: prev_link = f'/academy/{prev_lesson["module_id"]}/{prev_lesson["id"]}' prev_text = 'Previous' else: prev_link = '/academy' prev_text = 'Back to Academy' if next_lesson: next_link = f'/academy/{next_lesson["module_id"]}/{next_lesson["id"]}' next_text = f'Next: {next_lesson["title"]}' else: next_link = '/academy' next_text = 'Back to Academy' svg = SVG_ILLUSTRATIONS.get(lesson['id'], DEFAULT_SVG) content_html = generate_content_html(lesson) html = f''' {lesson['title']} — quiXzoom Academy
    {module['title']} — {module['description']}

    {lesson['title']}

    ā±ļø {lesson['duration']} šŸŽÆ {module['level']} šŸ“š {lesson['type']}
    {svg} {content_html}
    ''' return html def main(): """Generate all English lessons""" print("šŸš€ Generating English quiXzoom Academy...") print("=" * 60) output_dir = Path('academy-en') output_dir.mkdir(exist_ok=True) total_lessons = 0 for module_idx, module in enumerate(data['modules']): module_dir = output_dir / module['id'] module_dir.mkdir(exist_ok=True) print(f"\nšŸ“š {module['title']}") for lesson_idx, lesson in enumerate(module['lessons']): lesson_dir = module_dir / lesson['id'] lesson_dir.mkdir(exist_ok=True) prev_lesson = None next_lesson = None if lesson_idx > 0: prev_lesson = { 'module_id': module['id'], 'id': module['lessons'][lesson_idx - 1]['id'], 'title': module['lessons'][lesson_idx - 1]['title'] } elif module_idx > 0: prev_module = data['modules'][module_idx - 1] prev_lesson = { 'module_id': prev_module['id'], 'id': prev_module['lessons'][-1]['id'], 'title': prev_module['lessons'][-1]['title'] } if lesson_idx < len(module['lessons']) - 1: next_lesson = { 'module_id': module['id'], 'id': module['lessons'][lesson_idx + 1]['id'], 'title': module['lessons'][lesson_idx + 1]['title'] } elif module_idx < len(data['modules']) - 1: next_module = data['modules'][module_idx + 1] next_lesson = { 'module_id': next_module['id'], 'id': next_module['lessons'][0]['id'], 'title': next_module['lessons'][0]['title'] } html = generate_lesson_html(module, lesson, prev_lesson, next_lesson) with open(lesson_dir / 'index.html', 'w', encoding='utf-8') as f: f.write(html) total_lessons += 1 print(f" āœ… {lesson['id']}: {lesson['title']}") print(f"\n{'=' * 60}") print(f"āœ… {total_lessons} English lessons generated!") print(f"šŸ“ Saved in academy-en/") return total_lessons if __name__ == "__main__": main()