Files
boc/build-academy-final.py
T
Bernt aee0f09db8 landvex: Fixar och tester klara för alla komponenter
- Datafabrik: Dockerfile fix, agentorkestrering fungerar
- Vision: Identify-modell, FAISS, OCR alla testade
- API: Alla 7 integrationstester passerade
- Upplösare: Entitetsupplösning verifierad
2026-07-05 06:41:32 +00:00

720 lines
24 KiB
Python

#!/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': '''<svg class="svg-illustration" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
<defs><linearGradient id="g1" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color:#667eea"/><stop offset="100%" style="stop-color:#764ba2"/></linearGradient></defs>
<rect width="800" height="400" fill="url(#g1)"/>
<circle cx="400" cy="200" r="120" fill="rgba(255,255,255,0.1)"/>
<text x="400" y="180" text-anchor="middle" font-size="80" fill="white">📸</text>
<text x="400" y="280" text-anchor="middle" font-size="24" fill="white" font-weight="bold">Välkommen till quiXzoom</text>
<text x="400" y="310" text-anchor="middle" font-size="16" fill="rgba(255,255,255,0.8)">Bli en mästerlig Zoomer</text>
</svg>''',
'm2l1': '''<svg class="svg-illustration" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
<rect width="800" height="400" fill="#1a1a2e"/>
<rect x="50" y="50" width="300" height="300" rx="12" fill="#4facfe"/>
<text x="200" y="200" text-anchor="middle" font-size="60" fill="white">📷</text>
<text x="200" y="280" text-anchor="middle" font-size="16" fill="white">Original</text>
<text x="400" y="200" text-anchor="middle" font-size="40" fill="white">→</text>
<rect x="450" y="50" width="300" height="300" rx="12" fill="#43e97b"/>
<text x="600" y="200" text-anchor="middle" font-size="60" fill="white">🤖</text>
<text x="600" y="280" text-anchor="middle" font-size="16" fill="white">AI-analys</text>
<rect x="470" y="70" width="100" height="30" rx="15" fill="rgba(255,255,255,0.3)"/>
<text x="520" y="90" text-anchor="middle" font-size="12" fill="white">Skärpa ✓</text>
<rect x="580" y="70" width="100" height="30" rx="15" fill="rgba(255,255,255,0.3)"/>
<text x="630" y="90" text-anchor="middle" font-size="12" fill="white">Ljus ✓</text>
</svg>''',
'm2l2': '''<svg class="svg-illustration" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="266" height="400" fill="#333"/>
<text x="133" y="180" text-anchor="middle" font-size="40" fill="#666">🌑</text>
<text x="133" y="220" text-anchor="middle" font-size="16" fill="#999">För mörk</text>
<rect x="266" y="0" width="268" height="400" fill="#fff3e0"/>
<text x="400" y="180" text-anchor="middle" font-size="40" fill="#e65100">☀️</text>
<text x="400" y="220" text-anchor="middle" font-size="16" fill="#e65100">Perfekt</text>
<rect x="534" y="0" width="266" height="400" fill="#f5f5f5"/>
<text x="667" y="180" text-anchor="middle" font-size="40" fill="#ccc">💡</text>
<text x="667" y="220" text-anchor="middle" font-size="16" fill="#999">För ljus</text>
</svg>''',
'm2l3': '''<svg class="svg-illustration" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="400" height="400" fill="#ffebee"/>
<text x="200" y="180" text-anchor="middle" font-size="60" fill="#c62828">😵‍💫</text>
<text x="200" y="240" text-anchor="middle" font-size="20" fill="#c62828">Oskarp</text>
<rect x="400" y="0" width="400" height="400" fill="#e8f5e9"/>
<text x="600" y="180" text-anchor="middle" font-size="60" fill="#2e7d32">✨</text>
<text x="600" y="240" text-anchor="middle" font-size="20" fill="#2e7d32">Skarp</text>
</svg>''',
'm2l4': '''<svg class="svg-illustration" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
<rect width="800" height="400" fill="#f5f5f7"/>
<line x1="266" y1="0" x2="266" y2="400" stroke="#0066FF" stroke-width="2" stroke-dasharray="5,5"/>
<line x1="533" y1="0" x2="533" y2="400" stroke="#0066FF" stroke-width="2" stroke-dasharray="5,5"/>
<line x1="0" y1="133" x2="800" y2="133" stroke="#0066FF" stroke-width="2" stroke-dasharray="5,5"/>
<line x1="0" y1="266" x2="800" y2="266" stroke="#0066FF" stroke-width="2" stroke-dasharray="5,5"/>
<circle cx="400" cy="200" r="80" fill="#00C853" opacity="0.3"/>
<text x="400" y="190" text-anchor="middle" font-size="60" fill="#00C853">🌉</text>
<text x="400" y="260" text-anchor="middle" font-size="16" fill="#00C853" font-weight="bold">Huvudobjekt</text>
</svg>''',
'm3l1': '''<svg class="svg-illustration" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
<rect width="800" height="400" fill="#e3f2fd"/>
<line x1="0" y1="100" x2="800" y2="100" stroke="#bbdefb" stroke-width="1"/>
<line x1="0" y1="200" x2="800" y2="200" stroke="#bbdefb" stroke-width="1"/>
<line x1="0" y1="300" x2="800" y2="300" stroke="#bbdefb" stroke-width="1"/>
<line x1="200" y1="0" x2="200" y2="400" stroke="#bbdefb" stroke-width="1"/>
<line x1="400" y1="0" x2="400" y2="400" stroke="#bbdefb" stroke-width="1"/>
<line x1="600" y1="0" x2="600" y2="400" stroke="#bbdefb" stroke-width="1"/>
<rect x="360" y="160" width="80" height="120" rx="10" fill="#333"/>
<rect x="370" y="170" width="60" height="100" rx="5" fill="#4facfe"/>
<text x="400" y="230" text-anchor="middle" font-size="30" fill="white">📱</text>
<circle cx="200" cy="80" r="30" fill="#00C853" opacity="0.8"/>
<text x="200" y="90" text-anchor="middle" font-size="20" fill="white">🛰️</text>
<circle cx="600" cy="80" r="30" fill="#00C853" opacity="0.8"/>
<text x="600" y="90" text-anchor="middle" font-size="20" fill="white">🛰️</text>
<line x1="230" y1="100" x2="360" y2="200" stroke="#00C853" stroke-width="2" stroke-dasharray="5,5"/>
<line x1="570" y1="100" x2="440" y2="200" stroke="#00C853" stroke-width="2" stroke-dasharray="5,5"/>
<circle cx="400" cy="280" r="40" fill="none" stroke="#00C853" stroke-width="3"/>
<text x="400" y="340" text-anchor="middle" font-size="14" fill="#00C853">Noggrann ✓</text>
</svg>''',
'm4l1': '''<svg class="svg-illustration" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
<rect width="800" height="400" fill="#f5f5f7"/>
<rect x="0" y="250" width="800" height="150" fill="#555"/>
<line x1="0" y1="325" x2="800" y2="325" stroke="#fff" stroke-width="4" stroke-dasharray="20,20"/>
<circle cx="300" cy="200" r="40" fill="#FF6B35"/>
<text x="300" y="215" text-anchor="middle" font-size="40" fill="white">👷</text>
<rect x="340" y="180" width="30" height="50" rx="5" fill="#333"/>
<text x="355" y="215" text-anchor="middle" font-size="20" fill="white">📱</text>
<polygon points="500,250 520,180 540,250" fill="#FF6B35"/>
<line x1="350" y1="250" x2="500" y2="250" stroke="#00C853" stroke-width="3" stroke-dasharray="10,5"/>
<text x="425" y="240" text-anchor="middle" font-size="14" fill="#00C853">Säkert avstånd</text>
<text x="650" y="220" text-anchor="middle" font-size="50" fill="#666">🚗</text>
</svg>''',
'm5l1': '''<svg class="svg-illustration" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
<rect width="800" height="400" fill="#e8f5e9"/>
<path d="M 100 200 Q 200 100 300 200 T 500 200 T 700 200" fill="none" stroke="#00C853" stroke-width="8" stroke-linecap="round"/>
<circle cx="100" cy="200" r="30" fill="#0066FF"/>
<text x="100" y="210" text-anchor="middle" font-size="20" fill="white">A</text>
<circle cx="300" cy="200" r="30" fill="#0066FF"/>
<text x="300" y="210" text-anchor="middle" font-size="20" fill="white">B</text>
<circle cx="500" cy="200" r="30" fill="#0066FF"/>
<text x="500" y="210" text-anchor="middle" font-size="20" fill="white">C</text>
<circle cx="700" cy="200" r="30" fill="#0066FF"/>
<text x="700" y="210" text-anchor="middle" font-size="20" fill="white">D</text>
<text x="400" y="120" text-anchor="middle" font-size="40" fill="#00C853">🚴</text>
</svg>''',
'm6l1': '''<svg class="svg-illustration" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
<rect width="800" height="400" fill="#f5f5f7"/>
<circle cx="100" cy="200" r="50" fill="#00C853"/>
<text x="100" y="190" text-anchor="middle" font-size="30" fill="white">📸</text>
<text x="100" y="280" text-anchor="middle" font-size="12" fill="#666">Godkänd</text>
<text x="200" y="210" text-anchor="middle" font-size="30" fill="#999">→</text>
<circle cx="300" cy="200" r="50" fill="#0066FF"/>
<text x="300" y="190" text-anchor="middle" font-size="30" fill="white">🤖</text>
<text x="300" y="280" text-anchor="middle" font-size="12" fill="#666">AI-granskning</text>
<text x="400" y="210" text-anchor="middle" font-size="30" fill="#999">→</text>
<circle cx="500" cy="200" r="50" fill="#7B61FF"/>
<text x="500" y="190" text-anchor="middle" font-size="30" fill="white">✓</text>
<text x="500" y="280" text-anchor="middle" font-size="12" fill="#666">Godkännande</text>
<text x="600" y="210" text-anchor="middle" font-size="30" fill="#999">→</text>
<circle cx="700" cy="200" r="50" fill="#FFD600"/>
<text x="700" y="190" text-anchor="middle" font-size="30" fill="white">💰</text>
<text x="700" y="280" text-anchor="middle" font-size="12" fill="#666">Utbetalning</text>
</svg>'''
}
# Standard SVG för lektioner utan specifik illustration
DEFAULT_SVG = '''<svg class="svg-illustration" viewBox="0 0 800 400" xmlns="http://www.w3.org/2000/svg">
<rect width="800" height="400" fill="#f5f5f7"/>
<circle cx="400" cy="200" r="100" fill="#0066FF" opacity="0.1"/>
<text x="400" y="220" text-anchor="middle" font-size="80" fill="#0066FF">📚</text>
<text x="400" y="320" text-anchor="middle" font-size="20" fill="#666">quiXzoom Academy</text>
</svg>'''
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'<div class="content-block">\n<p>{content["intro"]}</p>\n</div>')
# Tips
if 'tips' in content:
tips_html = '\n'.join([f'<p>• {tip}</p>' for tip in content['tips']])
html_parts.append(f'<div class="tip-box">\n<strong>💡 Tips</strong>\n{tips_html}\n</div>')
# Requirements
if 'requirements' in content:
req_html = '\n'.join([f'<li>{req}</li>' for req in content['requirements']])
html_parts.append(f'<div class="content-block">\n<h2>Vad du behöver</h2>\n<ul>\n{req_html}\n</ul>\n</div>')
# Steps
if 'steps' in content:
steps_html = '\n'.join([f'<li><strong>Steg {i+1}:</strong> {step}</li>' for i, step in enumerate(content['steps'])])
html_parts.append(f'<div class="content-block">\n<h2>Steg för steg</h2>\n<ol>\n{steps_html}\n</ol>\n</div>')
# Factors
if 'factors' in content:
factors_html = '\n'.join([f'<li>{factor}</li>' for factor in content['factors']])
html_parts.append(f'<div class="content-block">\n<h2>Viktiga faktorer</h2>\n<ul>\n{factors_html}\n</ul>\n</div>')
# Examples
if 'examples' in content:
examples_html = '\n'.join([f'<p>• {example}</p>' for example in content['examples']])
html_parts.append(f'<div class="example-box">\n<h4>Exempel</h4>\n{examples_html}\n</div>')
# Best practices
if 'best_practices' in content:
bp_html = '\n'.join([f'<li>{bp}</li>' for bp in content['best_practices']])
html_parts.append(f'<div class="content-block">\n<h2>Bästa praxis</h2>\n<ul>\n{bp_html}\n</ul>\n</div>')
# Common errors
if 'common_errors' in content:
errors_html = '\n'.join([f'<li>{error}</li>' for error in content['common_errors']])
html_parts.append(f'<div class="content-block">\n<h2>Vanliga fel</h2>\n<ul>\n{errors_html}\n</ul>\n</div>')
# Solutions
if 'solutions' in content:
sol_html = '\n'.join([f'<li>{sol}</li>' for sol in content['solutions']])
html_parts.append(f'<div class="content-block">\n<h2>Lösningar</h2>\n<ul>\n{sol_html}\n</ul>\n</div>')
# Safety rules
if 'safety_rules' in content:
rules_html = '\n'.join([f'<li>{rule}</li>' for rule in content['safety_rules']])
html_parts.append(f'<div class="content-block">\n<h2>Säkerhetsregler</h2>\n<ul>\n{rules_html}\n</ul>\n</div>')
# Rules
if 'rules' in content:
rules_html = '\n'.join([f'<li>{rule}</li>' for rule in content['rules']])
html_parts.append(f'<div class="content-block">\n<h2>Regler</h2>\n<ul>\n{rules_html}\n</ul>\n</div>')
# Strategies
if 'strategies' in content:
strat_html = '\n'.join([f'<li>{strat}</li>' for strat in content['strategies']])
html_parts.append(f'<div class="content-block">\n<h2>Strategier</h2>\n<ul>\n{strat_html}\n</ul>\n</div>')
# Levels
if 'levels' in content:
levels_html = '\n'.join([f'<li>{level}</li>' for level in content['levels']])
html_parts.append(f'<div class="content-block">\n<h2>Nivåer</h2>\n<ul>\n{levels_html}\n</ul>\n</div>')
# Payment schedule
if 'payment_schedule' in content:
pay_html = '\n'.join([f'<li>{pay}</li>' for pay in content['payment_schedule']])
html_parts.append(f'<div class="content-block">\n<h2>Utbetalningar</h2>\n<ul>\n{pay_html}\n</ul>\n</div>')
# Deductions
if 'deductions' in content:
ded_html = '\n'.join([f'<li>{ded}</li>' for ded in content['deductions']])
html_parts.append(f'<div class="content-block">\n<h2>Avdrag du kan göra</h2>\n<ul>\n{ded_html}\n</ul>\n</div>')
# Warning
if 'warning' in content:
html_parts.append(f'<div class="warning-box">\n<strong>⚠️ Viktigt</strong>\n<p>{content["warning"]}</p>\n</div>')
# Quiz
if 'quiz' in content:
quiz = content['quiz']
options_html = '\n'.join([
f'<li class="quiz-option" onclick="checkAnswer(this, {i == quiz["correct"]})">\n<span class="quiz-letter">{chr(65+i)}</span>\n<span>{opt}</span>\n</li>'
for i, opt in enumerate(quiz['options'])
])
html_parts.append(f'''<div class="quiz-container">
<div class="quiz-question">{quiz['question']}</div>
<ul class="quiz-options">
{options_html}
</ul>
<div class="quiz-feedback" id="quizFeedback"></div>
</div>''')
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'''<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{lesson['title']} — quiXzoom Academy</title>
<style>
:root {{
--qx-black: #0a0a0a;
--qx-white: #ffffff;
--qx-blue: #0066FF;
--qx-green: #00C853;
--qx-gray: #F5F5F7;
--qx-dark-gray: #1a1a1a;
--qx-text-muted: #6e6e73;
--qx-purple: #7B61FF;
--qx-orange: #FF6B35;
}}
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
body {{
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
color: var(--qx-black);
background: var(--qx-white);
line-height: 1.6;
}}
.progress-container {{
position: sticky;
top: 0;
background: white;
padding: 12px 20px;
border-bottom: 1px solid var(--qx-gray);
z-index: 100;
}}
.progress-bar {{
max-width: 600px;
margin: 0 auto;
background: var(--qx-gray);
border-radius: 10px;
height: 8px;
overflow: hidden;
}}
.progress-fill {{
background: var(--qx-green);
height: 100%;
width: 0%;
transition: width 0.5s ease;
}}
.lesson-container {{
max-width: 800px;
margin: 0 auto;
padding: 40px 20px;
}}
.lesson-header {{
margin-bottom: 48px;
}}
.lesson-module {{
color: var(--qx-blue);
font-size: 0.875rem;
text-transform: uppercase;
letter-spacing: 2px;
margin-bottom: 8px;
}}
.lesson-title {{
font-size: 2.5rem;
margin-bottom: 16px;
line-height: 1.2;
}}
.lesson-meta {{
color: var(--qx-text-muted);
font-size: 0.9rem;
display: flex;
gap: 16px;
}}
.svg-illustration {{
width: 100%;
border-radius: 16px;
margin: 32px 0;
box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}}
.content-block {{
margin-bottom: 48px;
}}
.content-block h2 {{
font-size: 1.75rem;
margin-bottom: 20px;
}}
.content-block p {{
margin-bottom: 16px;
color: #333;
font-size: 1.05rem;
}}
.content-block ul {{
margin-left: 24px;
margin-bottom: 16px;
}}
.content-block li {{
margin-bottom: 12px;
}}
.tip-box {{
background: #e8f4fd;
border-left: 4px solid var(--qx-blue);
padding: 24px;
margin: 24px 0;
border-radius: 0 12px 12px 0;
}}
.tip-box strong {{
color: var(--qx-blue);
display: block;
margin-bottom: 8px;
}}
.warning-box {{
background: #fff3cd;
border-left: 4px solid var(--qx-orange);
padding: 24px;
margin: 24px 0;
border-radius: 0 12px 12px 0;
}}
.warning-box strong {{
color: var(--qx-orange);
display: block;
margin-bottom: 8px;
}}
.example-box {{
background: var(--qx-gray);
padding: 24px;
border-radius: 12px;
margin: 24px 0;
}}
.quiz-container {{
background: var(--qx-gray);
padding: 32px;
border-radius: 16px;
margin: 32px 0;
}}
.quiz-question {{
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 24px;
}}
.quiz-options {{
list-style: none;
}}
.quiz-option {{
background: white;
padding: 16px 20px;
margin-bottom: 12px;
border-radius: 12px;
cursor: pointer;
transition: all 0.2s;
border: 2px solid transparent;
display: flex;
align-items: center;
gap: 12px;
}}
.quiz-option:hover {{
border-color: var(--qx-blue);
transform: translateX(4px);
}}
.quiz-option.correct {{
background: var(--qx-green);
color: white;
border-color: var(--qx-green);
}}
.quiz-option.wrong {{
background: #ff4444;
color: white;
border-color: #ff4444;
}}
.quiz-option.disabled {{
pointer-events: none;
opacity: 0.7;
}}
.quiz-letter {{
width: 32px;
height: 32px;
border-radius: 50%;
background: var(--qx-gray);
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
flex-shrink: 0;
}}
.quiz-feedback {{
margin-top: 20px;
padding: 20px;
border-radius: 12px;
display: none;
font-size: 1rem;
}}
.quiz-feedback.show {{
display: block;
}}
.lesson-nav {{
display: flex;
justify-content: space-between;
margin-top: 60px;
padding-top: 40px;
border-top: 2px solid var(--qx-gray);
}}
.nav-btn {{
padding: 14px 28px;
border-radius: 10px;
text-decoration: none;
font-weight: 600;
transition: all 0.2s;
display: inline-flex;
align-items: center;
gap: 8px;
}}
.nav-btn.prev {{
background: var(--qx-gray);
color: var(--qx-black);
}}
.nav-btn.next {{
background: var(--qx-blue);
color: white;
}}
.complete-btn {{
display: block;
width: 100%;
max-width: 400px;
margin: 48px auto;
padding: 18px 32px;
background: var(--qx-green);
color: white;
border: none;
border-radius: 12px;
font-size: 1.1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
}}
.complete-btn:hover {{
transform: translateY(-2px);
box-shadow: 0 4px 16px rgba(0,200,83,0.3);
}}
.complete-btn.completed {{
background: var(--qx-gray);
color: var(--qx-text-muted);
cursor: default;
}}
@media (max-width: 768px) {{
.lesson-title {{ font-size: 1.75rem; }}
}}
</style>
</head>
<body>
<div class="progress-container">
<div class="progress-bar">
<div class="progress-fill" id="lessonProgress" style="width: 0%"></div>
</div>
</div>
<div class="lesson-container">
<header class="lesson-header">
<div class="lesson-module">{module['title']}{module['description']}</div>
<h1 class="lesson-title">{lesson['title']}</h1>
<div class="lesson-meta">
<span>⏱️ {lesson['duration']}</span>
<span>🎯 {module['level']}</span>
<span>📚 {lesson['type']}</span>
</div>
</header>
{svg}
{content_html}
<button class="complete-btn" id="completeBtn" onclick="completeLesson()">
✅ Markera lektion som klar
</button>
<nav class="lesson-nav">
<a href="{prev_link}" class="nav-btn prev">← {prev_text}</a>
<a href="{next_link}" class="nav-btn next">{next_text} →</a>
</nav>
</div>
<script>
const lessonId = '{lesson['id']}';
let completedLessons = JSON.parse(localStorage.getItem('academyProgress') || '[]');
function checkAnswer(element, isCorrect) {{
const options = document.querySelectorAll('.quiz-option');
const feedback = document.getElementById('quizFeedback');
options.forEach(opt => opt.classList.add('disabled'));
if (isCorrect) {{
element.classList.add('correct');
feedback.innerHTML = '<strong>✅ Rätt!</strong> Bra jobbat!';
feedback.style.background = '#d4edda';
feedback.style.color = '#155724';
}} else {{
element.classList.add('wrong');
feedback.innerHTML = '<strong>❌ Inte riktigt.</strong> Tänk igenom svaret en gång till.';
feedback.style.background = '#f8d7da';
feedback.style.color = '#721c24';
}}
feedback.classList.add('show');
}}
function completeLesson() {{
if (!completedLessons.includes(lessonId)) {{
completedLessons.push(lessonId);
localStorage.setItem('academyProgress', JSON.stringify(completedLessons));
const btn = document.getElementById('completeBtn');
btn.textContent = '✅ Lektion klar!';
btn.classList.add('completed');
btn.disabled = true;
btn.style.transform = 'scale(1.05)';
setTimeout(() => btn.style.transform = 'scale(1)', 200);
}}
}}
if (completedLessons.includes(lessonId)) {{
const btn = document.getElementById('completeBtn');
btn.textContent = '✅ Lektion klar!';
btn.classList.add('completed');
btn.disabled = true;
}}
</script>
</body>
</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()