#!/usr/bin/env python3 """ quiXzoom Academy — Bygg alla lektioner med SVG-illustrationer """ import json import os from pathlib import Path # Ladda innehåll with open('academy-lessons-content.json', 'r', encoding='utf-8') as f: data = json.load(f) # SVG-illustrationer för varje lektion SVG_ILLUSTRATIONS = { 'm1l1': ''' 📸 Välkommen till quiXzoom Bli en mästerlig Zoomer ''', 'm2l1': ''' 📷 Original 🤖 AI-analys Skärpa ✓ Ljus ✓ ''', 'm2l2': ''' 🌑 För mörk ☀️ Perfekt 💡 För ljus ''', 'm2l3': ''' 😵‍💫 Oskarp Skarp ''', 'm2l4': ''' 🌉 Huvudobjekt ''', 'm3l1': ''' 📱 🛰️ 🛰️ Noggrann ✓ ''', 'm4l1': ''' 👷 📱 Säkert avstånd 🚗 ''', 'm5l1': ''' A B C D 🚴 ''', 'm6l1': ''' 📸 Godkänd 🤖 AI-granskning Godkännande 💰 Utbetalning ''' } # Standard SVG för lektioner utan specifik illustration DEFAULT_SVG = ''' 📚 quiXzoom Academy ''' def generate_content_html(lesson_data): """Generera HTML-innehåll för en lektion""" content = lesson_data['content'] html_parts = [] # Intro if 'intro' in content: html_parts.append(f'
\n

{content["intro"]}

\n
') # Tips 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
') # Requirements if 'requirements' in content: req_html = '\n'.join([f'
  • {req}
  • ' for req in content['requirements']]) html_parts.append(f'
    \n

    Vad du behöver

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

    Steg för steg

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

    Viktiga faktorer

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

    • {example}

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

    Exempel

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

    Bästa praxis

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

    Vanliga fel

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

    Lösningar

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

    Säkerhetsregler

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

    Regler

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

    Strategier

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

    Nivåer

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

    Utbetalningar

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

    Avdrag du kan göra

    \n\n
    ') # Warning if 'warning' in content: html_parts.append(f'
    \n⚠️ Viktigt\n

    {content["warning"]}

    \n
    ') # Quiz 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): """Generera komplett HTML för en lektion""" # Navigation if prev_lesson: prev_link = f'/academy/{prev_lesson["module_id"]}/{prev_lesson["id"]}' prev_text = 'Föregående' else: prev_link = '/academy' prev_text = 'Tillbaka till Academy' if next_lesson: next_link = f'/academy/{next_lesson["module_id"]}/{next_lesson["id"]}' next_text = f'Nästa: {next_lesson["title"]}' else: next_link = '/academy' next_text = 'Tillbaka till Academy' # SVG illustration svg = SVG_ILLUSTRATIONS.get(lesson['id'], DEFAULT_SVG) # Content content_html = generate_content_html(lesson) # Bygg HTML 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(): """Generera alla lektioner""" print("🚀 Genererar quiXzoom Academy med SVG-illustrationer...") print("=" * 60) output_dir = Path('academy-final') 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) # Hitta föregående och nästa lektion 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'] } # Generera HTML html = generate_lesson_html(module, lesson, prev_lesson, next_lesson) # Spara 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} lektioner genererade med SVG-illustrationer!") print(f"📁 Sparade i academy-final/") return total_lessons if __name__ == "__main__": main()