📘 Lesson Object
lessons[ ]
{
id: number, // unique lesson identifier (1–36)
level: string, // CEFR level: "A1" | "A2" | "B1" | "B2" | "C1" | "C2"
cat: string, // category: "grammar" | "vocab"
title: string, // Bulgarian title
title_en: string, // English title
desc: string, // Bulgarian short description
desc_en: string, // English short description
content: HTML string, // Bulgarian lesson body (HTML)
content_en:HTML string, // English lesson body (HTML)
}
❓ Question Object
questions[ ]
{
q: string, // Bulgarian question text
q_en: string, // English question text
opts: string[], // Bulgarian answer options [4]
opts_en: string[], // English answer options [4]
ans: number, // correct answer index (0–3)
level: string, // CEFR level: "A1"–"C2"
topic: string, // topic tag (maps to quiz set)
// Optional flip fields (translation questions only):
flip: boolean, // true = reverse question in EN mode
q_flip: string, // EN mode: asks for BG word
opts_flip: string[], // Bulgarian options shown in EN mode
ans_flip: number, // correct index for flipped version
}
⚙️ Module Public Interfaces
| Module | Method | Returns | Description |
| ThemeModule | toggle() | void | Switches light/dark theme and saves to localStorage |
| ThemeModule | init() | void | Loads saved theme on page load |
| LangModule | toggle() | void | Switches BG/EN and re-renders all UI text |
| LangModule | t(key) | string | Returns translated string for given key |
| LangModule | current() | "bg"|"en" | Returns active language code |
| CacheModule | save(data) | void | Serialises progress object to localStorage as JSON |
| CacheModule | load() | object|null | Deserialises and returns saved progress or null |
| CacheModule | clear() | void | Removes progress data from localStorage |
| StateModule | addLesson(id) | void | Marks lesson as read, saves state |
| StateModule | addQuizResult(lv,s,t) | void | Records quiz score per level, saves state |
| NavModule | showPage(id,btn) | void | Activates page by id, highlights nav button |
| NavModule | openLesson(id) | void | Shows lesson detail view for given lesson id |
| QuizModule | startSet(id) | void | Loads questions for named quiz set and begins quiz |
| QuizModule | selectAnswer(idx) | void | Checks answer, shows feedback, handles flip logic |
| QuizModule | showList() | void | Returns to quiz selection list view |
💾 localStorage Schema
CacheModule
// Key: "learnenglish_progress"
{
lessonsRead: number[], // array of lesson ids read
quizCorrect: number, // total correct answers all-time
quizTotal: number, // total questions answered
levelCorrect: Record<string,number>, // correct per level {"A1":3,"B2":5,...}
levelTotal: Record<string,number> // total per level
}
// Key: "theme" → "light" | "dark"
// Key: "lang" → "bg" | "en"