/* Maths chapters 17–25 */
(() => {
const { mc, inp, ord, DONE } = window.QH;
BOOK.push(
{ id: 'm17', subj: 'maths', n: 17, title: 'Presenting and interpreting data 2', strand: 'Statistics', codes: ['8Ss.03', '8Ss.05'],
  secs: [
    { n: '17.1', t: 'Pie charts', w: 'pie',
      intro: 'Change the frequencies and watch each sector angle update. The angles always add to 360°.',
      tasks: [['Make the total 60 people', s => s.tot === 60], ['Make one category exactly 90°', s => s.v.some(x => Math.abs(x / s.tot * 360 - 90) < 0.01)]],
      notice: [<>Angle for one item = <b>360° ÷ total</b>.</>, <>Sector angle = <b>frequency × (360 ÷ total)</b>.</>, <>Pie charts show <b>proportions</b> of a whole, not exact amounts.</>],
      check: [inp('40 people in a survey; 10 chose tea. Sector angle?', '90', '10/40 × 360 = 90°.', '°'), inp('A sector is 72° of a pie chart showing 50 people. How many people?', '10', '72/360 × 50 = 10.')] },
    { n: '17.2', t: 'Infographics', w: 'infographic',
      intro: 'Change the key of the pictogram. Which key makes the infographic clearest?',
      tasks: [['Try every key', (s, H) => [50, 100, 200, 500].every(k => H('key', k))]],
      notice: [<>An <b>infographic</b> combines pictures, charts and short text to tell a story with data.</>, <>It needs a clear <b>key</b>, a <b>title</b> and an honest scale.</>, <>Be a critical reader: check the source, the scale and what is left out.</>],
      check: [mc('Each icon = 200 bottles. 3½ icons means…', ['3.5 bottles', '600 bottles', '700 bottles', '350 bottles'], 2, '3.5 × 200 = 700.'), mc('Which makes an infographic misleading?', ['A clear key', 'A source', 'Icons of different sizes for equal amounts', 'A title'], 2, 'Unequal icons distort the comparison.')] },
    { n: '17.3', t: 'Trends and relationships', w: 'scatter',
      intro: 'Change the strength and direction of the relationship. Add a line of best fit.',
      tasks: [['Show strong positive correlation', s => s.r >= 0.8], ['Show negative correlation', s => s.r <= -0.3], ['Show no correlation', s => Math.abs(s.r) < 0.2]],
      notice: [<><b>Positive correlation</b>: as one variable increases, so does the other.</>, <><b>Negative correlation</b>: as one increases, the other decreases.</>, <>A <b>line of best fit</b> can estimate values. <b>Correlation does not prove causation.</b></>],
      check: [mc('Temperature vs ice-cream sales likely shows…', ['Positive correlation', 'Negative correlation', 'No correlation', 'Causation only'], 0, 'Hotter days usually mean more sales.'), mc('Age of a car vs its value…', ['Positive', 'Negative', 'None', 'Perfect'], 1, 'Older cars are usually worth less.')] },
  ],
  practice: [inp('Pie chart, total 90. Frequency 15. Angle?', '60', '15 × 4 = 60.', '°'), mc('Shoe size vs maths score likely shows…', ['Positive correlation', 'Negative correlation', 'No correlation', 'Strong positive correlation'], 2, 'There is no link.'), mc('A time series graph is used to show…', ['Proportions', 'Change over time', 'Two variables\' correlation', 'Categories'], 1, 'Values over time.')],
  challenge: [mc('Two pie charts show that 25% of Class A and 25% of Class B walk to school. Can you say the same number walk?', ['Yes', 'No: the class sizes may be different', 'Only if the angles match', 'Yes, pie charts show counts'], 1, 'Pie charts show proportions, not totals.'), mc('Hours of TV and test scores show negative correlation. Which conclusion is valid?', ['TV causes low scores', 'Students who watch more TV tend to score lower', 'TV has no effect', 'Scores cause TV watching'], 1, 'Correlation shows a tendency, not a cause.')],
  recap: { points: ['Pie chart angle = frequency × 360/total.', 'Infographics need a key, a source and an honest scale.', 'Scatter graphs show correlation; lines of best fit estimate values.'], terms: [['Correlation', 'A relationship between two variables.'], ['Line of best fit', 'A straight line through the middle of the points.'], ['Sector', 'A slice of a pie chart.']] } },

{ id: 'm18', subj: 'maths', n: 18, title: 'Transformations', strand: 'Geometry', codes: ['8Gp.03', '8Gp.04', '8Gp.05', '8Gp.06'],
  secs: [
    { n: '18.1', t: 'Translations', w: 'transform', cfg: { kind: 'translate' },
      intro: 'Change the column vector and watch the image slide. Does its shape or size change?',
      tasks: [['Translate left and down', s => s.vx < 0 && s.vy < 0], ['Use vector (5, 2)', s => s.vx === 5 && s.vy === 2]],
      notice: [<>A <b>column vector</b> gives the move: top = right (+) or left (−); bottom = up (+) or down (−).</>, <>Every point moves the <b>same</b> distance in the same direction.</>, <>The image is <b>congruent</b> to the object.</>],
      check: [mc('Which vector moves 3 left and 4 up?', ['(3, 4)', '(−3, 4)', '(4, −3)', '(3, −4)'], 1, 'Left is negative x.'), mc('After a translation the image is…', ['enlarged', 'congruent', 'reflected', 'similar but smaller'], 1, 'Same shape and size.')] },
    { n: '18.2', t: 'Reflections', w: 'transform', cfg: { kind: 'reflect' },
      intro: 'Choose a mirror line. Check that each image point is the same distance from the line as its object point.',
      tasks: [['Reflect in y = x', s => s.mirror === 'y=x'], ['Reflect in y = −x', s => s.mirror === 'y=-x'], ['Reflect in a line parallel to an axis', s => s.mirror === 'x=4' || s.mirror === 'y=-1']],
      notice: [<>Each point moves <b>perpendicular</b> to the mirror line, the same distance on the other side.</>, <>In <b>y = x</b>, (a, b) becomes (b, a). In <b>y = −x</b>, (a, b) becomes (−b, −a).</>, <>The image is congruent but <b>reversed</b>.</>],
      check: [mc('(3, 1) reflected in the y-axis?', ['(−3, 1)', '(3, −1)', '(1, 3)', '(−1, −3)'], 0, 'x changes sign.'), mc('(2, 5) reflected in y = x?', ['(−2, 5)', '(5, 2)', '(−5, −2)', '(2, −5)'], 1, 'Swap the coordinates.')] },
    { n: '18.3', t: 'Rotations', w: 'transform', cfg: { kind: 'rotate' },
      intro: 'Choose an angle, a direction and a centre. Watch the shape turn.',
      tasks: [['Rotate 180°', s => s.ang === 180], ['Use a centre that isn\'t the origin', s => s.cx !== 0 || s.cy !== 0], ['Rotate 90° anticlockwise', s => s.ang === 90 && s.dirn === 'acw']],
      notice: [<>To describe a rotation you need <b>three things</b>: centre, angle and direction.</>, <>90° clockwise is the same as 270° anticlockwise.</>, <>180° needs no direction. The image is congruent.</>],
      check: [mc('Which is NOT needed to describe a rotation?', ['Centre', 'Angle', 'Direction', 'Scale factor'], 3, 'A scale factor belongs to enlargements.'), mc('(2, 0) rotated 90° anticlockwise about (0, 0)?', ['(0, 2)', '(0, −2)', '(−2, 0)', '(2, 2)'], 0, 'It moves onto the positive y-axis.')] },
    { n: '18.4', t: 'Enlargements', w: 'transform', cfg: { kind: 'enlarge' },
      intro: 'Choose a scale factor and a centre. Follow the rays from the centre through each vertex.',
      tasks: [['Enlarge with scale factor 3', s => s.k === 3], ['Move the centre away from the origin', s => s.ex !== 0 || s.ey !== 0]],
      notice: [<>Each image point is <b>k times as far</b> from the centre as the object point.</>, <>All lengths are multiplied by the <b>scale factor</b>.</>, <>The image is <b>similar</b> (same shape), not congruent.</>],
      check: [inp('A side of 4 cm is enlarged by scale factor 3. New length?', '12', '4 × 3.', 'cm'), mc('After an enlargement, the angles…', ['double', 'stay the same', 'change by the scale factor', 'become 90°'], 1, 'The shape is similar, so the angles are unchanged.')] },
  ],
  practice: [mc('(1, 2) translated by (4, −3)?', ['(5, −1)', '(−3, 5)', '(4, −6)', '(5, 5)'], 0, '1 + 4, 2 − 3.'), mc('(4, 3) reflected in the x-axis?', ['(−4, 3)', '(4, −3)', '(3, 4)', '(−4, −3)'], 1, 'y changes sign.'), mc('Rotation 180° about (0, 0) of (3, −2)?', ['(−3, 2)', '(3, 2)', '(2, −3)', '(−2, 3)'], 0, 'Both coordinates change sign.')],
  challenge: [mc('Which transformations always give a congruent image?', ['Translation, reflection, rotation', 'Enlargement only', 'All four', 'Reflection only'], 0, 'Enlargement changes the size.'), inp('A triangle with perimeter 15 cm is enlarged by scale factor 2.5. New perimeter?', '37.5', 'Lengths × 2.5.', 'cm')],
  recap: { points: ['Translation: column vector. Reflection: mirror line. Rotation: centre, angle, direction. Enlargement: centre, scale factor.', 'Translations, reflections and rotations give congruent images.', 'Enlargements give similar images.'], terms: [['Congruent', 'The same shape and size.'], ['Similar', 'The same shape, different size.'], ['Column vector', 'A vector written with the x change on top and the y change below.']] } },

{ id: 'm19', subj: 'maths', n: 19, title: 'Percentages', strand: 'Number', codes: ['8Nf.05'],
  secs: [
    { n: '19.1', t: 'Percentage increase and decrease', w: 'pctchange',
      intro: 'Choose an amount and a percentage change. Watch the multiplier and the absolute change.',
      tasks: [['Increase 80 by 25%', s => s.o === 80 && s.p === 25 && s.dir === 'inc'], ['Find a multiplier of 0.85', s => s.m === 0.85], ['Make a decrease with an absolute change of −30', s => s.ch === -30]],
      notice: [<>Increase by p%: <b>× (1 + p/100)</b>. Decrease by p%: <b>× (1 − p/100)</b>.</>, <>The <b>absolute change</b> is the actual amount added or removed.</>, <>One multiplication gives the new amount in a single step.</>],
      check: [inp('Increase $60 by 15%.', '69', '60 × 1.15.', '$'), inp('Decrease 250 by 12%.', '220', '250 × 0.88.')] },
  ],
  practice: [inp('Multiplier for a 7% increase?', '1.07', '1 + 0.07.'), inp('Decrease 80 kg by 35%.', '52', '80 × 0.65.', 'kg'), inp('A price rises from $40 to $46. Percentage increase?', '15', '6/40 = 0.15.', '%')],
  challenge: [mc('A price rises by 10% then falls by 10%. Compared with the start it is…', ['the same', '1% lower', '1% higher', '20% lower'], 1, '1.1 × 0.9 = 0.99.'), inp('A town\'s population of 8000 increases by 5% each year for 2 years. New population?', '8820', '8000 × 1.05 × 1.05.')],
  recap: { points: ['Multiplier = 1 ± p/100.', 'New amount = original × multiplier.', 'Absolute change = new − original.'], terms: [['Multiplier', 'The number you multiply by to apply a percentage change.'], ['Absolute change', 'The actual size of the change.'], ['Percentage change', 'Change ÷ original × 100.']] } },

{ id: 'm20', subj: 'maths', n: 20, title: 'Sequences', strand: 'Algebra', codes: ['8As.01', '8As.02'],
  secs: [
    { n: '20.1', t: 'Generating sequences', w: 'seqgen',
      intro: 'Set a first term and a term-to-term rule. Try adding fractions and multiplying.',
      tasks: [['Make a decreasing linear sequence', s => s.kind === '+' && s.step < 0], ['Use a fractional step', s => s.kind === 'f' && s.step % 2 !== 0], ['Make a non-linear sequence', s => s.kind === '×']],
      notice: [<>A <b>term-to-term rule</b> tells you how to get from one term to the next.</>, <>A constant difference makes a <b>linear</b> sequence; the difference can be a fraction or negative.</>, <>Multiplying gives a <b>non-linear</b> sequence with growing gaps.</>],
      check: [inp('First term 5, rule "subtract 3". 4th term?', '-4', '5, 2, −1, −4.'), mc('Rule for ½, 1¼, 2, 2¾, …', ['add ½', 'add ¾', 'multiply by 2', 'add 1'], 1, 'Each step is +¾.')] },
    { n: '20.2', t: 'nth term rules', w: 'nthterm',
      intro: 'Change a and b in the nth term an + b. See the table, the graph and any term you choose.',
      tasks: [['Make the sequence 5, 8, 11, 14…', s => s.a === 3 && s.b === 2], ['Make a decreasing sequence', s => s.a < 0], ['Find the 100th term of any sequence', s => s.n === 100]],
      notice: [<>The <b>difference</b> between terms is the coefficient of n.</>, <>Then adjust: <b>nth term = (difference)n + (term 1 − difference)</b>.</>, <>The nth term finds <b>any term directly</b>, e.g. the 100th.</>],
      check: [mc('nth term of 7, 11, 15, 19…?', ['4n + 3', '4n + 7', '3n + 4', 'n + 4'], 0, 'The difference is 4; 7 − 4 = 3.'), inp('nth term 5n − 2. 20th term?', '98', '100 − 2.')] },
  ],
  practice: [mc('nth term of 2, 5, 8, 11?', ['3n − 1', '3n + 2', '2n + 3', 'n + 3'], 0, 'Difference 3; 2 − 3 = −1.'), mc('nth term of 20, 17, 14…?', ['−3n + 23', '3n + 17', '20 − n', '−3n + 20'], 0, 'Difference −3; 20 + 3 = 23.'), inp('Is 50 in the sequence 4n + 2? Type the term number, or 0 if not.', '12', '4n + 2 = 50 → n = 12.')],
  challenge: [mc('Is 100 a term of 3n + 2?', ['Yes, n = 32', 'No: (100 − 2)/3 = 32.67 is not a whole number', 'Yes, n = 34', 'Cannot tell'], 1, 'n must be a positive integer.'), mc('nth term of ½, 1, 1½, 2…?', ['½n', 'n + ½', '2n', 'n/4'], 0, 'Difference ½; ½ − ½ = 0.')],
  recap: { points: ['Term-to-term rules generate sequences.', 'Linear: constant difference → nth term an + b.', 'Use the nth term to find any term or test whether a number is in the sequence.'], terms: [['nth term', 'A formula for any term using its position n.'], ['Linear sequence', 'One with a constant difference.'], ['Term', 'A value in a sequence.']] } },

{ id: 'm21', subj: 'maths', n: 21, title: 'Probability 2', strand: 'Probability', codes: ['8Sp.02', '8Sp.03'],
  secs: [
    { n: '21.1', t: 'Lists and tree diagrams for combined events', w: 'tree',
      intro: 'Change the probabilities on the branches. Tap an outcome to multiply along its path.',
      tasks: [['Tap an outcome', s => s.hl != null], ['Make P(Rain and Late) = 0.42', s => Math.abs(s.p * s.q - 0.42) < 0.001]],
      notice: [<>Each set of branches from a point adds to <b>1</b>.</>, <>For combined independent events, <b>multiply along the branches</b>.</>, <>All the final outcomes add up to <b>1</b>.</>],
      check: [inp('P(A) = 0.5, P(B) = 0.4, independent. P(A and B)?', ['0.2', '.2'], '0.5 × 0.4.'), mc('How many outcomes when two coins are flipped?', ['2', '3', '4', '6'], 2, 'HH, HT, TH, TT.')] },
    { n: '21.2', t: 'Sample space diagrams and Venn diagrams', w: 'samplespace',
      intro: 'Use the sample space grid for two dice, then a Venn diagram for the numbers 1–20.',
      tasks: [['Find P(sum = 7)', s => s.mode === 'grid' && s.ev === 'sum = 7'], ['Shade A∩B in the Venn diagram', s => s.mode === 'venn' && s.reg === 'A∩B'], ['Shade A∪B', s => s.mode === 'venn' && s.reg === 'A∪B']],
      notice: [<>A <b>sample space diagram</b> lists every equally likely outcome. Two dice give 36.</>, <>P(event) = <b>favourable ÷ total</b>.</>, <>In a Venn diagram, <b>A∩B</b> is "both" and <b>A∪B</b> is "either or both".</>],
      check: [inp('Two dice: P(double)? Simplest form.', '1/6', '6/36.'), mc('Numbers 1–10. A = even, B = multiples of 3. A∩B?', ['{6}', '{3, 6, 9}', '{2, 4, 6, 8, 10}', '{2, 3, 4, 6, 8, 9, 10}'], 0, 'Only 6 is in both.')] },
  ],
  practice: [inp('Two dice: P(sum = 12)? (fraction)', '1/36', 'Only 6 + 6.'), mc('Spinner A: P(red) = ⅓, Spinner B: P(red) = ½. P(both red)?', ['⅚', '⅙', '½', '⅓'], 1, '⅓ × ½.'), inp('Coin and dice: how many outcomes?', '12', '2 × 6.')],
  challenge: [inp('P(late) = 0.2 each day, independently. P(on time on both Monday and Tuesday)?', ['0.64', '.64'], '0.8 × 0.8.'), mc('Two dice: P(sum ≥ 10)?', ['1/6', '1/12', '1/4', '5/36'], 0, '6 outcomes: 4+6, 5+5, 5+6, 6+4, 6+5, 6+6.')],
  recap: { points: ['Tree diagrams: multiply along branches for "and".', 'Sample space diagrams list all equally likely outcomes.', 'Venn: ∩ = both, ∪ = either or both.'], terms: [['Independent', 'One event does not affect the other.'], ['Sample space', 'All possible outcomes.'], ['Mutually exclusive', 'The events cannot happen at the same time.']] } },

{ id: 'm22', subj: 'maths', n: 22, title: 'Ratio and proportion', strand: 'Number', codes: ['8Nf.10', '8Nf.11', '8Nf.12'],
  secs: [
    { n: '22.1', t: 'Relating ratio and proportion', w: 'recipe',
      intro: 'Scale the recipe for different numbers of people. Every amount uses the same multiplier.',
      tasks: [['Scale to 6 people', s => s.n === 6], ['Scale down to 1 person', s => s.n === 1], ['Scale to 10 people', s => s.n === 10]],
      notice: [<>In <b>direct proportion</b>, if one quantity is multiplied by k, so is the other.</>, <>Find the amount for <b>1 unit</b> first (the unitary method).</>, <>The <b>ratio</b> between the ingredients stays the same.</>],
      check: [inp('4 pens cost $6. Cost of 10?', '15', '$1.50 each.', '$'), mc('Are these in direct proportion: 3 kg costs $12 and 5 kg costs $20?', ['Yes: $4 per kg both times', 'No', 'Only if rounded', 'Cannot tell'], 0, 'Same rate.')] },
    { n: '22.2', t: 'Simplifying and comparing ratios', w: 'ratiosimp',
      intro: 'Divide both parts by a common factor until the ratio is in its simplest form. Convert units first!',
      tasks: DONE,
      notice: [<>Simplify by dividing both parts by their <b>HCF</b>.</>, <>Use the <b>same units</b> first: 40 cm : 2 m = 40 : 200 = 1 : 5.</>, <>To compare ratios, write them as <b>1 : n</b> or with a common part.</>],
      check: [mc('Simplify 18 : 24.', ['3 : 4', '9 : 12', '6 : 8', '2 : 3'], 0, 'HCF 6.'), mc('Simplify 500 g : 2 kg.', ['1 : 4', '5 : 2', '250 : 1', '1 : 400'], 0, '500 : 2000.')] },
    { n: '22.3', t: 'Dividing a quantity into a ratio', w: 'ratiobar',
      intro: 'Share an amount in a ratio with two or three parts. Count the boxes to find one part.',
      tasks: [['Share using a 3-part ratio', s => s.c > 0], ['Share 60 in the ratio 1 : 2 : 3', s => s.t === 60 && s.a === 1 && s.b === 2 && s.c === 3]],
      notice: [<>Add the parts to find the <b>total number of parts</b>.</>, <><b>One part</b> = amount ÷ total parts.</>, <>Multiply to get each share. Check that the shares add back to the total.</>],
      check: [inp('Share $45 in the ratio 2 : 3. Larger share?', '27', '45 ÷ 5 = 9; 3 × 9.', '$'), inp('Share 84 in the ratio 1 : 2 : 4. Smallest share?', '12', '84 ÷ 7.')] },
  ],
  practice: [mc('Simplify 35 : 21.', ['5 : 3', '7 : 3', '5 : 7', '3 : 5'], 0, 'HCF 7.'), inp('Share 56 in the ratio 3 : 5. Smaller part?', '21', '56 ÷ 8 = 7; × 3.'), inp('6 eggs make 15 cakes. Eggs for 25 cakes?', '10', '15 ÷ 6 = 2.5 cakes per egg.')],
  challenge: [inp('Boys : girls = 4 : 5. There are 36 girls. How many students in total?', '81', 'One part = 9; 9 parts = 81.'), mc('Which is the better value: 400 g for $3 or 650 g for $5?', ['400 g ($0.75 per 100 g)', '650 g ($0.77 per 100 g)', 'Same', 'Cannot tell'], 0, 'Compare the cost per 100 g.')],
  recap: { points: ['Direct proportion: same multiplier; use the unitary method.', 'Simplify using the HCF; convert units first.', 'Share: total parts → one part → each share.'], terms: [['Ratio', 'A comparison of quantities, a : b.'], ['Direct proportion', 'Quantities that increase at the same rate.'], ['Unitary method', 'Find the value of one unit first.']] } },

{ id: 'm23', subj: 'maths', n: 23, title: 'Relationships and graphs', strand: 'Algebra', codes: ['8As.05', '8As.06', '8As.07'],
  secs: [
    { n: '23.1', t: 'Plotting graphs of linear functions', w: 'plotlin',
      intro: 'Use the table of values to plot each point by tapping the grid. When every point is plotted, the line is drawn.',
      tasks: DONE,
      notice: [<>Make a <b>table of values</b>: substitute each x to find y.</>, <>Plot the coordinate pairs; they lie on a <b>straight line</b>.</>, <>Use at least <b>3 points</b> so you can spot a mistake.</>],
      check: [inp('y = 3x − 1. Find y when x = −2.', '-7', '3(−2) − 1.'), mc('Does (2, 5) lie on y = 2x + 1?', ['Yes', 'No'], 0, '2(2) + 1 = 5.')] },
    { n: '23.2', t: 'Equation of a line', w: 'linear', cfg: { target: { m: 2, c: -3 } },
      intro: 'Change m and c to match the dashed target line, y = 2x − 3.',
      tasks: [['Match the dashed line', s => s.m === 2 && s.c === -3], ['Make a line with a negative gradient', s => s.m < 0]],
      notice: [<><b>y = mx + c</b>: m is the gradient and c is the y-intercept.</>, <>Gradient = <b>change in y ÷ change in x</b>.</>, <>Parallel lines have the <b>same gradient</b>.</>],
      check: [mc('Gradient of y = 7 − 2x?', ['7', '−2', '2', '−7'], 1, 'Rewrite as y = −2x + 7.'), mc('Equation with gradient 3 through (0, −4)?', ['y = 3x − 4', 'y = −4x + 3', 'y = 3x + 4', 'y = x − 4'], 0, 'm = 3, c = −4.')] },
    { n: '23.3', t: 'Real-life graphs and functions', w: 'reallife',
      intro: 'Compare two phone plans. Find where they cost the same.',
      tasks: [['Make Plan A cheaper at 15 GB', s => s.f1 + s.r1 * 15 < s.f2 + s.r2 * 15], ['Make the plans cost the same at 10 GB', s => s.cross != null && Math.abs(s.cross - 10) < 0.01]],
      notice: [<>The <b>y-intercept</b> is the fixed cost.</>, <>The <b>gradient</b> is the rate, e.g. the cost per GB.</>, <>The <b>intersection</b> is where both options give the same value.</>],
      check: [mc('On a cost graph, the gradient represents…', ['the fixed fee', 'the cost per unit', 'the total cost', 'the time'], 1, 'The rate of change.'), inp('Plan: $12 + $3 per GB. Cost for 5 GB?', '27', '12 + 15.', '$')] },
    { n: '23.4', t: 'Drawing and comparing graphs', w: 'twolines',
      intro: 'Draw two lines. Make them cross, then make them parallel.',
      tasks: [['Make the lines parallel', s => s.par && s.c1 !== s.c2], ['Make them intersect at (2, 3)', s => s.ix != null && Math.abs(s.ix - 2) < 0.01 && Math.abs(s.m1 * 2 + s.c1 - 3) < 0.01]],
      notice: [<>Where two lines cross, that point <b>satisfies both equations</b>.</>, <>Lines with equal gradients are <b>parallel</b> and never meet.</>, <>Graphs with several parts can show a journey or a change of rate.</>],
      check: [mc('y = 3x + 1 and y = 3x − 5 are…', ['perpendicular', 'parallel', 'the same line', 'intersecting at (0, 1)'], 1, 'Same gradient.'), inp('Where do y = x + 1 and y = −x + 5 meet? Give the x-coordinate.', '2', 'x + 1 = −x + 5 → x = 2.')] },
  ],
  practice: [inp('y = −2x + 4. y when x = 3?', '-2', '−6 + 4.'), mc('y-intercept of y = 5x − 8?', ['5', '−8', '8', '0'], 1, 'c = −8.'), mc('Which line is steepest?', ['y = 2x', 'y = −5x + 1', 'y = 3x + 7', 'y = x'], 1, '|−5| is the largest.')],
  challenge: [inp('A plumber charges a fixed fee plus an hourly rate. 2 hours cost $70 and 5 hours cost $130. What is the fixed fee?', '30', 'Rate = 60/3 = $20 per hour; 70 − 40 = 30.', '$'), mc('Line through (1, 4) and (3, 10)?', ['y = 3x + 1', 'y = 2x + 2', 'y = 3x + 4', 'y = 6x − 2'], 0, 'm = 6/2 = 3; 4 = 3 + c.')],
  recap: { points: ['Table of values → plot → straight line.', 'y = mx + c: m gradient, c intercept.', 'Real-life: intercept = fixed amount, gradient = rate; intersection = equal values.'], terms: [['Gradient', 'Steepness: rise ÷ run.'], ['Intercept', 'Where a graph crosses an axis.'], ['Intersection', 'The point where two graphs meet.']] } },

{ id: 'm24', subj: 'maths', n: 24, title: 'Thinking statistically', strand: 'Statistics', codes: ['8Ss.03', '8Ss.04', '8Ss.05'],
  secs: [
    { n: '24.1', t: 'Comparing and using graphs', w: 'timeseries',
      intro: 'Compare monthly temperatures in two cities. Switch between a line graph and a dual bar chart.',
      tasks: [['View both graph types', (s, H) => H('type', 'line') && H('type', 'bar')], ['Look at each city on its own', (s, H) => H('show', 'A') && H('show', 'B')]],
      notice: [<>Choose a graph to suit the data and the question.</>, <><b>Line graphs</b> are best for change over time (time series).</>, <>Compare the <b>level</b> (average) and the <b>variation</b> (range).</>],
      check: [mc('Best graph for a city\'s temperature over a year?', ['Pie chart', 'Line graph', 'Venn diagram', 'Stem-and-leaf'], 1, 'Time series.'), mc('Mumbai\'s range is 4 °C and London\'s is 16 °C. This means…', ['Mumbai is colder', 'London\'s temperature varies more through the year', 'They are equal', 'London is hotter'], 1, 'A larger range means more variation.')] },
    { n: '24.2', t: 'Comparing distributions using measures of average and spread', w: 'distrib',
      intro: 'Change Group B\'s data. Compare the two groups with an average and the range.',
      tasks: [['Make B taller on average but less spread out', s => s.shift > 0 && s.spread < 1], ['Compare using the mean', s => s.stat === 'mean']],
      notice: [<>Always compare <b>one average</b> AND <b>one measure of spread</b>.</>, <>Write <b>in context</b>: "On average Group B's plants were taller…"</>, <>The median is better than the mean when there are <b>outliers</b>.</>],
      check: [mc('Which is a measure of spread?', ['Mean', 'Median', 'Mode', 'Range'], 3, 'The range measures spread.'), mc('A data set has one very large value. Which average represents it best?', ['Mean', 'Median', 'Range', 'Total'], 1, 'The median is not affected by the extreme value.')] },
    { n: '24.3', t: 'Project', w: 'order',
      cfg: { rounds: [{ p: 'Put the steps of a statistical investigation in order', items: ['Ask a question and make a prediction (hypothesis)', 'Plan: choose the data, sample and method', 'Collect and record the data', 'Represent the data with suitable charts', 'Calculate averages and spread; interpret', 'Conclude: was the prediction correct? Suggest improvements'] }] },
      intro: 'Order the stages of a statistical project, from question to conclusion.',
      tasks: DONE,
      notice: [<>Investigations follow a cycle: <b>plan → collect → process → interpret</b>.</>, <>Justify your sampling method and sample size.</>, <>Discuss <b>variation</b> and limitations, then check your prediction.</>],
      check: [mc('What should come first?', ['Draw graphs', 'Write a question and prediction', 'Calculate the mean', 'Write the conclusion'], 1, 'Start with the question.'), mc('Why repeat with a larger sample?', ['More reliable conclusions', 'Less work', 'Bigger graphs', 'To change the hypothesis'], 0, 'It reduces the effect of chance.')] },
  ],
  practice: [inp('Data: 3, 7, 7, 9, 14. Range?', '11', '14 − 3.'), inp('Data: 3, 7, 7, 9, 14. Mean?', '8', '40/5.'), mc('Best for comparing two distributions?', ['One average only', 'An average and the range', 'Just the range', 'The total'], 1, 'Use both.')],
  challenge: [mc('Class A: mean 62, range 40. Class B: mean 65, range 12. Which statement is best?', ['A did better', 'B scored higher on average and their scores were more consistent', 'They are the same', 'A was more consistent'], 1, 'A higher mean and a smaller range.'), mc('A survey of 10 people found most prefer tea. What is the main limitation?', ['Too many people', 'The sample is small, so the result may not be reliable', 'Tea is categorical', 'Nothing'], 1, 'Small samples vary a lot.')],
  recap: { points: ['Choose graphs to fit the data (line graphs for time).', 'Compare an average AND a spread, in context.', 'Investigation cycle: question → plan → collect → represent → interpret → conclude.'], terms: [['Distribution', 'How the data values are spread out.'], ['Outlier', 'A value far from the rest.'], ['Hypothesis', 'A prediction to test.']] } },

{ id: 'm25', subj: 'maths', n: 25, title: 'Accurate drawing', strand: 'Geometry', codes: ['8Gg.12', '8Gg.07'],
  secs: [
    { n: '25.1', t: 'Construction of triangles', w: 'construct', cfg: { kind: 'sss' },
      intro: 'Step through the construction of a triangle from three sides, using a ruler and compasses.',
      tasks: [['Complete the construction', s => s.done]],
      notice: [<>To construct a triangle from <b>three sides (SSS)</b>, use a ruler and compasses.</>, <>Leave your <b>construction arcs</b> showing; they are your working.</>, <>You can also construct from <b>SAS</b> or <b>ASA</b> using a protractor.</>],
      check: [mc('Which can you NOT use to construct a unique triangle?', ['SSS', 'SAS', 'ASA', 'AAA'], 3, 'Three angles fix the shape but not the size.'), mc('Why leave the arcs?', ['They look nice', 'They show your method', 'They are needed for the area', 'They aren\'t needed'], 1, 'Arcs are evidence of an accurate construction.')] },
    { n: '25.2', t: 'Constructing bisectors', w: 'construct', cfg: { kind: 'perp' },
      intro: 'Step through the construction of a perpendicular bisector. It cuts a line in half at 90°.',
      tasks: [['Complete the construction', s => s.done]],
      notice: [<>Open the compasses to <b>more than half</b> the line, then draw arcs from both ends with the <b>same radius</b>.</>, <>Joining the crossing points gives the <b>perpendicular bisector</b>, through the midpoint at 90°.</>, <>An <b>angle bisector</b> uses the same idea to split an angle exactly in half.</>],
      check: [mc('Every point on the perpendicular bisector of AB is…', ['closer to A', 'the same distance from A and B', 'on AB', 'at 45°'], 1, 'It is equidistant from A and B.'), mc('Why must the compass radius be more than half of AB?', ['So the arcs cross', 'To make it neater', 'So it\'s 90°', 'It doesn\'t matter'], 0, 'Otherwise the arcs won\'t meet.')] },
    { n: '25.3', t: 'Plans and elevations', w: 'views',
      intro: 'Build a solid from cubes by tapping the grid. Watch its plan and elevations update.',
      tasks: [['Build a solid with 8 or more cubes', s => s.total >= 8], ['Use a stack 3 cubes high', s => s.h.some(r => r.some(v => v === 3))]],
      notice: [<>The <b>plan</b> is the view from above.</>, <>The <b>front</b> and <b>side elevations</b> are views from the front and from the side.</>, <>Draw them <b>to scale</b> on squared paper.</>],
      check: [mc('The view from directly above is called the…', ['front elevation', 'side elevation', 'plan', 'net'], 2, 'The plan is the bird\'s-eye view.'), mc('A cylinder standing upright has a plan that is a…', ['rectangle', 'circle', 'triangle', 'square'], 1, 'From above you see the circular top.')] },
  ],
  practice: [mc('A square-based pyramid seen from the front looks like a…', ['square', 'triangle', 'circle', 'pentagon'], 1, 'The elevation is a triangle.'), mc('An angle bisector divides an angle…', ['into 90°', 'into two equal angles', 'into three', 'in a 1 : 2 ratio'], 1, 'Bisect means cut in half.'), mc('Equipment for SSS?', ['Protractor only', 'Ruler and compasses', 'Set square', 'Calculator'], 1, 'Arcs with compasses.')],
  challenge: [mc('A goat is tied in a field so it stays the same distance from two trees. What path can it walk along?', ['A circle round one tree', 'The perpendicular bisector of the line between the trees', 'The line between the trees', 'An angle bisector'], 1, 'The perpendicular bisector is the set of points equidistant from both.'), mc('A shape has a circle as its plan and a rectangle as its front elevation. What is it?', ['Cone', 'Cylinder', 'Sphere', 'Prism'], 1, 'A cylinder.')],
  recap: { points: ['Construct triangles (SSS, SAS, ASA) with a ruler, compasses and protractor.', 'Perpendicular bisector: equal arcs from both ends. Angle bisector: equal arcs from the arms.', 'Plan = from above; elevations = front and side.'], terms: [['Bisector', 'A line that cuts something exactly in half.'], ['Perpendicular', 'At right angles.'], ['Elevation', 'A view from the front or side.']] } },
);
})();
