#!/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': '''''',
'm2l1': '''''',
'm2l2': '''''',
'm2l3': '''''',
'm2l4': '''''',
'm3l1': '''''',
'm4l1': '''''',
'm5l1': '''''',
'm6l1': ''''''
}
DEFAULT_SVG = ''''''
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'
')
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'')
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'')
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'')
if 'common_errors' in content:
errors_html = '\n'.join([f'{error}' for error in content['common_errors']])
html_parts.append(f'')
if 'solutions' in content:
sol_html = '\n'.join([f'{sol}' for sol in content['solutions']])
html_parts.append(f'')
if 'safety_rules' in content:
rules_html = '\n'.join([f'{rule}' for rule in content['safety_rules']])
html_parts.append(f'')
if 'rules' in content:
rules_html = '\n'.join([f'{rule}' for rule in content['rules']])
html_parts.append(f'')
if 'strategies' in content:
strat_html = '\n'.join([f'{strat}' for strat in content['strategies']])
html_parts.append(f'')
if 'levels' in content:
levels_html = '\n'.join([f'{level}' for level in content['levels']])
html_parts.append(f'')
if 'payment_schedule' in content:
pay_html = '\n'.join([f'{pay}' for pay in content['payment_schedule']])
html_parts.append(f'')
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'''''')
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
'''
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()