Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc99865bd4 | ||
|
|
587cfe3f0b | ||
|
|
0a4c051ee5 | ||
|
|
343b40c645 | ||
|
|
d1688ac150 | ||
|
|
271ffe92d4 | ||
|
|
0571d1c0ff | ||
|
|
180d6e9b3e | ||
|
|
80f405123e | ||
|
|
077aca6008 | ||
|
|
9dba5ff1ff |
No files matched your search
+1
-1
@@ -109,7 +109,7 @@ def _has_publishable_data(row) -> bool:
|
||||
|
||||
|
||||
def _url_element(loc: str, lastmod: str | None = None) -> str:
|
||||
"""One <url> entry. No priority or changefreq — Google ignores both."""
|
||||
"""One <url> entry. No priority or changefreq, Google ignores both."""
|
||||
body = f"<loc>{loc}</loc>"
|
||||
if lastmod:
|
||||
body += f"<lastmod>{lastmod}</lastmod>"
|
||||
|
||||
@@ -250,6 +250,10 @@ def select_nearby(frame: pd.DataFrame, urn: int) -> list[dict]:
|
||||
"distance_miles": float(row["distance_miles"]),
|
||||
"school_type": _native(row.get("school_type")),
|
||||
"age_range": _native(row.get("age_range")),
|
||||
# Each peer's own phase, not the subject's: the pool is a phase
|
||||
# group, so an all-through school can sit beside a primary. The
|
||||
# compare basket counts it against both of its tabs.
|
||||
"phase": _native(row.get("phase")),
|
||||
"shared": _shared(subject, row, is_secondary),
|
||||
"metric_value": _native(row.get(metric_key)),
|
||||
"metric_key": metric_key,
|
||||
|
||||
@@ -163,6 +163,18 @@ def test_secondary_reaches_further_than_primary():
|
||||
assert {s["urn"] for s in select_nearby(frame, 100001)} == {100002, 100003}
|
||||
|
||||
|
||||
def test_each_card_carries_its_own_phase():
|
||||
# The compare basket limits each phase separately, so an all-through peer
|
||||
# must not inherit the subject's "Primary".
|
||||
frame = _frame(
|
||||
_row(100001, "Subject"),
|
||||
_row(100002, "A", latitude=_at(0.5)),
|
||||
_row(100003, "B", phase="All-through", age_range="4-18", latitude=_at(0.6)),
|
||||
)
|
||||
phases = {s["urn"]: s["phase"] for s in select_nearby(frame, 100001)}
|
||||
assert phases == {100002: "Primary", 100003: "All-through"}
|
||||
|
||||
|
||||
def test_the_cap_follows_the_phase():
|
||||
assert radius_miles("Primary") == 2.0
|
||||
assert radius_miles("Middle deemed primary") == 2.0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { test, expect, Page } from '@playwright/test';
|
||||
import { test, expect, Locator, Page } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Journey tests for SchoolCompare, run against the staging environment as the
|
||||
@@ -19,6 +19,31 @@ function schoolLinks(page: Page) {
|
||||
return page.locator('a[href^="/school/"]');
|
||||
}
|
||||
|
||||
/**
|
||||
* A scroll offset that has stopped moving.
|
||||
*
|
||||
* The carousel arrows scroll with `behavior: 'smooth'`, so a reading taken
|
||||
* straight after a click lands mid-animation. Measured against staging: the
|
||||
* animation runs ~700ms, and a poll for "has it moved at all" is satisfied
|
||||
* 50ms in, at 13px of a 1300px journey. A test that then records an offset,
|
||||
* does something, and records again is measuring the tail of the arrow's
|
||||
* animation rather than the effect of whatever it did in between.
|
||||
*
|
||||
* Two identical readings in a row is the cheapest sound definition of settled.
|
||||
*/
|
||||
async function settledScrollLeft(scroller: Locator): Promise<number> {
|
||||
let previous = -1;
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const current = await scroller.evaluate((node: HTMLElement) => Math.round(node.scrollLeft));
|
||||
const settled = current === previous;
|
||||
previous = current;
|
||||
return settled;
|
||||
}, { timeout: 10_000 })
|
||||
.toBe(true);
|
||||
return previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* Two URNs guaranteed to be pure-primary (same phase). The compare page's
|
||||
* phase tabs split all-through schools (which carry KS4 data) onto the
|
||||
@@ -97,9 +122,9 @@ test('the coverage figure is live, not the hardcoded fallback', async ({ page })
|
||||
test('the landing page states the real comparison limit', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
const body = await page.locator('body').innerText();
|
||||
// MAX_SCHOOLS in context/ComparisonProvider.tsx is 5. The hero used to
|
||||
// promise three while a card lower on the same page promised five.
|
||||
expect(body).toMatch(/five schools/i);
|
||||
// MAX_PER_GROUP in lib/compareLogic.ts is 5 per phase. The hero once
|
||||
// promised three while a card lower on the same page promised five.
|
||||
expect(body).toMatch(/five primary and five secondary schools/i);
|
||||
expect(body).not.toMatch(/three schools/i);
|
||||
});
|
||||
|
||||
@@ -2776,9 +2801,7 @@ test('nearby schools link on to other schools and into compare', async ({ page }
|
||||
await expect(back).toBeDisabled();
|
||||
|
||||
await forward.click();
|
||||
await expect
|
||||
.poll(() => scroller.evaluate((node: HTMLElement) => node.scrollLeft))
|
||||
.toBeGreaterThan(8);
|
||||
expect(await settledScrollLeft(scroller)).toBeGreaterThan(8);
|
||||
await expect(back).toBeEnabled();
|
||||
}
|
||||
|
||||
@@ -2794,15 +2817,61 @@ test('nearby schools link on to other schools and into compare', async ({ page }
|
||||
//
|
||||
// A few pixels of snap or sub-pixel adjustment are fine; a reset to the
|
||||
// start is not, which is the whole point of the check.
|
||||
const offsetBefore = await scroller.evaluate((node: HTMLElement) => node.scrollLeft);
|
||||
const offsetBefore = await settledScrollLeft(scroller);
|
||||
await section.getByRole('button', { name: /Add to compare/ }).last().click();
|
||||
await expect(
|
||||
section.getByRole('button', { name: /Added to compare/ }).first(),
|
||||
).toBeVisible();
|
||||
const offsetAfter = await scroller.evaluate((node: HTMLElement) => node.scrollLeft);
|
||||
const offsetAfter = await settledScrollLeft(scroller);
|
||||
expect(Math.abs(offsetAfter - offsetBefore)).toBeLessThanOrEqual(8);
|
||||
});
|
||||
|
||||
/**
|
||||
* Every section in the mobile jump sheet can actually be reached.
|
||||
*
|
||||
* The sheet is a fixed bottom sheet, and the app has a fixed bottom tab bar.
|
||||
* `position: sticky` with a z-index on the sticky nav makes it a stacking
|
||||
* context, so the sheet's own z-index orders it only within that context —
|
||||
* against the tab bar, the nav's value is what counts. The last item in the
|
||||
* sheet was therefore painted over and untappable as soon as the list grew
|
||||
* long enough to reach the bar, which adding "Nearby schools" is what did.
|
||||
*
|
||||
* Bounding boxes are not enough to catch this: the item is in the viewport and
|
||||
* the right size, it is simply underneath something. So this asks the question
|
||||
* a thumb asks — what is on top at this point.
|
||||
*/
|
||||
test('every section in the mobile jump sheet is tappable, not under the tab bar', async ({ page }) => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await searchByName(page, 'Primary');
|
||||
await schoolLinks(page).first().click();
|
||||
await page.waitForURL(/\/school\//);
|
||||
|
||||
// Scroll down so the sticky nav is docked and the sheet has somewhere to open.
|
||||
await page.evaluate(() => window.scrollTo({ top: 1200 }));
|
||||
// Two controls carry aria-haspopup: the mobile "Section" button and the
|
||||
// desktop "All" one, which is display:none here but still in the DOM.
|
||||
await page.locator('[aria-haspopup="menu"]:visible').click();
|
||||
|
||||
const sheet = page.locator('[role="menu"]');
|
||||
await expect(sheet).toBeVisible();
|
||||
|
||||
const covered = await sheet.evaluate((panel: HTMLElement) =>
|
||||
Array.from(panel.querySelectorAll('[role="menuitem"]'))
|
||||
.map((el) => {
|
||||
const box = el.getBoundingClientRect();
|
||||
const hit = document.elementFromPoint(
|
||||
Math.round(box.left + box.width / 2),
|
||||
Math.round(box.top + box.height / 2),
|
||||
);
|
||||
return { label: (el as HTMLElement).innerText.trim().replace(/\s+/g, ' '), reachable: !!(hit && hit.closest('[role="menuitem"]')) };
|
||||
})
|
||||
.filter((item) => !item.reachable)
|
||||
.map((item) => item.label),
|
||||
);
|
||||
|
||||
expect(covered).toEqual([]);
|
||||
});
|
||||
|
||||
/**
|
||||
* The nearby-schools section at MOBILE.md's three reference widths.
|
||||
*
|
||||
|
||||
@@ -123,7 +123,7 @@ describe('C1 snippet copy', () => {
|
||||
|
||||
it('no C1 page claims a school count that will drift', () => {
|
||||
// The corpus moves with every data refresh; this repo has already shipped
|
||||
// one copy bug of that kind ("three schools" against MAX_SCHOOLS = 5).
|
||||
// one copy bug of that kind ("three schools" against a limit of five).
|
||||
for (const [, meta] of pages) {
|
||||
expect(meta.description as string).not.toMatch(/\b\d{2},\d{3}\b|\b\d{2},000\b/);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ describe('CompareAdmissions', () => {
|
||||
render(<CompareAdmissions schools={[grammar]} data={data} isSecondary={true} />);
|
||||
|
||||
expect(
|
||||
screen.getByText(/Entry is by entrance test — the school is selective/),
|
||||
screen.getByText(/Entry is by entrance test\. The school is selective/),
|
||||
).toBeInTheDocument();
|
||||
expect(screen.queryByText(/non-faith primaries/)).toBeNull();
|
||||
});
|
||||
|
||||
@@ -102,7 +102,7 @@ describe('CutoffMapPanel', () => {
|
||||
// Explanation is supporting text, not part of the bold verdict line.
|
||||
expect(result.querySelector('[class*="cutoffCheckHeadline"]')!.textContent)
|
||||
.not.toMatch(/measurement error/);
|
||||
expect(result).not.toHaveTextContent(/^\S+ away — inside/);
|
||||
expect(result).not.toHaveTextContent(/^\S+ away, inside/);
|
||||
});
|
||||
|
||||
it('surfaces a postcode the geocoder cannot find', async () => {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import ts from 'typescript';
|
||||
|
||||
/**
|
||||
* Keeps the em dash out of public copy.
|
||||
*
|
||||
* Every visitor-facing sentence was rewritten to use a colon, comma, full stop
|
||||
* or parentheses instead. A new one slips back in unnoticed, because it reads
|
||||
* fine to whoever wrote it, so this walks the source with the TypeScript parser
|
||||
* and checks every string literal, template chunk and JSX text node. Comments
|
||||
* are not nodes the walk visits, so they stay free to use it.
|
||||
*
|
||||
* Two uses are allowed:
|
||||
* - a lone dash standing in for a missing value in a table cell or stat slot,
|
||||
* which is a data convention rather than prose;
|
||||
* - the message of a thrown Error, which only a developer reads.
|
||||
*/
|
||||
|
||||
const ROOT = path.join(__dirname, '..', '..');
|
||||
const SCANNED = ['app', 'components', 'lib'];
|
||||
const SKIPPED = [path.join(ROOT, 'app', '(payload)')];
|
||||
|
||||
function sources(dir: string): string[] {
|
||||
if (SKIPPED.includes(dir)) return [];
|
||||
return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
||||
const full = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) return sources(full);
|
||||
return /\.tsx?$/.test(entry.name) ? [full] : [];
|
||||
});
|
||||
}
|
||||
|
||||
function isErrorMessage(node: ts.Node): boolean {
|
||||
for (let p = node.parent; p; p = p.parent) {
|
||||
if (ts.isNewExpression(p) && /Error$/.test(p.expression.getText())) return true;
|
||||
if (ts.isStatement(p)) return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const EMPTY_VALUE = /^(—|—)$/;
|
||||
|
||||
function dashedCopy(file: string): string[] {
|
||||
const text = fs.readFileSync(file, 'utf8');
|
||||
const kind = file.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
||||
const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, kind);
|
||||
const found: string[] = [];
|
||||
const visit = (node: ts.Node) => {
|
||||
if (
|
||||
ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node) || ts.isJsxText(node)
|
||||
|| ts.isTemplateHead(node) || ts.isTemplateMiddle(node) || ts.isTemplateTail(node)
|
||||
) {
|
||||
const copy = node.getText().replace(/\s+/g, ' ').trim();
|
||||
const bare = node.text.trim();
|
||||
if (/—|—/.test(copy) && !EMPTY_VALUE.test(bare) && !isErrorMessage(node)) {
|
||||
const { line } = sf.getLineAndCharacterOfPosition(node.getStart());
|
||||
found.push(`${path.relative(ROOT, file)}:${line + 1} ${copy}`);
|
||||
}
|
||||
}
|
||||
ts.forEachChild(node, visit);
|
||||
};
|
||||
visit(sf);
|
||||
return found;
|
||||
}
|
||||
|
||||
describe('public copy', () => {
|
||||
it('uses no em dashes', () => {
|
||||
const files = SCANNED.flatMap((dir) => sources(path.join(ROOT, dir)));
|
||||
expect(files.length).toBeGreaterThan(50);
|
||||
expect(files.flatMap(dashedCopy)).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -108,7 +108,7 @@ describe('all-through schools', () => {
|
||||
|
||||
it('labels the KS2 block explicitly', () => {
|
||||
renderSchoolDetail(allThroughFixture);
|
||||
expect(screen.getAllByText(/Primary — KS2 SATs/).length).toBeGreaterThan(0);
|
||||
expect(screen.getAllByText(/Primary: KS2 SATs/).length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* The basket limit is five per phase group, not five overall, and the
|
||||
* provider is where it is enforced for every add path.
|
||||
*
|
||||
* Entries without a phase count against both groups. Baskets saved before
|
||||
* phases were recorded hold such entries, so the compare page backfills them
|
||||
* once it has fetched each school.
|
||||
*/
|
||||
|
||||
import { act, render, screen, fireEvent } from '@testing-library/react';
|
||||
|
||||
import { AddToCompareButton } from '@/components/school/AddToCompareButton';
|
||||
import { ComparisonProvider } from '@/context/ComparisonProvider';
|
||||
import { useComparisonContext } from '@/context/ComparisonContext';
|
||||
import type { NearbySchool, School } from '@/lib/types';
|
||||
|
||||
type Ctx = ReturnType<typeof useComparisonContext>;
|
||||
|
||||
function renderBasket(stored: Partial<School>[] = []) {
|
||||
window.localStorage.setItem('selectedSchools', JSON.stringify(stored));
|
||||
const ref: { current: Ctx | null } = { current: null };
|
||||
function Probe() {
|
||||
ref.current = useComparisonContext();
|
||||
return null;
|
||||
}
|
||||
render(
|
||||
<ComparisonProvider>
|
||||
<Probe />
|
||||
</ComparisonProvider>,
|
||||
);
|
||||
return ref as { current: Ctx };
|
||||
}
|
||||
|
||||
const school = (urn: number, phase: string | null) =>
|
||||
({ urn, school_name: `School ${urn}`, phase }) as School;
|
||||
|
||||
beforeEach(() => {
|
||||
window.localStorage.clear();
|
||||
jest.spyOn(window, 'alert').mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => jest.restoreAllMocks());
|
||||
|
||||
it('holds five primary and five secondary schools, and no more of either', () => {
|
||||
const ctx = renderBasket();
|
||||
act(() => {
|
||||
for (let i = 0; i < 6; i++) ctx.current.addSchool(school(100000 + i, 'Primary'));
|
||||
for (let i = 0; i < 6; i++) ctx.current.addSchool(school(200000 + i, 'Secondary'));
|
||||
});
|
||||
expect(ctx.current.selectedSchools).toHaveLength(10);
|
||||
expect(window.alert).toHaveBeenCalledWith(expect.stringMatching(/5 primary schools/));
|
||||
expect(window.alert).toHaveBeenCalledWith(expect.stringMatching(/5 secondary schools/));
|
||||
});
|
||||
|
||||
it('frees the second group once a stored entry learns its phase', () => {
|
||||
// Three phase-less entries from an older basket plus two primaries: the
|
||||
// primary group reads as full although only two are really primary.
|
||||
const ctx = renderBasket([
|
||||
school(100001, null),
|
||||
school(100002, null),
|
||||
school(100003, null),
|
||||
school(100004, 'Primary'),
|
||||
school(100005, 'Primary'),
|
||||
]);
|
||||
expect(ctx.current.fullGroupFor({ phase: 'Primary' })).toBe('primary');
|
||||
|
||||
act(() => {
|
||||
ctx.current.backfillPhases({ 100001: 'Secondary', 100002: 'Secondary', 100003: 'Secondary' });
|
||||
});
|
||||
|
||||
expect(ctx.current.fullGroupFor({ phase: 'Primary' })).toBeNull();
|
||||
expect(ctx.current.selectedSchools.map((s) => s.phase)).toEqual([
|
||||
'Secondary',
|
||||
'Secondary',
|
||||
'Secondary',
|
||||
'Primary',
|
||||
'Primary',
|
||||
]);
|
||||
});
|
||||
|
||||
it('never overwrites a phase the basket already has', () => {
|
||||
const ctx = renderBasket([school(100001, 'Primary')]);
|
||||
act(() => ctx.current.backfillPhases({ 100001: 'All-through' }));
|
||||
expect(ctx.current.selectedSchools[0].phase).toBe('Primary');
|
||||
});
|
||||
|
||||
it('a nearby card adds its own phase, not an unknown one', () => {
|
||||
const nearby = {
|
||||
urn: 100009,
|
||||
school_name: 'Nearby',
|
||||
distance_miles: 0.4,
|
||||
school_type: 'Academy',
|
||||
age_range: '4-18',
|
||||
phase: 'All-through',
|
||||
shared: [],
|
||||
metric_value: null,
|
||||
metric_key: 'rwm_expected_pct',
|
||||
metric_year: null,
|
||||
} as NearbySchool;
|
||||
|
||||
const ref: { current: Ctx | null } = { current: null };
|
||||
function Probe() {
|
||||
ref.current = useComparisonContext();
|
||||
return null;
|
||||
}
|
||||
render(
|
||||
<ComparisonProvider>
|
||||
<Probe />
|
||||
<AddToCompareButton school={nearby} />
|
||||
</ComparisonProvider>,
|
||||
);
|
||||
fireEvent.click(screen.getByRole('button', { name: /Add to compare/ }));
|
||||
expect(ref.current?.selectedSchools[0].phase).toBe('All-through');
|
||||
});
|
||||
@@ -6,8 +6,12 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
MAX_PER_GROUP,
|
||||
OFSTED_LEGACY_GRADES,
|
||||
admissionsForPhase,
|
||||
compareGroups,
|
||||
fitToGroupLimits,
|
||||
fullGroupFor,
|
||||
ofstedDisplay,
|
||||
progressBand,
|
||||
rcAreaLabel,
|
||||
@@ -313,3 +317,48 @@ describe('latestValues', () => {
|
||||
expect(latestValues(data, [1], 'nope')).toEqual([null]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('basket limits per comparison group', () => {
|
||||
const school = (phase: string | null, urn = 0) => ({ urn, phase });
|
||||
const many = (phase: string | null, n: number, from = 0) =>
|
||||
Array.from({ length: n }, (_, i) => school(phase, from + i));
|
||||
|
||||
it('files each phase under its compare tab', () => {
|
||||
expect(compareGroups('Primary')).toEqual(['primary']);
|
||||
expect(compareGroups('Middle deemed primary')).toEqual(['primary']);
|
||||
expect(compareGroups('Secondary')).toEqual(['secondary']);
|
||||
expect(compareGroups('Middle deemed secondary')).toEqual(['secondary']);
|
||||
expect(compareGroups('16 plus')).toEqual(['secondary']);
|
||||
});
|
||||
|
||||
it('counts schools that could land in either tab against both', () => {
|
||||
expect(compareGroups('All-through')).toEqual(['primary', 'secondary']);
|
||||
expect(compareGroups('Not applicable')).toEqual(['primary', 'secondary']);
|
||||
expect(compareGroups(null)).toEqual(['primary', 'secondary']);
|
||||
});
|
||||
|
||||
it('a full primary group still admits secondary schools', () => {
|
||||
const basket = many('Primary', MAX_PER_GROUP);
|
||||
expect(fullGroupFor(basket, school('Primary'))).toBe('primary');
|
||||
expect(fullGroupFor(basket, school('Secondary'))).toBeNull();
|
||||
expect(fullGroupFor(basket, school('All-through'))).toBe('primary');
|
||||
});
|
||||
|
||||
it('allows ten schools in total, five per group', () => {
|
||||
const basket = [...many('Primary', 5), ...many('Secondary', 5, 5)];
|
||||
expect(fullGroupFor(basket, school('Primary'))).toBe('primary');
|
||||
expect(fullGroupFor(basket, school('Secondary'))).toBe('secondary');
|
||||
});
|
||||
|
||||
it('an all-through school uses a slot in both groups', () => {
|
||||
const basket = [school('All-through'), ...many('Primary', 4, 1)];
|
||||
expect(fullGroupFor(basket, school('Primary'))).toBe('primary');
|
||||
expect(fullGroupFor(basket, school('Secondary'))).toBeNull();
|
||||
});
|
||||
|
||||
it('trims an oversized shared link per group, keeping order', () => {
|
||||
const urls = [...many('Primary', 7), ...many('Secondary', 3, 7)];
|
||||
const kept = fitToGroupLimits(urls).map((s) => s.urn);
|
||||
expect(kept).toEqual([0, 1, 2, 3, 4, 7, 8, 9]);
|
||||
});
|
||||
});
|
||||
@@ -122,7 +122,7 @@ describe('compareToCutoff', () => {
|
||||
|
||||
it('reads back the reported case in one unit', () => {
|
||||
expect(compareToCutoff(69, 270, 2026).headline)
|
||||
.toBe('0.04 miles away — inside the September 2026 cut-off of 0.17 miles.');
|
||||
.toBe('0.04 miles away, inside the September 2026 cut-off of 0.17 miles.');
|
||||
});
|
||||
|
||||
it('calls a clearly nearer home inside, and names the year', () => {
|
||||
|
||||
@@ -33,9 +33,9 @@ export async function generateMetadata(
|
||||
// Deliberately not the homepage's phrase. Two pages chasing "compare
|
||||
// schools" is how a site competes with itself; this one takes the tool
|
||||
// phrasing instead.
|
||||
title: 'School Comparison Tool — Up to Five at Once | schoolcompare',
|
||||
title: 'School Comparison Tool: Primary and Secondary Schools | schoolcompare',
|
||||
description:
|
||||
'Put up to five English schools in one table: SATs and GCSE results against the England average, Ofsted grades, and the distance places were offered.',
|
||||
'Put up to five primary and five secondary schools in England in one table: SATs and GCSE results against the England average, Ofsted grades, and the distance places were offered.',
|
||||
keywords:
|
||||
'school comparison, compare schools, Ofsted comparison, school admissions, KS2 comparison, primary school performance',
|
||||
alternates: { canonical: absoluteUrl('/compare') },
|
||||
|
||||
@@ -54,7 +54,7 @@ export const metadata: Metadata = {
|
||||
template: '%s | schoolcompare',
|
||||
},
|
||||
description:
|
||||
'Put five English schools on one screen — SATs, GCSE results, Ofsted grades, and how close you had to live to get a place. Free, no sign-up.',
|
||||
'Put five English schools on one screen: SATs, GCSE results, Ofsted grades, and how close you had to live to get a place. Free, no sign-up.',
|
||||
keywords: 'school comparison, KS2 results, KS4 results, primary school, secondary school, England schools, SATs results, GCSE results',
|
||||
authors: [{ name: 'schoolcompare' }],
|
||||
manifest: '/manifest.json',
|
||||
@@ -69,7 +69,7 @@ export const metadata: Metadata = {
|
||||
type: 'website',
|
||||
title: 'Compare Schools Side by Side | schoolcompare',
|
||||
description:
|
||||
'Put five English schools on one screen — SATs, GCSE results, Ofsted grades, and how close you had to live to get a place.',
|
||||
'Put five English schools on one screen: SATs, GCSE results, Ofsted grades, and how close you had to live to get a place.',
|
||||
/*
|
||||
* Declared, not inherited.
|
||||
*
|
||||
@@ -93,7 +93,7 @@ export const metadata: Metadata = {
|
||||
card: 'summary_large_image',
|
||||
title: 'Compare Schools Side by Side | schoolcompare',
|
||||
description:
|
||||
'Put five English schools on one screen — SATs, GCSE results, Ofsted grades, and how close you had to live to get a place.',
|
||||
'Put five English schools on one screen: SATs, GCSE results, Ofsted grades, and how close you had to live to get a place.',
|
||||
// The card is summary_large_image; claiming that and supplying no image
|
||||
// is worse than claiming a summary card.
|
||||
images: ['/opengraph-image'],
|
||||
|
||||
@@ -49,7 +49,7 @@ export const metadata: Metadata = {
|
||||
*/
|
||||
title: { absolute: 'Compare Schools Side by Side | schoolcompare' },
|
||||
description:
|
||||
'Put five English schools on one screen — SATs, GCSE results, Ofsted grades, and how close you had to live to get a place. Free, no sign-up.',
|
||||
'Put five English schools on one screen: SATs, GCSE results, Ofsted grades, and how close you had to live to get a place. Free, no sign-up.',
|
||||
// This page reads eleven search params. They filter a result set; they do
|
||||
// not make a new document. Collapsing every combination onto "/" stops the
|
||||
// homepage competing with itself for its own head terms.
|
||||
|
||||
@@ -56,7 +56,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
// absolute: the root layout's template appends '| schoolcompare' to a
|
||||
// plain string, and this title already carries it. Without this every
|
||||
// place title read '... | schoolcompare | schoolcompare'.
|
||||
title: { absolute: `Schools in ${name} — Compare ${count} Schools | schoolcompare` },
|
||||
title: { absolute: `Schools in ${name}: Compare ${count} Schools | schoolcompare` },
|
||||
description:
|
||||
`Every school in ${name}, with SATs and GCSE results, Ofsted grades, the local `
|
||||
+ `average against England, and how close you had to live to get a place.`,
|
||||
|
||||
@@ -41,7 +41,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
// "Local Authority" stays in the title for the same reason it is on the
|
||||
// bare authority page: 67 town names collide with an authority name, and
|
||||
// a reader landing on both needs to know which set each covers.
|
||||
title: { absolute: `${word} Schools in ${name} — Local Authority | schoolcompare` },
|
||||
title: { absolute: `${word} Schools in ${name} (Local Authority) | schoolcompare` },
|
||||
description:
|
||||
`Every ${phase} school in the ${name} local authority, with results, Ofsted `
|
||||
+ `grades and the authority average against England.`,
|
||||
|
||||
@@ -43,7 +43,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
|
||||
const { name, count } = detail.place;
|
||||
return {
|
||||
title: { absolute: `Schools in ${name} — Local Authority | schoolcompare` },
|
||||
title: { absolute: `Schools in ${name} (Local Authority) | schoolcompare` },
|
||||
description:
|
||||
`All ${count} schools in the ${name} local authority, with SATs and GCSE results, `
|
||||
+ `Ofsted grades and the authority average against England.`,
|
||||
|
||||
@@ -11,7 +11,7 @@ import { ImageResponse } from 'next/og';
|
||||
* and a suggestion of the illustration's rolling landscape along the bottom.
|
||||
* It states the promise rather than decorating it.
|
||||
*/
|
||||
export const alt = 'schoolcompare — find the school where your child will flourish';
|
||||
export const alt = 'schoolcompare: find the school where your child will flourish';
|
||||
export const size = { width: 1200, height: 630 };
|
||||
export const contentType = 'image/png';
|
||||
|
||||
|
||||
@@ -64,11 +64,11 @@ interface Step {
|
||||
const SECONDARY_STEPS: Step[] = [
|
||||
{
|
||||
title: 'Check entry criteria',
|
||||
body: 'Look at each school\'s admissions policy — catchment areas, faith criteria, sibling priority, and aptitude tests vary widely.',
|
||||
body: 'Look at each school\'s admissions policy. Catchment areas, faith criteria, sibling priority and aptitude tests vary widely.',
|
||||
callouts: [
|
||||
{
|
||||
title: 'Selective schools register earlier',
|
||||
body: 'Grammar and other selective schools need separate entrance-test registration months earlier — often by September, well before the 31 October deadline.',
|
||||
body: 'Grammar and other selective schools need separate entrance-test registration months earlier, often by September and well before the 31 October deadline.',
|
||||
},
|
||||
{
|
||||
title: 'Faith schools may need an extra form',
|
||||
@@ -86,26 +86,26 @@ const SECONDARY_STEPS: Step[] = [
|
||||
{
|
||||
date: '31 October',
|
||||
title: 'Application deadline',
|
||||
body: 'Submit your ranked list of schools — most councils allow three to six preferences (London boroughs typically six). Councils treat all preferences equally, so list schools in the genuine order you want them, not strategically.',
|
||||
body: 'Submit your ranked list of schools. Most councils allow three to six preferences (London boroughs typically six). Councils treat all preferences equally, so list schools in the genuine order you want them, not strategically.',
|
||||
highlight: 'deadline',
|
||||
tool: { label: 'Compare performance to order your preferences', href: '/rankings' },
|
||||
},
|
||||
{
|
||||
date: '1 March',
|
||||
title: 'National Offer Day',
|
||||
body: 'Your allocated school appears on the council\'s online admissions portal and is sent by email. Release times are set by each council — often from late afternoon, though some publish overnight — so check your council\'s page rather than refreshing at midnight.',
|
||||
body: 'Your allocated school appears on the council\'s online admissions portal and is sent by email. Release times are set by each council (often from late afternoon, though some publish overnight), so check your council\'s page rather than refreshing at midnight.',
|
||||
highlight: 'offer',
|
||||
tool: { label: 'Look up your allocated school', href: '/' },
|
||||
},
|
||||
{
|
||||
date: '~15 March',
|
||||
title: 'Accept or decline',
|
||||
body: 'Respond by the deadline your council gives — typically around 15 March. Accepting does not prevent you from keeping a place on a waiting list for a preferred school.',
|
||||
body: 'Respond by the deadline your council gives, typically around 15 March. Accepting does not prevent you from keeping a place on a waiting list for a preferred school.',
|
||||
tool: { label: 'Weigh your offer against your other choices', href: '/compare' },
|
||||
},
|
||||
{
|
||||
title: 'Appeals',
|
||||
body: 'If unsuccessful, you can appeal within 20 school days of the refusal letter. Secondary appeals consider whether prejudice to the school outweighs your case — success rates vary.',
|
||||
body: 'If unsuccessful, you can appeal within 20 school days of the refusal letter. Secondary appeals consider whether prejudice to the school outweighs your case, and success rates vary.',
|
||||
tool: { label: 'Gather performance evidence for your case', href: '/rankings' },
|
||||
},
|
||||
];
|
||||
@@ -163,7 +163,7 @@ interface Tip {
|
||||
const TIPS: Tip[] = [
|
||||
{
|
||||
heading: 'Equal preference rule',
|
||||
body: 'Councils consider every school you list before making any offer, then give you the highest-ranked one you qualify for. Your order only decides which qualifying school you get — you can\'t game it, so list schools in the order you genuinely want them.',
|
||||
body: 'Councils consider every school you list before making any offer, then give you the highest-ranked one you qualify for. Your order only decides which qualifying school you get. You can\'t game it, so list schools in the order you genuinely want them.',
|
||||
},
|
||||
{
|
||||
heading: 'Late applications go to the back',
|
||||
@@ -259,7 +259,7 @@ export function AdmissionsView() {
|
||||
</span>
|
||||
<h1 className={styles.heroTitle}>School Admissions Guide</h1>
|
||||
<p className={styles.heroSub}>
|
||||
Everything parents need to know about applying for a school place in England — from opening dates to National Offer Day, with live countdowns to every key milestone.
|
||||
Everything parents need to know about applying for a school place in England, from opening dates to National Offer Day, with live countdowns to every key milestone.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ interface ComparisonChartProps {
|
||||
isSecondary?: boolean;
|
||||
}
|
||||
|
||||
// One shape per basket slot (MAX_SCHOOLS = 5) — secondary encoding so
|
||||
// One shape per slot in a phase tab (MAX_PER_GROUP = 5) — secondary encoding so
|
||||
// converging lines stay tellable apart without relying on hue alone.
|
||||
const POINT_STYLES: PointStyle[] = ['circle', 'triangle', 'rect', 'rectRot', 'star'];
|
||||
|
||||
@@ -258,15 +258,15 @@ export function ComparisonChart({ comparisonData, schools, metric, metricLabel,
|
||||
// published by DfE but aren't in our dataset yet.
|
||||
<p className={styles.chartNote}>
|
||||
School-level GCSE figures for 2019/20 and 2020/21 weren't published (COVID
|
||||
grading), and more recent years aren't in our dataset yet where lines break — the
|
||||
England average is shown where available.
|
||||
grading), and more recent years aren't in our dataset yet. Where lines break, the
|
||||
England average is shown if available.
|
||||
</p>
|
||||
) : (
|
||||
!isSecondary &&
|
||||
built.showUnpublished202122Note && (
|
||||
<p className={styles.chartNote}>
|
||||
No national tests were held in 2019/20 and 2020/21 (COVID), and DfE didn't publish
|
||||
school-level figures for 2021/22 — the England average is shown for that year.
|
||||
school-level figures for 2021/22. The England average is shown for that year.
|
||||
</p>
|
||||
)
|
||||
)}
|
||||
|
||||
@@ -53,7 +53,8 @@ export function ComparisonView({
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const { selectedSchools, removeSchool, replaceSchools, isInitialized } = useComparison();
|
||||
const { selectedSchools, removeSchool, replaceSchools, backfillPhases, isInitialized } =
|
||||
useComparison();
|
||||
|
||||
const [selectedMetric, setSelectedMetric] = useState(initialMetric);
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
@@ -157,6 +158,17 @@ export function ComparisonView({
|
||||
};
|
||||
}, [urnKey, isInitialized]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!comparisonData) return;
|
||||
backfillPhases(
|
||||
Object.fromEntries(
|
||||
Object.values(comparisonData)
|
||||
.filter((d) => d?.school_info)
|
||||
.map((d) => [d.school_info.urn, d.school_info.phase]),
|
||||
),
|
||||
);
|
||||
}, [comparisonData, backfillPhases]);
|
||||
|
||||
const primarySchools = selectedSchools.filter((school) => {
|
||||
const info = comparisonData?.[school.urn]?.school_info;
|
||||
const hasPrimaryData =
|
||||
@@ -263,7 +275,7 @@ export function ComparisonView({
|
||||
<header className={styles.header}>
|
||||
<h1>Compare Schools</h1>
|
||||
<p className={styles.subtitle}>
|
||||
Add schools to your comparison basket to see them side by side — inspection results,
|
||||
Add schools to your comparison basket to see them side by side: inspection results,
|
||||
academics, admissions and community.
|
||||
</p>
|
||||
</header>
|
||||
@@ -300,8 +312,8 @@ export function ComparisonView({
|
||||
<div>
|
||||
<h1>Compare Schools</h1>
|
||||
<p className={styles.subtitle}>
|
||||
{selectedSchools.length} school{selectedSchools.length !== 1 ? 's' : ''} side by side
|
||||
— each number anchored against the England average so you can tell at a glance
|
||||
{selectedSchools.length} school{selectedSchools.length !== 1 ? 's' : ''} side by side,
|
||||
each number anchored against the England average so you can tell at a glance
|
||||
what's typical and what stands out.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -47,7 +47,7 @@ export function EditorialSection({
|
||||
<p>
|
||||
School performance data in England is rich but fragmented. The Department for Education and Ofsted
|
||||
publish Key Stage 2 SATs, GCSE attainment, inspection outcomes, progress scores, admissions figures
|
||||
and demographics — each in its own table, each with its own jargon.
|
||||
and demographics, each in its own table with its own jargon.
|
||||
</p>
|
||||
<p>
|
||||
schoolcompare brings it all into one place. Every school page shows performance against the national
|
||||
|
||||
@@ -323,7 +323,7 @@ export function FilterBar({
|
||||
{isHero && (
|
||||
<>
|
||||
<p className={styles.searchHint}>
|
||||
Search by <strong>school name</strong> — or use your{" "}
|
||||
Search by <strong>school name</strong>, or use your{" "}
|
||||
<strong>postcode</strong> for the nearest schools.
|
||||
</p>
|
||||
{onNearMe && (
|
||||
|
||||
@@ -149,11 +149,12 @@ interface ValueProp {
|
||||
* and is backed by the next-deadline bar further down this page.
|
||||
*
|
||||
* Every claim here must name something the product actually does. Two of the
|
||||
* four previously did not: "up to three schools" contradicted MAX_SCHOOLS = 5
|
||||
* in context/ComparisonProvider.tsx (and the card further down the page, which
|
||||
* correctly said five), and "class sizes" described data the codebase has never
|
||||
* held — grep for it and this line was the only hit. Both are corrected below
|
||||
* against the real fields, which live in components/school/InclusionSection.tsx.
|
||||
* four previously did not: "up to three schools" contradicted the basket limit
|
||||
* of five (and the card further down the page, which correctly said five), and
|
||||
* "class sizes" described data the codebase has never held — grep for it and
|
||||
* this line was the only hit. Both are corrected below against the real
|
||||
* fields, which live in components/school/InclusionSection.tsx.
|
||||
* The limit is now five per phase: MAX_PER_GROUP in lib/compareLogic.ts.
|
||||
*/
|
||||
const VALUE_PROPS: ValueProp[] = [
|
||||
{
|
||||
@@ -179,13 +180,13 @@ const VALUE_PROPS: ValueProp[] = [
|
||||
icon: <BarsIcon />,
|
||||
tintClass: styles.propIconCompare,
|
||||
title: 'Easy to compare',
|
||||
body: 'Up to five schools side by side, on the measures that matter.',
|
||||
body: 'Up to five primary and five secondary schools side by side, on the measures that matter.',
|
||||
},
|
||||
{
|
||||
icon: <HeartIcon />,
|
||||
tintClass: styles.propIconContext,
|
||||
title: 'Beyond the numbers',
|
||||
body: 'SEN support, pupil premium and attendance — not just results.',
|
||||
body: 'Not just results: SEN support, pupil premium and attendance too.',
|
||||
},
|
||||
{
|
||||
icon: <CalendarIcon />,
|
||||
@@ -478,8 +479,8 @@ export function HomeView({ initialSchools, filters, totalSchools, howItWorks, ed
|
||||
every line above the fold costs. */}
|
||||
<span className={styles.heroDescriptionFull}>
|
||||
{' '}Key Stage 2 SATs, GCSE results, Ofsted grades, progress scores
|
||||
and admissions data{coverageLabel && <> for <strong>{coverageLabel} schools</strong></>} — side by
|
||||
side, in one place.
|
||||
and admissions data{coverageLabel && <> for <strong>{coverageLabel} schools</strong></>}, side by
|
||||
side in one place.
|
||||
</span>
|
||||
</p>
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export function HowItWorksSection() {
|
||||
<div className={styles.sectionHead}>
|
||||
<p className={styles.sectionKicker}>Every school page</p>
|
||||
<h2 className={styles.sectionHeading}>What you'll see on every school</h2>
|
||||
<p className={styles.sectionAside}>Primary or secondary — the page adapts to the phase</p>
|
||||
<p className={styles.sectionAside}>The page adapts to primary or secondary</p>
|
||||
</div>
|
||||
<div className={styles.hiwGrid}>
|
||||
{/* Card 1 — Performance */}
|
||||
@@ -123,7 +123,7 @@ export function HowItWorksSection() {
|
||||
<div className={styles.hiwCardBody}>
|
||||
<div className={styles.hiwStep}>Judgement</div>
|
||||
<div className={styles.hiwTitle}>Ofsted at a glance</div>
|
||||
<p className={styles.hiwDesc}>Since November 2025, Ofsted rates each area of school life on a five-point scale rather than one overall word. We show every area and the inspection date — and, for schools not yet reinspected, the older overall grade they still carry.</p>
|
||||
<p className={styles.hiwDesc}>Since November 2025, Ofsted rates each area of school life on a five-point scale rather than one overall word. We show every area, the inspection date and, for schools not yet reinspected, the older overall grade they still carry.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -143,7 +143,7 @@ export function HowItWorksSection() {
|
||||
<span className={styles.compareRowVal}>{b}</span>
|
||||
</div>
|
||||
))}
|
||||
<div className={styles.compareFoot}>+ compare up to 5 schools</div>
|
||||
<div className={styles.compareFoot}>+ up to 5 primary & 5 secondary</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.hiwCardBody}>
|
||||
@@ -152,7 +152,7 @@ export function HowItWorksSection() {
|
||||
{/* One verb for one feature. The site previously called this
|
||||
"compare" in the nav, "shortlist" in the footer and "pin" here,
|
||||
which reads as three separate things it does not have. */}
|
||||
<p className={styles.hiwDesc}>Compare up to five schools and every metric aligns in the same columns — works for primary and secondary alike.</p>
|
||||
<p className={styles.hiwDesc}>Compare primary and secondary school performance side by side: KS2 SATs results for primary schools, GCSE Attainment 8 for secondary schools, and Ofsted ratings for both, lined up in one table so you can see where each school is stronger.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -114,7 +114,7 @@ export function PerformanceChart({
|
||||
const delta = latest.rwm_expected_pct! - prev.rwm_expected_pct!;
|
||||
const arrow = delta > 1 ? '↑' : delta < -1 ? '↓' : '→';
|
||||
if (best.year === latest.year) {
|
||||
return `${arrow} Best year on record — ${latestPct}% met the expected standard in Reading, Writing & Maths`;
|
||||
return `${arrow} Best year on record: ${latestPct}% met the expected standard in Reading, Writing & Maths`;
|
||||
}
|
||||
return `${arrow} Reading, Writing & Maths peaked at ${bestPct}% (${formatAcademicYear(best.year)}), currently ${latestPct}%`;
|
||||
})();
|
||||
@@ -451,15 +451,15 @@ export function PerformanceChart({
|
||||
{hasGap && (
|
||||
<p className={styles.covidNote}>
|
||||
{isSecondary
|
||||
? "School-level GCSE figures for 2019/20 and 2020/21 weren't published (COVID grading) where the line breaks — the England average is shown where available."
|
||||
: "No national tests were held in 2019/20 and 2020/21 (COVID), and DfE didn't publish school-level figures for 2021/22 — the England average is shown for those years where available."}
|
||||
? "School-level GCSE figures for 2019/20 and 2020/21 weren't published (COVID grading). Where the line breaks, the England average is shown if available."
|
||||
: "No national tests were held in 2019/20 and 2020/21 (COVID), and DfE didn't publish school-level figures for 2021/22. Where available, the England average is shown for those years."}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Desktop-only hint about toggling progress in the legend */}
|
||||
{!isSecondary && (
|
||||
<p className={styles.chartHint}>
|
||||
Progress scores (Reading, Writing, Maths) are hidden by default — click them in the legend to show.
|
||||
Progress scores (Reading, Writing, Maths) are hidden by default. Click them in the legend to show them.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -95,6 +95,9 @@ export function RankingsView({
|
||||
const handleAddToCompare = (ranking: RankingEntry) => {
|
||||
addSchool({
|
||||
...ranking,
|
||||
// Ranking rows carry no phase, but the tab they're ranked under is
|
||||
// theirs. The compare basket's per-phase limit needs it.
|
||||
phase: isPrimary ? 'Primary' : 'Secondary',
|
||||
address: null,
|
||||
postcode: null,
|
||||
latitude: null,
|
||||
@@ -119,7 +122,7 @@ export function RankingsView({
|
||||
<h1>School Rankings</h1>
|
||||
<p className={styles.subtitle}>
|
||||
Schools ranked by {metricLabel.toLowerCase()}
|
||||
{!selectedArea && rankings.length > 0 && <span className={styles.limitNote}> — showing top {rankings.length}</span>}
|
||||
{!selectedArea && rankings.length > 0 && <span className={styles.limitNote}> (showing top {rankings.length})</span>}
|
||||
</p>
|
||||
</header>
|
||||
|
||||
@@ -145,7 +148,7 @@ export function RankingsView({
|
||||
{isProgressScore && (
|
||||
<p className={styles.progressHint}>
|
||||
Progress scores: 0 = national average. Positive = above average.
|
||||
{isPrimary && ' KS2 progress isn’t published for 2023/24 or 2024/25 (there’s no key stage 1 baseline) — pick an earlier year to rank by it.'}
|
||||
{isPrimary && ' KS2 progress isn’t published for 2023/24 or 2024/25 because there’s no key stage 1 baseline. Pick an earlier year to rank by it.'}
|
||||
</p>
|
||||
)}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { useComparison } from "@/hooks/useComparison";
|
||||
import { debounce } from "@/lib/utils";
|
||||
import { fetchSchools } from "@/lib/api";
|
||||
import { track } from "@/lib/analytics";
|
||||
import { MAX_PER_GROUP } from "@/lib/compareLogic";
|
||||
import type { School } from "@/lib/types";
|
||||
import styles from "./SchoolSearchModal.module.css";
|
||||
|
||||
@@ -20,7 +21,7 @@ interface SchoolSearchModalProps {
|
||||
}
|
||||
|
||||
export function SchoolSearchModal({ isOpen, onClose }: SchoolSearchModalProps) {
|
||||
const { addSchool, selectedSchools, canAddMore } = useComparison();
|
||||
const { addSchool, selectedSchools, fullGroupFor } = useComparison();
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [results, setResults] = useState<School[]>([]);
|
||||
const [isSearching, setIsSearching] = useState(false);
|
||||
@@ -73,6 +74,19 @@ export function SchoolSearchModal({ isOpen, onClose }: SchoolSearchModalProps) {
|
||||
return selectedSchools.some((s) => s.urn === urn);
|
||||
};
|
||||
|
||||
// Limits apply per phase group, so a full primary list must not stop a
|
||||
// parent adding secondary schools.
|
||||
const primaryFull = fullGroupFor({ phase: "Primary" }) !== null;
|
||||
const secondaryFull = fullGroupFor({ phase: "Secondary" }) !== null;
|
||||
const limitWarning =
|
||||
primaryFull && secondaryFull
|
||||
? `You're comparing ${MAX_PER_GROUP} primary and ${MAX_PER_GROUP} secondary schools, the most at once. Remove a school to add another.`
|
||||
: primaryFull
|
||||
? `You're comparing ${MAX_PER_GROUP} primary schools, the most at once. You can still add secondary schools.`
|
||||
: secondaryFull
|
||||
? `You're comparing ${MAX_PER_GROUP} secondary schools, the most at once. You can still add primary schools.`
|
||||
: null;
|
||||
|
||||
const handleClose = () => {
|
||||
setSearchTerm("");
|
||||
setResults([]);
|
||||
@@ -83,10 +97,8 @@ export function SchoolSearchModal({ isOpen, onClose }: SchoolSearchModalProps) {
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={handleClose} title="Add School to Comparison">
|
||||
<div className={styles.modalContent}>
|
||||
{!canAddMore && (
|
||||
<div className={styles.warning}>
|
||||
Maximum 5 schools can be compared. Remove a school to add another.
|
||||
</div>
|
||||
{limitWarning && (
|
||||
<div className={styles.warning}>{limitWarning}</div>
|
||||
)}
|
||||
|
||||
{/* Search Input */}
|
||||
@@ -112,6 +124,7 @@ export function SchoolSearchModal({ isOpen, onClose }: SchoolSearchModalProps) {
|
||||
|
||||
{results.map((school) => {
|
||||
const alreadySelected = isSchoolSelected(school.urn);
|
||||
const fullGroup = alreadySelected ? null : fullGroupFor(school);
|
||||
|
||||
return (
|
||||
<div key={school.urn} className={styles.resultItem}>
|
||||
@@ -126,12 +139,16 @@ export function SchoolSearchModal({ isOpen, onClose }: SchoolSearchModalProps) {
|
||||
</div>
|
||||
<button
|
||||
onClick={() => handleAddSchool(school)}
|
||||
disabled={alreadySelected || !canAddMore}
|
||||
disabled={alreadySelected || fullGroup !== null}
|
||||
className={`${styles.resultButton} ${
|
||||
alreadySelected ? "btn btn-active" : "btn btn-secondary"
|
||||
}`}
|
||||
>
|
||||
{alreadySelected ? "✓ Comparing" : "+ Compare"}
|
||||
{alreadySelected
|
||||
? "✓ Comparing"
|
||||
: fullGroup
|
||||
? `${fullGroup === "primary" ? "Primary" : "Secondary"} full`
|
||||
: "+ Compare"}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -33,14 +33,14 @@ export function SpecialSchoolNote({ school }: { school: { school_type?: string |
|
||||
<>
|
||||
<strong>This is a special school.</strong> Its pupils have special educational needs and
|
||||
work towards individual targets. They sit the same national assessments, but very few
|
||||
reach the mainstream “expected standard” these measures report — so a
|
||||
reach the mainstream “expected standard” these measures report, so a
|
||||
comparison with the England average isn’t a meaningful guide to the school.
|
||||
</>
|
||||
)}
|
||||
{kind === 'pru' && (
|
||||
<>
|
||||
<strong>This is a pupil referral unit.</strong> It teaches pupils educated outside a
|
||||
mainstream school — for example after exclusion, or for medical or behavioural reasons.
|
||||
mainstream school, for example after exclusion or for medical or behavioural reasons.
|
||||
The mainstream “expected standard” and the England-average comparison
|
||||
aren’t a meaningful guide to the school.
|
||||
</>
|
||||
|
||||
@@ -26,7 +26,7 @@ interface StripSpec {
|
||||
|
||||
const TIER1_PRIMARY: StripSpec[] = [
|
||||
{
|
||||
label: 'Reading, writing & maths — expected standard',
|
||||
label: 'Reading, writing & maths: expected standard',
|
||||
metric: 'rwm_expected_pct',
|
||||
anchorKey: 'rwm_expected_pct',
|
||||
tip: '% of Year 6 pupils reaching the expected standard in reading, writing and maths.',
|
||||
@@ -49,18 +49,18 @@ const TIER1_PRIMARY: StripSpec[] = [
|
||||
|
||||
const TIER2_PRIMARY: StripSpec[] = [
|
||||
{
|
||||
label: 'Grammar, punctuation & spelling — expected standard',
|
||||
label: 'Grammar, punctuation & spelling: expected standard',
|
||||
metric: 'gps_expected_pct',
|
||||
anchorKey: 'gps_expected_pct',
|
||||
},
|
||||
{
|
||||
label: 'Science — expected standard (teacher-assessed)',
|
||||
label: 'Science: expected standard (teacher-assessed)',
|
||||
metric: 'science_expected_pct',
|
||||
anchorKey: 'science_expected_pct',
|
||||
tip: 'Teacher-assessed, like writing — there has been no KS2 science test since 2009, so comparisons are indicative.',
|
||||
tip: 'Teacher-assessed, like writing. There has been no KS2 science test since 2009, so comparisons are indicative.',
|
||||
},
|
||||
{
|
||||
label: 'Average scaled score — reading',
|
||||
label: 'Average scaled score: reading',
|
||||
metric: 'reading_avg_score',
|
||||
anchorKey: 'reading_avg_score',
|
||||
min: 100,
|
||||
@@ -68,7 +68,7 @@ const TIER2_PRIMARY: StripSpec[] = [
|
||||
unit: '',
|
||||
},
|
||||
{
|
||||
label: 'Average scaled score — maths',
|
||||
label: 'Average scaled score: maths',
|
||||
metric: 'maths_avg_score',
|
||||
anchorKey: 'maths_avg_score',
|
||||
min: 100,
|
||||
@@ -76,7 +76,7 @@ const TIER2_PRIMARY: StripSpec[] = [
|
||||
unit: '',
|
||||
},
|
||||
{
|
||||
label: 'Average scaled score — grammar, punctuation & spelling',
|
||||
label: 'Average scaled score: grammar, punctuation & spelling',
|
||||
metric: 'gps_avg_score',
|
||||
anchorKey: 'gps_avg_score',
|
||||
min: 100,
|
||||
@@ -193,7 +193,7 @@ export function CompareAcademics({
|
||||
return (
|
||||
<Section
|
||||
title="How students do academically"
|
||||
how="GCSE results (latest year). Attainment 8 averages performance across eight subjects; Progress 8 shows how much progress students make compared with similar students nationally — the wording is DfE's own banding."
|
||||
how="GCSE results (latest year). Attainment 8 averages performance across eight subjects; Progress 8 shows how much progress students make compared with similar students nationally. The wording is DfE's own banding."
|
||||
>
|
||||
<SectionGrid schools={schools}>
|
||||
<RowLabel tip="Average Attainment 8 score across eight GCSE subjects.">Attainment 8</RowLabel>
|
||||
@@ -230,7 +230,7 @@ export function CompareAcademics({
|
||||
</Chip>
|
||||
) : p8NotPublished[i] ? (
|
||||
<span className={s.small}>
|
||||
Not published — this GCSE year group sat no KS2 tests (COVID), so DfE has no
|
||||
Not published: this GCSE year group sat no KS2 tests (COVID), so DfE has no
|
||||
baseline to measure progress from
|
||||
</span>
|
||||
) : (
|
||||
@@ -308,7 +308,7 @@ export function CompareAcademics({
|
||||
return (
|
||||
<Section
|
||||
title="How children do academically"
|
||||
how="Results from national tests and teacher assessments at the end of Year 6 — writing is assessed by teachers, not tested. Each line runs from 0–100%; the grey tick marks the England average, so dots to its right are above average."
|
||||
how="Results from national tests and teacher assessments at the end of Year 6 (writing is assessed by teachers, not tested). Each line runs from 0–100%; the grey tick marks the England average, so dots to its right are above average."
|
||||
>
|
||||
<div className={s.card}>
|
||||
{TIER1_PRIMARY.map((spec) => (
|
||||
@@ -324,7 +324,7 @@ export function CompareAcademics({
|
||||
))}
|
||||
|
||||
<details className={styles.moreMeasures}>
|
||||
<summary>More measures — grammar, punctuation & spelling, science, average scaled scores</summary>
|
||||
<summary>More measures: grammar, punctuation & spelling, science, average scaled scores</summary>
|
||||
{TIER2_PRIMARY.map((spec) => (
|
||||
<Strip
|
||||
key={spec.metric}
|
||||
|
||||
@@ -49,17 +49,17 @@ export function CompareAdmissions({
|
||||
how={
|
||||
<>
|
||||
From the most recent admissions round ({entryLabel}). "First choice" means
|
||||
families who ranked the school top of their application form — officially a "first
|
||||
preference". Schools never see your ranking: places are decided only by the
|
||||
families who ranked the school top of their application form (officially a "first
|
||||
preference"). Schools never see your ranking: places are decided only by the
|
||||
school's admission criteria, so listing a school lower down never hurts your chances.
|
||||
These are National Offer Day offers — waiting lists and appeals can change the final
|
||||
These are National Offer Day offers. Waiting lists and appeals can change the final
|
||||
intake.
|
||||
</>
|
||||
}
|
||||
>
|
||||
<SectionGrid schools={schools}>
|
||||
<Measure
|
||||
tip="How many application forms named the school at any preference rank — not the number of families competing head-to-head for a place."
|
||||
tip="How many application forms named the school at any preference rank. This is not the number of families competing head-to-head for a place."
|
||||
label="Interest in the school"
|
||||
>
|
||||
{schools.map((school, i) => {
|
||||
@@ -126,7 +126,7 @@ export function CompareAdmissions({
|
||||
// Selective schools: the entrance test decides, whatever the
|
||||
// offer percentage looks like — never the distance template.
|
||||
text =
|
||||
'Entry is by entrance test — the school is selective; distance and preference rank don’t decide places.';
|
||||
'Entry is by entrance test. The school is selective, so distance and preference rank don’t decide places.';
|
||||
} else if (summary.firstPrefPct >= 100) {
|
||||
text = `Every family who put ${school.school_name} first got a place.`;
|
||||
} else if (summary.firstPrefPct >= 90) {
|
||||
@@ -134,9 +134,9 @@ export function CompareAdmissions({
|
||||
} else if (a?.oversubscribed) {
|
||||
text = isSecondary
|
||||
? faith
|
||||
? 'More first-choice applications than places — check the school’s admission criteria (faith-based criteria may apply).'
|
||||
: 'More first-choice applications than places — check the school’s admission criteria (catchment or distance often decides, but criteria vary).'
|
||||
: 'More first-choice applications than places — check the school’s admission criteria (for most non-faith primaries, distance decides).';
|
||||
? 'More first-choice applications than places. Check the school’s admission criteria (faith-based criteria may apply).'
|
||||
: 'More first-choice applications than places. Check the school’s admission criteria (catchment or distance often decides, but criteria vary).'
|
||||
: 'More first-choice applications than places. Check the school’s admission criteria (for most non-faith primaries, distance decides).';
|
||||
} else {
|
||||
text = `${summary.firstPrefPct}% of first-choice families received an offer.`;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export function CompareAtAGlance({
|
||||
: benchmarks?.primary?.median_pupils;
|
||||
|
||||
return (
|
||||
<Section title="At a glance" how="The short version — each row below is explained in its own section further down.">
|
||||
<Section title="At a glance" how="The short version. Each row below is explained in its own section further down.">
|
||||
<SectionGrid schools={schools}>
|
||||
<Measure label="Latest Ofsted inspection">
|
||||
{schools.map((school, i) => {
|
||||
|
||||
@@ -56,12 +56,12 @@ export function CompareCommunity({
|
||||
how={
|
||||
<>
|
||||
The school's community, from the latest school census. State-school averages are
|
||||
computed from our dataset and shown for context — there's no “right”
|
||||
computed from our dataset and shown for context. There's no “right”
|
||||
number here.
|
||||
{anyAllThrough && (
|
||||
<>
|
||||
{' '}
|
||||
For all-through schools these figures cover the whole school, all ages — not just
|
||||
For all-through schools these figures cover the whole school and all ages, not just
|
||||
the {isSecondary ? 'secondary' : 'primary'} phase.
|
||||
</>
|
||||
)}
|
||||
@@ -79,7 +79,7 @@ export function CompareCommunity({
|
||||
if (pupils != null && capacity != null && capacity > 0) {
|
||||
capNote =
|
||||
pupils >= capacity
|
||||
? `${capacity.toLocaleString('en-GB')} places — at or above capacity`
|
||||
? `${capacity.toLocaleString('en-GB')} places (at or above capacity)`
|
||||
: `of ${capacity.toLocaleString('en-GB')} places (${Math.round((pupils / capacity) * 100)}% full)`;
|
||||
}
|
||||
return (
|
||||
@@ -111,7 +111,7 @@ export function CompareCommunity({
|
||||
</Measure>
|
||||
|
||||
<Measure
|
||||
tip="% of pupils eligible for free school meals — a common measure of how many pupils come from lower-income families. Benchmark computed across state schools in our dataset."
|
||||
tip="% of pupils eligible for free school meals, a common measure of how many pupils come from lower-income families. Benchmark computed across state schools in our dataset."
|
||||
label="Free school meals"
|
||||
>
|
||||
{schools.map((school, i) => {
|
||||
@@ -145,7 +145,7 @@ export function CompareCommunity({
|
||||
</Measure>
|
||||
|
||||
<Measure
|
||||
tip="% of pupils receiving SEN support (not including EHC plans). A high figure can mean the school hosts specialist provision — often a strength, not a warning sign. State-school average computed from our dataset."
|
||||
tip="% of pupils receiving SEN support (not including EHC plans). A high figure can mean the school hosts specialist provision, which is often a strength rather than a warning sign. State-school average computed from our dataset."
|
||||
label="Extra learning support (SEN)"
|
||||
>
|
||||
{schools.map((school, i) => {
|
||||
|
||||
@@ -47,7 +47,7 @@ function ResultCell({ display }: { display: OfstedDisplay }) {
|
||||
return (
|
||||
<>
|
||||
<strong style={{ fontSize: '0.9rem' }}>Report card</strong>
|
||||
<span className={s.small}>New-style inspection — no overall grade is given</span>
|
||||
<span className={s.small}>New-style inspection: no overall grade is given</span>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -127,7 +127,7 @@ function JudgementDetailCell({
|
||||
if (published.length === 0) {
|
||||
return (
|
||||
<span className={s.small}>
|
||||
We don't hold area-by-area detail for this inspection — see {schoolName}'s
|
||||
We don't hold area-by-area detail for this inspection. See {schoolName}'s
|
||||
Ofsted page for the full report.
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -28,6 +28,9 @@ export function AddToCompareButton({ school }: { school: NearbySchool }) {
|
||||
school_name: school.school_name,
|
||||
school_type: school.school_type,
|
||||
age_range: school.age_range,
|
||||
// The basket limits each phase separately. Missing (an older API)
|
||||
// counts against both groups, which is safe, just stricter.
|
||||
phase: school.phase ?? null,
|
||||
} as School);
|
||||
};
|
||||
|
||||
@@ -39,7 +42,7 @@ export function AddToCompareButton({ school }: { school: NearbySchool }) {
|
||||
aria-pressed={selected}
|
||||
>
|
||||
{selected ? '✓ Added to compare' : '+ Add to compare'}
|
||||
<span className={styles.srOnly}> — {school.school_name}</span>
|
||||
<span className={styles.srOnly}>: {school.school_name}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ export function AdmissionsSection({
|
||||
<><strong>{admissions.first_preference_applications}</strong> families put it first for </>
|
||||
)}
|
||||
{admissions.places_offered != null && <><strong>{admissions.places_offered}</strong> places</>}
|
||||
{admissions.total_applications != null && ` — ${admissions.total_applications.toLocaleString()} applications in total`}.
|
||||
{admissions.total_applications != null && ` (${admissions.total_applications.toLocaleString()} applications in total)`}.
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -189,7 +189,7 @@ export function DestinationsView({
|
||||
data-group={card ?? 'none'}
|
||||
className={`${styles.segment} ${styles[seg.category]} ${dimmed(card) ? styles.dim : ''}`}
|
||||
style={{ width: `${seg.widthPct}%` }}
|
||||
title={`${CATEGORY_LABELS[seg.category]} — ${seg.labelPct}% (${seg.pupils} pupils)`}
|
||||
title={`${CATEGORY_LABELS[seg.category]}: ${seg.labelPct}% (${seg.pupils} pupils)`}
|
||||
>
|
||||
{seg.widthPct >= 9 ? `${seg.labelPct}%` : ''}
|
||||
</div>
|
||||
@@ -254,7 +254,7 @@ export function DestinationsView({
|
||||
<p className={styles.footnote}>
|
||||
Shares are rounded and may not add up to 100%. A pupil counted under a
|
||||
school sixth form may have moved to a different school's sixth
|
||||
form — the published data records the type of place, not which one.
|
||||
form. The published data records the type of place, not which one.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -129,7 +129,7 @@ export function GcseSection({
|
||||
that comparison isn't meaningful. */}
|
||||
{!suppressComparison && latestResults.attainment_8_score != null && (
|
||||
<div className={styles.att8Viz}>
|
||||
<div className={styles.att8VizLabel}>Attainment 8 — school vs national</div>
|
||||
<div className={styles.att8VizLabel}>Attainment 8: school vs national</div>
|
||||
<div className={styles.att8VizTrack}>
|
||||
<div
|
||||
className={styles.att8VizFill}
|
||||
@@ -155,7 +155,7 @@ export function GcseSection({
|
||||
{/* Progress 8 number line with CI */}
|
||||
{latestResults.progress_8_score != null && !p8Suspended && (
|
||||
<div className={styles.p8Viz}>
|
||||
<div className={styles.p8VizLabel}>Progress 8 — relative to national baseline (0)</div>
|
||||
<div className={styles.p8VizLabel}>Progress 8: relative to national baseline (0)</div>
|
||||
{(() => {
|
||||
const p8 = latestResults.progress_8_score!;
|
||||
const lo = latestResults.progress_8_lower_ci ?? p8;
|
||||
|
||||
@@ -37,7 +37,7 @@ export function HistorySection({
|
||||
<>
|
||||
{hasKS2Results && (
|
||||
<>
|
||||
<h3 className={styles.subSectionTitle}>Primary — KS2 SATs</h3>
|
||||
<h3 className={styles.subSectionTitle}>Primary: KS2 SATs</h3>
|
||||
<div className={styles.chartContainer}>
|
||||
<PerformanceChart
|
||||
data={yearlyData}
|
||||
@@ -51,7 +51,7 @@ export function HistorySection({
|
||||
)}
|
||||
{hasKS4Results && (
|
||||
<>
|
||||
<h3 className={styles.subSectionTitle} style={{ marginTop: '1.5rem' }}>Secondary — GCSEs</h3>
|
||||
<h3 className={styles.subSectionTitle} style={{ marginTop: '1.5rem' }}>Secondary: GCSEs</h3>
|
||||
<div className={styles.chartContainer}>
|
||||
<PerformanceChart
|
||||
data={yearlyData}
|
||||
|
||||
@@ -114,14 +114,14 @@ export function OfstedSection({
|
||||
</div>
|
||||
<p className={styles.ofstedDisclaimer}>
|
||||
{ofsted.grade_source === 'ungraded_carried_forward'
|
||||
? 'This overall grade is carried forward from an earlier inspection — Ofsted has since visited without issuing a new overall grade. From September 2024, Ofsted no longer makes an overall effectiveness judgement.'
|
||||
? 'This overall grade is carried forward from an earlier inspection. Ofsted has since visited without issuing a new overall grade. From September 2024, Ofsted no longer makes an overall effectiveness judgement.'
|
||||
: isSecondary
|
||||
? 'From September 2024, Ofsted no longer makes an overall effectiveness judgement in inspections.'
|
||||
: 'From September 2024, Ofsted no longer makes an overall effectiveness judgement in inspections of state-funded schools.'}
|
||||
</p>
|
||||
{oeifAllSameGrade ? (
|
||||
<p className={styles.ofstedAllSame}>
|
||||
Rated <strong>{OFSTED_LABELS[ofsted.overall_effectiveness!]}</strong> across all inspected areas — Quality of Teaching, Behaviour, Pupils' Development and Leadership.
|
||||
Rated <strong>{OFSTED_LABELS[ofsted.overall_effectiveness!]}</strong> across all inspected areas: Quality of Teaching, Behaviour, Pupils' Development and Leadership.
|
||||
</p>
|
||||
) : (
|
||||
<div className={`${styles.metricsGrid} ${styles.gradeGrid}`}>
|
||||
|
||||
@@ -41,7 +41,7 @@ export function ResultsSection({
|
||||
? 'GCSE results for Year 11 pupils.'
|
||||
: 'End-of-primary-school tests taken by Year 6 pupils.')
|
||||
: isAllThrough
|
||||
? 'KS2 SATs (end of Year 6) and GCSE results (Year 11) — this school covers both. England averages shown for comparison.'
|
||||
? 'This school covers both KS2 SATs (end of Year 6) and GCSE results (Year 11). England averages shown for comparison.'
|
||||
: isSecondary
|
||||
? 'GCSE results for Year 11 pupils. England averages shown for comparison.'
|
||||
: 'End-of-primary-school tests taken by Year 6 pupils. England averages shown for comparison.'}
|
||||
@@ -56,7 +56,7 @@ export function ResultsSection({
|
||||
{hasKS2Results && (
|
||||
<>
|
||||
{isAllThrough && (
|
||||
<h3 className={styles.subSectionTitle}>Primary — KS2 SATs (Year 6)</h3>
|
||||
<h3 className={styles.subSectionTitle}>Primary: KS2 SATs (Year 6)</h3>
|
||||
)}
|
||||
<div className={styles.heroStatGrid}>
|
||||
{latestResults.rwm_expected_pct !== null && (
|
||||
@@ -208,7 +208,7 @@ export function ResultsSection({
|
||||
{hasKS4Results && (
|
||||
<>
|
||||
{isAllThrough && (
|
||||
<h3 className={styles.subSectionTitle} style={{ marginTop: '1.5rem' }}>Secondary — GCSEs (Year 11)</h3>
|
||||
<h3 className={styles.subSectionTitle} style={{ marginTop: '1.5rem' }}>Secondary: GCSEs (Year 11)</h3>
|
||||
)}
|
||||
<div className={styles.metricsGrid}>
|
||||
{latestResults.attainment_8_score !== null && (
|
||||
|
||||
@@ -283,6 +283,21 @@
|
||||
}
|
||||
|
||||
|
||||
/* `position: sticky` with a z-index makes .sectionNav a stacking context, so
|
||||
the jump sheet's own z-index only orders it INSIDE that context. Against the
|
||||
fixed bottom tab bar (Navigation.module.css, z-index 1000) what counts is
|
||||
.sectionNav's 10 — which is why the sheet's last item was painted over, and
|
||||
untappable, once the list grew long enough to reach the bar.
|
||||
|
||||
Lifted only while the sheet is open, and only to 1100: above the bar, below
|
||||
the comparison toast (2000), the fullscreen map (5000) and the info popover
|
||||
(9999). This rule carries the z-index and nothing else; every other
|
||||
declaration belongs to .sectionNav in both states. */
|
||||
.sectionNavSheetOpen {
|
||||
z-index: 1100;
|
||||
}
|
||||
|
||||
|
||||
.sectionNavBack {
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
|
||||
@@ -229,8 +229,8 @@ export function SchoolDetailShell({
|
||||
</div>
|
||||
{isProposedToClose(schoolInfo) && (
|
||||
<div className={styles.closingStrip} role="note">
|
||||
<strong>⚠ Proposed to close</strong> — this school is proposed for closure,
|
||||
check with the local authority before applying.
|
||||
<strong>⚠ Proposed to close.</strong> Check with the local authority before
|
||||
applying.
|
||||
</div>
|
||||
)}
|
||||
{schoolInfo.address && (
|
||||
@@ -344,7 +344,10 @@ export function SchoolDetailShell({
|
||||
</header>
|
||||
|
||||
{/* Sticky Section Navigation — docks under the global header */}
|
||||
<nav className={styles.sectionNav} aria-label="Page sections">
|
||||
<nav
|
||||
className={`${styles.sectionNav}${sectionsOpen ? ` ${styles.sectionNavSheetOpen}` : ''}`}
|
||||
aria-label="Page sections"
|
||||
>
|
||||
<button onClick={scrollToTop} className={styles.sectionNavBack} aria-label="Back to top">
|
||||
<span aria-hidden="true">↑</span>
|
||||
<span className={styles.sectionNavBackLabel}>Top</span>
|
||||
|
||||
@@ -46,10 +46,10 @@ export function SecondaryAdmissionsSection({
|
||||
|
||||
{admissionsTag && (
|
||||
<div className={`${styles.admissionsTypeBadge} ${admissionsTag === 'Selective' ? styles.admissionsSelective : styles.admissionsFaith}`}>
|
||||
<strong>{admissionsTag}</strong>{' '}
|
||||
<strong>{admissionsTag}:</strong>{' '}
|
||||
{admissionsTag === 'Selective'
|
||||
? '— Entry to this school is by selective examination (e.g. 11+).'
|
||||
: `— This school has a faith-based admissions priority (${schoolInfo.religious_denomination}).`}
|
||||
? 'entry to this school is by selective examination (e.g. 11+).'
|
||||
: `this school has a faith-based admissions priority (${schoolInfo.religious_denomination}).`}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ export interface CutoffDisplay {
|
||||
/** What the cut-off measures, and what it does not. Identical on both templates. */
|
||||
export const CUTOFF_NOTE =
|
||||
'The furthest home offered a place, after higher priorities such as siblings, ' +
|
||||
'faith and EHCP were applied. It is not a fixed catchment — it moves every year ' +
|
||||
'faith and EHCP were applied. It is not a fixed catchment. It moves every year ' +
|
||||
'with the number of applications.';
|
||||
|
||||
/** Straight-line, because that is how councils measure it. */
|
||||
@@ -54,7 +54,7 @@ export function describeCutoff(
|
||||
entryYear: formatEntryYear(distance.year),
|
||||
routeNote:
|
||||
routes > 1
|
||||
? `Furthest of ${routes} admission routes at this school — the one that ` +
|
||||
? `Furthest of ${routes} admission routes at this school. The one that ` +
|
||||
'applies to your child may have had a shorter cut-off.'
|
||||
: null,
|
||||
};
|
||||
@@ -122,10 +122,10 @@ export function compareToCutoff(
|
||||
const cutoffPhrase = `the September ${year} cut-off of ${cutoffLabel}`;
|
||||
const headline =
|
||||
verdict === 'inside'
|
||||
? `${label} away — inside ${cutoffPhrase}.`
|
||||
? `${label} away, inside ${cutoffPhrase}.`
|
||||
: verdict === 'outside'
|
||||
? `${label} away — beyond ${cutoffPhrase}.`
|
||||
: `${label} away — too close to ${cutoffPhrase} to call.`;
|
||||
? `${label} away, beyond ${cutoffPhrase}.`
|
||||
: `${label} away, too close to ${cutoffPhrase} to call.`;
|
||||
|
||||
const detail =
|
||||
verdict === 'too-close'
|
||||
@@ -156,11 +156,11 @@ export function compareToCutoff(
|
||||
*/
|
||||
export const CUTOFF_CHECK_CAVEAT =
|
||||
'Distance is the last criterion applied. Places go first to children in care, '
|
||||
+ 'EHCP places, siblings and — at faith schools — on faith criteria, so a home '
|
||||
+ 'EHCP places and siblings, and at faith schools by faith criteria, so a home '
|
||||
+ 'inside the distance can still miss out. Figures are straight-line distances '
|
||||
+ 'and not a catchment boundary; some authorities measure a walking route '
|
||||
+ "instead, which is always longer for the same home. Next year's cut-off "
|
||||
+ "depends on next year's applicants — always check the school's own "
|
||||
+ "depends on next year's applicants, so always check the school's own "
|
||||
+ 'admissions policy.';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
'use client';
|
||||
|
||||
import { createContext, useContext } from 'react';
|
||||
import type { CompareGroup } from '@/lib/compareLogic';
|
||||
import type { School } from '@/lib/types';
|
||||
|
||||
interface ComparisonContextType {
|
||||
@@ -16,9 +17,12 @@ interface ComparisonContextType {
|
||||
addSchool: (school: School) => void;
|
||||
removeSchool: (urn: number) => void;
|
||||
replaceSchools: (schools: School[]) => void;
|
||||
/** Fill in phases missing from stored entries; never overwrites one. */
|
||||
backfillPhases: (phases: Record<number, string | null | undefined>) => void;
|
||||
clearAll: () => void;
|
||||
isSelected: (urn: number) => boolean;
|
||||
canAddMore: boolean;
|
||||
/** The comparison group with no room for this school, or null. */
|
||||
fullGroupFor: (school: Pick<School, 'phase'>) => CompareGroup | null;
|
||||
isInitialized: boolean;
|
||||
mutate: () => void;
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { getFromLocalStorage, setToLocalStorage } from '@/lib/utils';
|
||||
import { MAX_PER_GROUP, fitToGroupLimits, fullGroupFor } from '@/lib/compareLogic';
|
||||
import type { School } from '@/lib/types';
|
||||
import { ComparisonContext } from './ComparisonContext';
|
||||
|
||||
const STORAGE_KEY = 'selectedSchools';
|
||||
const MAX_SCHOOLS = 5;
|
||||
|
||||
export function ComparisonProvider({ children }: { children: React.ReactNode }) {
|
||||
const [selectedSchools, setSelectedSchools] = useState<School[]>([]);
|
||||
@@ -53,8 +53,9 @@ export function ComparisonProvider({ children }: { children: React.ReactNode })
|
||||
if (prev.some((s) => s.urn === school.urn)) {
|
||||
return prev;
|
||||
}
|
||||
if (prev.length >= MAX_SCHOOLS) {
|
||||
alert(`Maximum ${MAX_SCHOOLS} schools can be compared`);
|
||||
const fullGroup = fullGroupFor(prev, school);
|
||||
if (fullGroup) {
|
||||
alert(`You can compare up to ${MAX_PER_GROUP} ${fullGroup} schools at once. Remove one to add another.`);
|
||||
return prev;
|
||||
}
|
||||
return [...prev, school];
|
||||
@@ -68,7 +69,23 @@ export function ComparisonProvider({ children }: { children: React.ReactNode })
|
||||
// Replace the whole selection — used when a shared /compare?urns=… link
|
||||
// must take precedence over whatever this visitor had stored.
|
||||
const replaceSchools = useCallback((schools: School[]) => {
|
||||
setSelectedSchools(schools.slice(0, MAX_SCHOOLS));
|
||||
setSelectedSchools(fitToGroupLimits(schools));
|
||||
}, []);
|
||||
|
||||
// Baskets saved before phases were recorded (or added from a path that
|
||||
// lacked one) count against both groups. Fill the gaps once the compare
|
||||
// page has fetched each school, so they stop holding a slot they don't need.
|
||||
const backfillPhases = useCallback((phases: Record<number, string | null | undefined>) => {
|
||||
setSelectedSchools((prev) => {
|
||||
let changed = false;
|
||||
const next = prev.map((s) => {
|
||||
const phase = phases[s.urn];
|
||||
if (s.phase || !phase) return s;
|
||||
changed = true;
|
||||
return { ...s, phase };
|
||||
});
|
||||
return changed ? next : prev;
|
||||
});
|
||||
}, []);
|
||||
|
||||
const clearAll = useCallback(() => {
|
||||
@@ -80,6 +97,11 @@ export function ComparisonProvider({ children }: { children: React.ReactNode })
|
||||
[selectedSchools]
|
||||
);
|
||||
|
||||
const fullGroupForSchool = useCallback(
|
||||
(school: Pick<School, 'phase'>) => fullGroupFor(selectedSchools, school),
|
||||
[selectedSchools]
|
||||
);
|
||||
|
||||
// Placeholder mutate - actual SWR mutate is in useComparison hook
|
||||
const mutate = useCallback(() => {}, []);
|
||||
|
||||
@@ -93,9 +115,10 @@ export function ComparisonProvider({ children }: { children: React.ReactNode })
|
||||
addSchool,
|
||||
removeSchool,
|
||||
replaceSchools,
|
||||
backfillPhases,
|
||||
clearAll,
|
||||
isSelected,
|
||||
canAddMore: selectedSchools.length < MAX_SCHOOLS,
|
||||
fullGroupFor: fullGroupForSchool,
|
||||
isInitialized,
|
||||
mutate,
|
||||
}}
|
||||
|
||||
@@ -289,3 +289,48 @@ export function latestValues(
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Basket limits — five per comparison group, not five overall
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type CompareGroup = 'primary' | 'secondary';
|
||||
|
||||
export const MAX_PER_GROUP = 5;
|
||||
|
||||
/**
|
||||
* Which phase tab(s) of the compare page a school can land in. The page
|
||||
* sorts by the data a school actually has, which isn't known when it's added,
|
||||
* so anything that isn't plainly one phase (all-through, special schools
|
||||
* with phase "Not applicable", unknown) counts against BOTH groups. That
|
||||
* keeps every tab at MAX_PER_GROUP or fewer, which the five-slot chart
|
||||
* palette and point styles rely on.
|
||||
*/
|
||||
export function compareGroups(phase?: string | null): CompareGroup[] {
|
||||
const p = (phase ?? '').toLowerCase();
|
||||
// "Middle deemed secondary" / "Middle deemed primary" match here too.
|
||||
// "16 plus" is secondary, as the API's PHASE_GROUPS files it.
|
||||
if (p.includes('secondary') || p === '16 plus') return ['secondary'];
|
||||
if (p.includes('primary')) return ['primary'];
|
||||
return ['primary', 'secondary'];
|
||||
}
|
||||
|
||||
/** The group that has no room for `school`, or null if it can be added. */
|
||||
export function fullGroupFor(
|
||||
basket: ReadonlyArray<{ phase?: string | null }>,
|
||||
school: { phase?: string | null },
|
||||
): CompareGroup | null {
|
||||
for (const group of compareGroups(school.phase)) {
|
||||
const used = basket.filter((s) => compareGroups(s.phase).includes(group)).length;
|
||||
if (used >= MAX_PER_GROUP) return group;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Keep schools in order, dropping any that would overflow a group. */
|
||||
export function fitToGroupLimits<T extends { phase?: string | null }>(schools: T[]): T[] {
|
||||
return schools.reduce<T[]>(
|
||||
(kept, school) => (fullGroupFor(kept, school) ? kept : [...kept, school]),
|
||||
[],
|
||||
);
|
||||
}
|
||||
+14
-14
@@ -16,32 +16,32 @@ export const METRIC_EXPLANATIONS: Record<string, MetricExplanation> = {
|
||||
detail: 'The national average is around 60%. Higher means more pupils reached the expected level.',
|
||||
},
|
||||
rwm_high_pct: {
|
||||
label: 'Higher Standard — Reading, Writing & Maths',
|
||||
label: 'Higher Standard: Reading, Writing & Maths',
|
||||
plain: '% of pupils exceeding the expected level in all three subjects',
|
||||
detail: 'A more demanding threshold. The national average is around 8%.',
|
||||
},
|
||||
reading_expected_pct: {
|
||||
label: 'Reading — Expected Standard',
|
||||
label: 'Reading: Expected Standard',
|
||||
plain: '% of pupils achieving the expected standard in reading at age 11',
|
||||
},
|
||||
writing_expected_pct: {
|
||||
label: 'Writing — Expected Standard',
|
||||
label: 'Writing: Expected Standard',
|
||||
plain: '% of pupils achieving the expected standard in writing at age 11',
|
||||
},
|
||||
maths_expected_pct: {
|
||||
label: 'Maths — Expected Standard',
|
||||
label: 'Maths: Expected Standard',
|
||||
plain: '% of pupils achieving the expected standard in maths at age 11',
|
||||
},
|
||||
reading_high_pct: {
|
||||
label: 'Reading — Higher Standard',
|
||||
label: 'Reading: Higher Standard',
|
||||
plain: '% of pupils exceeding the expected level in reading',
|
||||
},
|
||||
writing_high_pct: {
|
||||
label: 'Writing — Higher Standard',
|
||||
label: 'Writing: Higher Standard',
|
||||
plain: '% of pupils exceeding the expected level in writing',
|
||||
},
|
||||
maths_high_pct: {
|
||||
label: 'Maths — Higher Standard',
|
||||
label: 'Maths: Higher Standard',
|
||||
plain: '% of pupils exceeding the expected level in maths',
|
||||
},
|
||||
gps_expected_pct: {
|
||||
@@ -90,7 +90,7 @@ export const METRIC_EXPLANATIONS: Record<string, MetricExplanation> = {
|
||||
detail: 'Lower is better. Persistent absence can significantly affect attainment.',
|
||||
},
|
||||
rwm_expected_disadvantaged_pct: {
|
||||
label: 'Disadvantaged Pupils — Reading, Writing & Maths',
|
||||
label: 'Disadvantaged Pupils: Reading, Writing & Maths',
|
||||
plain: '% of disadvantaged pupils achieving the expected standard in all three subjects',
|
||||
},
|
||||
disadvantaged_gap: {
|
||||
@@ -105,7 +105,7 @@ export const METRIC_EXPLANATIONS: Record<string, MetricExplanation> = {
|
||||
},
|
||||
sen_ehcp_pct: {
|
||||
label: 'Education, Health and Care Plan (EHCP)',
|
||||
plain: '% of pupils with a formal EHCP — a legal plan for pupils with significant additional needs',
|
||||
plain: '% of pupils with a formal EHCP (a legal plan for pupils with significant additional needs)',
|
||||
},
|
||||
eal_pct: {
|
||||
label: 'English as an Additional Language',
|
||||
@@ -128,26 +128,26 @@ export const METRIC_EXPLANATIONS: Record<string, MetricExplanation> = {
|
||||
detail: '0 = national average. Positive means better-than-expected progress; negative means lower-than-expected. A score above +0.5 is considered well above average.',
|
||||
},
|
||||
english_maths_standard_pass_pct: {
|
||||
label: 'English & Maths — Grade 4+ (Standard Pass)',
|
||||
label: 'English & Maths: Grade 4+ (Standard Pass)',
|
||||
plain: '% of pupils achieving at least a grade 4 in both English and Maths',
|
||||
detail: 'Grade 4 is the minimum "standard pass". Employers and colleges often require grade 4 in English and Maths.',
|
||||
},
|
||||
english_maths_strong_pass_pct: {
|
||||
label: 'English & Maths — Grade 5+ (Strong Pass)',
|
||||
label: 'English & Maths: Grade 5+ (Strong Pass)',
|
||||
plain: '% of pupils achieving at least a grade 5 in both English and Maths',
|
||||
detail: 'Grade 5 is a "strong pass". Many sixth forms and universities expect grade 5 in English and Maths.',
|
||||
},
|
||||
ebacc_entry_pct: {
|
||||
label: 'EBacc Entry',
|
||||
plain: '% of pupils who entered the English Baccalaureate — a set of GCSE subjects covering English, Maths, Sciences, a Language, and Humanities',
|
||||
plain: '% of pupils who entered the English Baccalaureate (a set of GCSE subjects covering English, Maths, Sciences, a Language and Humanities)',
|
||||
detail: 'EBacc entry keeps academic options open post-16. It is not a separate qualification.',
|
||||
},
|
||||
ebacc_standard_pass_pct: {
|
||||
label: 'EBacc — Grade 4+ (Standard Pass)',
|
||||
label: 'EBacc: Grade 4+ (Standard Pass)',
|
||||
plain: '% of pupils achieving grade 4 or above across all EBacc subjects',
|
||||
},
|
||||
ebacc_strong_pass_pct: {
|
||||
label: 'EBacc — Grade 5+ (Strong Pass)',
|
||||
label: 'EBacc: Grade 5+ (Strong Pass)',
|
||||
plain: '% of pupils achieving grade 5 or above across all EBacc subjects',
|
||||
},
|
||||
ebacc_avg_score: {
|
||||
|
||||
@@ -360,6 +360,8 @@ export interface NearbySchool {
|
||||
distance_miles: number;
|
||||
school_type: string | null;
|
||||
age_range: string | null;
|
||||
/** Optional: a frontend can ship ahead of the API that serves it. */
|
||||
phase?: string | null;
|
||||
shared: string[];
|
||||
metric_value: number | null;
|
||||
metric_key: string;
|
||||
|
||||
@@ -116,7 +116,7 @@ export function formatWithSuppression(value: number | null | undefined): { displ
|
||||
return { display: formatPercentage(value), suppressed: false };
|
||||
}
|
||||
|
||||
export const SUPPRESSED_TOOLTIP = 'Data not available — may be suppressed to protect small cohorts.';
|
||||
export const SUPPRESSED_TOOLTIP = 'Data not available. It may be suppressed to protect small cohorts.';
|
||||
|
||||
/**
|
||||
* Format a progress score (can be negative)
|
||||
@@ -750,7 +750,7 @@ export function buildSchoolSummary(
|
||||
if (admissions.first_preference_offer_pct != null) {
|
||||
const pct = Math.round(admissions.first_preference_offer_pct);
|
||||
parts.push(
|
||||
`oversubscribed — ${pct}% of first-choice applicants are offered a place`,
|
||||
`oversubscribed (${pct}% of first-choice applicants are offered a place)`,
|
||||
);
|
||||
} else {
|
||||
parts.push('oversubscribed');
|
||||
|
||||
Reference in new issue
Block a user