mirror of
https://github.com/HananoshikaYomaru/openfreebooks.git
synced 2026-11-12 20:45:52 +00:00
473 lines
10 KiB
TypeScript
473 lines
10 KiB
TypeScript
/**
|
|
* One-off helper: merge research-based curriculumCoverage into math-curriculum.json.
|
|
* Run: bun scripts/apply-math-coverage.ts
|
|
*/
|
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
|
|
type Role = "core" | "extension" | "related";
|
|
type Coverage = Partial<Record<string, Role>>;
|
|
|
|
const ROOT = path.join(import.meta.dir, "..");
|
|
const JSON_PATH = path.join(ROOT, "data/math-curriculum.json");
|
|
|
|
/** slug → framework label → role */
|
|
const COVERAGE_BY_SLUG: Record<string, Coverage> = {
|
|
"zero-and-one": {
|
|
Foundation: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
DSE: "related",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"counting-and-numbers": {
|
|
Foundation: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
DSE: "related",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"basic-math-notation": {
|
|
Foundation: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
DSE: "related",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"properties-of-operations": {
|
|
Foundation: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
DSE: "related",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"written-calculation": {
|
|
Foundation: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
DSE: "related",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"integer-foundations": {
|
|
Foundation: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
DSE: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"integer-arithmetic": {
|
|
Foundation: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
DSE: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"rational-number-operations": {
|
|
Foundation: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
DSE: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"percentage-applications": {
|
|
Foundation: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
DSE: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"ratios-and-rates-foundation": {
|
|
Foundation: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
DSE: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"directed-numbers-rates": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
Foundation: "related",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"polynomials-expansion-factorisation": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
Gaokao: "core",
|
|
Foundation: "related",
|
|
AP: "related",
|
|
},
|
|
"algebraic-fractions-formulas": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
"Common Core": "related",
|
|
Singapore: "related",
|
|
"UK GCSE": "core",
|
|
Gaokao: "related",
|
|
Foundation: "related",
|
|
AP: "related",
|
|
},
|
|
"linear-equations-two-unknowns": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
"UK GCSE": "core",
|
|
Gaokao: "core",
|
|
AP: "related",
|
|
Foundation: "related",
|
|
},
|
|
"linear-inequalities-one-unknown": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
"UK GCSE": "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
Singapore: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"laws-of-indices": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
AP: "core",
|
|
"Common Core": "core",
|
|
"UK GCSE": "core",
|
|
Singapore: "core",
|
|
Gaokao: "core",
|
|
Foundation: "related",
|
|
},
|
|
"quadratic-equations": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
AP: "core",
|
|
"Common Core": "core",
|
|
"UK GCSE": "core",
|
|
Singapore: "core",
|
|
Gaokao: "core",
|
|
Foundation: "related",
|
|
},
|
|
"factor-remainder-theorems": {
|
|
DSE: "extension",
|
|
IB: "extension",
|
|
"A-Level": "extension",
|
|
IGCSE: "related",
|
|
Gaokao: "related",
|
|
AP: "related",
|
|
},
|
|
"complex-numbers": {
|
|
DSE: "extension",
|
|
IB: "extension",
|
|
"A-Level": "extension",
|
|
Gaokao: "related",
|
|
IGCSE: "related",
|
|
AP: "related",
|
|
},
|
|
"functions-graphs": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
AP: "core",
|
|
"Common Core": "core",
|
|
"UK GCSE": "core",
|
|
Singapore: "core",
|
|
Gaokao: "core",
|
|
Foundation: "related",
|
|
},
|
|
"exponential-logarithmic": {
|
|
DSE: "extension",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
AP: "core",
|
|
"Common Core": "core",
|
|
"UK GCSE": "core",
|
|
Gaokao: "core",
|
|
Singapore: "related",
|
|
Foundation: "related",
|
|
},
|
|
"sequences-series": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
"Common Core": "related",
|
|
"UK GCSE": "core",
|
|
AP: "related",
|
|
Gaokao: "core",
|
|
Singapore: "related",
|
|
Foundation: "related",
|
|
},
|
|
"variations": {
|
|
DSE: "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
IGCSE: "related",
|
|
"Common Core": "related",
|
|
Singapore: "related",
|
|
},
|
|
"linear-programming": {
|
|
DSE: "extension",
|
|
IB: "extension",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
IGCSE: "related",
|
|
},
|
|
"coordinate-geometry-foundations": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
"Common Core": "core",
|
|
"UK GCSE": "core",
|
|
IB: "core",
|
|
"A-Level": "related",
|
|
Singapore: "core",
|
|
AP: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"deductive-geometry": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
"UK GCSE": "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
Gaokao: "related",
|
|
},
|
|
"congruence-similarity": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
"UK GCSE": "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
Gaokao: "related",
|
|
},
|
|
"pythagoras-theorem": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
"UK GCSE": "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
IB: "core",
|
|
"A-Level": "related",
|
|
Gaokao: "core",
|
|
AP: "related",
|
|
},
|
|
"introduction-trigonometry": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
"UK GCSE": "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
IB: "core",
|
|
"A-Level": "related",
|
|
Gaokao: "core",
|
|
AP: "related",
|
|
},
|
|
"mensuration-3d": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
"UK GCSE": "core",
|
|
"Common Core": "core",
|
|
Singapore: "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
Gaokao: "related",
|
|
},
|
|
"coordinate-circles": {
|
|
DSE: "core",
|
|
IGCSE: "related",
|
|
IB: "extension",
|
|
"A-Level": "extension",
|
|
Gaokao: "related",
|
|
"UK GCSE": "related",
|
|
AP: "related",
|
|
},
|
|
"advanced-trigonometry": {
|
|
DSE: "extension",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
AP: "core",
|
|
"UK GCSE": "core",
|
|
Gaokao: "core",
|
|
"Common Core": "related",
|
|
Singapore: "related",
|
|
},
|
|
"circle-properties": {
|
|
DSE: "extension",
|
|
IGCSE: "core",
|
|
"UK GCSE": "core",
|
|
IB: "related",
|
|
"A-Level": "related",
|
|
Gaokao: "related",
|
|
Singapore: "related",
|
|
},
|
|
"loci": {
|
|
DSE: "extension",
|
|
IGCSE: "related",
|
|
"A-Level": "related",
|
|
IB: "related",
|
|
"UK GCSE": "related",
|
|
},
|
|
"statistical-charts-averages": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"Common Core": "core",
|
|
"UK GCSE": "core",
|
|
Singapore: "core",
|
|
AP: "related",
|
|
Gaokao: "related",
|
|
"A-Level": "related",
|
|
},
|
|
"measures-dispersion": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"A-Level": "related",
|
|
AP: "related",
|
|
"Common Core": "core",
|
|
"UK GCSE": "core",
|
|
Singapore: "related",
|
|
Gaokao: "related",
|
|
},
|
|
"basic-probability": {
|
|
DSE: "core",
|
|
IGCSE: "core",
|
|
IB: "core",
|
|
"Common Core": "core",
|
|
"UK GCSE": "core",
|
|
Singapore: "core",
|
|
AP: "related",
|
|
"A-Level": "related",
|
|
Gaokao: "related",
|
|
},
|
|
"permutations-combinations-probability": {
|
|
DSE: "extension",
|
|
IGCSE: "extension",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
AP: "related",
|
|
Gaokao: "related",
|
|
"Common Core": "related",
|
|
},
|
|
"normal-distribution-z-scores": {
|
|
DSE: "extension",
|
|
IB: "core",
|
|
"A-Level": "core",
|
|
AP: "related",
|
|
IGCSE: "related",
|
|
Gaokao: "related",
|
|
"Common Core": "related",
|
|
},
|
|
"statistical-literacy": {
|
|
DSE: "core",
|
|
IB: "related",
|
|
"Common Core": "related",
|
|
IGCSE: "related",
|
|
AP: "related",
|
|
"A-Level": "related",
|
|
Singapore: "related",
|
|
},
|
|
};
|
|
|
|
type Chapter = {
|
|
slug: string;
|
|
curriculums?: string[];
|
|
curriculumCoverage?: Coverage;
|
|
[key: string]: unknown;
|
|
};
|
|
|
|
type Catalog = {
|
|
strands: { chapters: Chapter[] }[];
|
|
[key: string]: unknown;
|
|
};
|
|
|
|
const catalog = JSON.parse(readFileSync(JSON_PATH, "utf8")) as Catalog;
|
|
|
|
for (const strand of catalog.strands) {
|
|
for (const chapter of strand.chapters) {
|
|
const coverage = COVERAGE_BY_SLUG[chapter.slug];
|
|
if (!coverage) {
|
|
throw new Error(`Missing coverage map for slug: ${chapter.slug}`);
|
|
}
|
|
chapter.curriculumCoverage = coverage;
|
|
delete chapter.curriculums;
|
|
}
|
|
}
|
|
|
|
writeFileSync(JSON_PATH, `${JSON.stringify(catalog, null, 2)}\n`);
|
|
console.log(`Updated ${Object.keys(COVERAGE_BY_SLUG).length} chapters in math-curriculum.json`);
|