# Magnivance Education Playground — content & maintenance

## Architecture

Zero-build, dependency-free static HTML/CSS/JavaScript. No frameworks, paid APIs, external fonts, CDNs, analytics, accounts or advertisements. Keep the complete website folder structure when deploying. Shared site infrastructure is unchanged.

- `index.html`, `grade-4.html` … `grade-8.html`: entry points, all using the same application.
- `playground.js`, `playground.css`: application and responsive/print styles.
- `data/manifest.js`: small overview loaded at startup.
- `data/grade-N.js`: loaded on demand with a local script tag. Works on HTTPS, HTTP and file URLs without fetch/CORS.
- `data/olympiad-dataset.json`: complete editable/portable structured data, organized by grade → book → subject → chapter → topic/concepts → questions/answers. The `chapters` list mirrors `book.subjects`; keep both synchronized.
- `reader/grade-N/page-NNN.webp`: original source page images, preserved in order. All diagrams remain accessible in their original context.
- `source/raw_pages.json`: full OCR text for all page slots, including front matter, revision sections and the missing-page record. This preserves source material that cannot reliably be normalized into an activity.
- `source/extraction-summary.txt`, `data/content-audit.json`: reproducible coverage and structural audit.
- `maintenance/extract_all_books.py`: standard-library Python extraction/normalization pipeline, no runtime dependency for website visitors.
- `maintenance/audit_dataset.py`: checks chapter coverage, references, unique question IDs, four-option MCQ structure, key membership and image availability. This is NOT a proof of mathematical or semantic accuracy.

## What is included

Five books: 564 page slots, 563 readable original images, 127 chapters, 2,942 extracted question items (2,414 chapter exercises + 528 mock items), 652 explicit/harvested definitions, 218 solved examples and 214 trap/tip entries. Grade 6 has 581 chapter questions (81 keyed MCQs) plus the complete 100 mock questions, all taken directly from the DOCX. Grade 6 now uses its 89 explicitly labelled source definitions rather than the previous 251 OCR-harvested fact fragments; the full source prose is still retained and readable. Book-based term games are transformations of STEM definitions, not a separate English course. Chapter source references point to the chapter's opening page; use the original reader to locate the precise exercise or answer page. Mock references retain examination title and printed question number.

OCR-aware parsing avoids mistaking thousands separators and decimal constants for new question numbers, handles headings with missing OCR section numbers, and never defaults a missing answer key to option A. Question counts reflect recovered boundaries, not an independent guarantee that every OCR line is semantically correct.

## Important editorial limitations

- **Grade 6, page 119 is an empty image in the supplied archive and original website.** The reader now displays the intervening text recovered from the supplied DOCX, clearly identified as text, not a fabricated original image. Maths Q26–30 and Science Q1–25 are restored; all 100 mock questions and keys are available.
- Transcribed mathematics, table layouts, options and answer alignments need human comparison against source images. The original book itself may contain inconsistencies. Preserve source wording; document any editorial correction.
- Missing/unrecognized MCQ keys are `null` and excluded from automatic marking. Such items remain available for book/self-check practice. Open answers use a self-check rubric, never pretend semantic AI grading.
- Test scoring is one point per keyed MCQ, with self-check results separate. It does not reproduce the books' varied original marks or constitute an official exam.
- Diagrams are not machine-interpreted: original pages are available alongside text models.

## Preferred update workflow

1. Back up the deployed folder and maintain source/version history.
2. For Grades 4, 5, 7 and 8, verify/correct the relevant page text in `source/raw_pages.json` against the original WebP. For Grade 6, update the supplied `source/grade-6.docx`; its native text overrides Grade 6 OCR during regeneration. Do not invent unavailable text.
3. Run from any directory:

   ```sh
   python3 olympiad/maintenance/extract_all_books.py
   python3 olympiad/maintenance/audit_dataset.py
   ```

   Paths are resolved relative to the maintenance script. The generator overwrites master JSON, manifest and grade JS files. With `source/grade-6.docx` present, it also regenerates the complete `grade-6-source.html` reader, `source/grade-6-docx.txt`, recovered page-119 text and `data/grade-6-docx-audit.json`. `maintenance/import_grade6_docx.py` imports DOCX XML in paragraph/table order; `maintenance/native_math.py` formats nested fractions, powers, units and symbols without a CDN or math API. The exact source LaTeX remains in `sourceRaw`. Recheck any manual structured-data edits before regenerating.
4. For an editorial structured-data-only edit, update the relevant chapter in both `chapters` and `book.subjects`. Rebuild each grade script as:

   ```js
   window.MAGNIVANCE_PLAYGROUND_BOOKS = window.MAGNIVANCE_PLAYGROUND_BOOKS || {};
   window.MAGNIVANCE_PLAYGROUND_BOOKS[4] = /* corresponding grade-4 object */;
   ```

   Maintain `id`, `qNum`, `type`, `prompt`, `options`, `correctOption`, `answer`, `explanation`, `bookRef`; keep IDs stable. Use `correctOption: null` for an unverified or missing key, never guess. Update manifest totals after edits.
5. Run the audit, then browser-check all affected tools and source pages. If counts change, update hero/coverage documentation too.
6. Upload changed files with the same relative paths. No database, build server or API keys are required.

New grade support requires adding its manifest/data, grade HTML entry point and image folder, plus extending any grade-specific blueprint/revision mappings in the application and this documentation.

## Weightage mapping

The blueprint uses the supplied Al-Khwarizmi 2026 preparation guideline. Chapter strand labels are normalized to it:

- Grades 4–6: number/operations and algebra/ratio/sequences → Number Theory & Operations; geometry/measurement → Geometry & Measurement; aptitude/reasoning and introductory data → Aptitude & Logical Reasoning.
- Grades 7–8: number theory and algebra → Numbers/Number Theory & Algebra; geometry/measurement → Geometry & Measurement; data/probability → Data & Probability.
- Science uses named strands; Scientific Reasoning maps to Scientific Reasoning & General Science.
- With both subjects selected, half of the target allocation goes to each subject. Largest remainders round strand targets to whole questions. Shortfalls are filled without duplicates from the remaining selected pool. The review/worksheet reports targets AND actual counts. Not every chapter selection can meet the whole-syllabus blueprint.

## Progress and privacy

Only `edutools_olympiad_playground_v1` is used by the Playground. Storage is optional and protected by try/catch. It contains chapter-study flags and up to 800 activity IDs, grade/chapter references, correctness and timestamps. No personal identity, typed answers or drawings are persisted. Results supports local JSON export, print and reset. No network telemetry or third-party requests. Other existing site tools may use their own documented local keys; shared site behavior is not altered.

## Browser QA checklist

- All five grade pages and grade switching; Science/Mathematics/chapter filters; topic search; URL deep links.
- Learning objectives, definitions, concepts, formulas, source thumbnails/dialog, solved step reveal, studied flag.
- Original reader: first/last pages, next/previous, number/chapter jump, keyboard keys, zoom/fit, Grade 6 missing page, practice-current-chapter.
- Flashcard flip, memory matching, visible pair matching, spelling/undo, definition true/false, blanks/word bank.
- MCQ selection/feedback, open self-check, Maths/logic scratchpad pointer drawing/eraser/grid/clear, Science strand feedback.
- Timed quiz, weighted allocation/worksheet, book mock selection, question palette, flags, response preservation, manual submission and expiry submission.
- Score separation, rubric self-check, dashboard, reload persistence, JSON export/reset and printing.
- Phone-width layout and keyboard focus. No external scripts, trackers, requests or ad banners.

## Deployment

Preview the site with `python3 -m http.server 8000 --bind 0.0.0.0` from the website root. On cPanel, back up `public_html`, then merge the archive contents into `public_html` (not an extra nested folder). `/olympiad/` is canonical. `/Olympiad/index.html` redirects older capitalized links to the lowercase directory. Test the deployed HTTPS paths after upload; this workspace build does not itself publish changes to magnivance.online.

## Grade 6 DOCX provenance

Source: `grade 6.docx`, Drive file `1XpPERwcQAen0BAzBWFLFTBpFWb1WZZs6`. All 27 chapters have a one-to-one match between printed exercise numbers and printed answer numbers. All 81 chapter MCQs have source keys. Mock counts are asserted as 30/30/40 with matching answer-number sets. The importer does not invent trap sections: Chapters 16–27 do not have separate traps sections in the DOCX. Exact XML text is preserved; original document typos and questionable mathematical answers still require editorial review. The importer normalizes display markup but does not silently replace source answers. The original image archive remains unchanged.
