/* Maths chapters 9–16 */
(() => {
const { mc, inp, ord, DONE } = window.QH;
BOOK.push(
{ id: 'm9', subj: 'maths', n: 9, title: 'Functions and formulae', strand: 'Algebra', codes: ['8As.03', '8Ae.05'],
  secs: [
    { n: '9.1', t: 'Functions', w: 'machine',
      intro: 'Build a two-step function machine. Feed it inputs, then switch to the inverse to work backwards.',
      tasks: [['Try at least 4 different inputs', (s, H) => H('__count_x', 4)], ['Use the inverse machine', s => s.inv], ['Make input 3 give output 10', s => s.x === 3 && s.y === 10 && !s.inv]],
      notice: [<>A <b>function</b> gives exactly <b>one output</b> for each input.</>, <>Function notation: x → 2x + 4.</>, <>To find the input, use the <b>inverse</b>: undo each step in <b>reverse order</b>.</>],
      check: [inp('x → 3x − 2. Output when x = 5?', '13', '3 × 5 − 2 = 13.'), inp('x → 2x + 7. The output is 19. Input?', '6', 'Reverse: 19 − 7 = 12, then ÷ 2 = 6.')] },
    { n: '9.2', t: 'Constructing and using formulae', w: 'formula',
      cfg: { f: { name: 'Taxi fare: $3 fixed charge plus $2 per km', f: 'C = 3 + 2d', vars: [['d', 'Distance (km)', 0, 20, 1]], calc: v => 3 + 2 * v.d, out: 'Cost C', unit: '$' } },
      intro: 'A taxi charges $3 to start, plus $2 per km. Change the distance and see how the formula gives the cost.',
      tasks: [['Find the cost of a 12 km ride', s => s.v.d === 12], ['Find the distance that costs $23', s => s.r === 23]],
      notice: [<>A <b>formula</b> describes a rule in symbols: <b>C = 3 + 2d</b>.</>, <>Build it from words: fixed part + rate × variable.</>, <><b>Substitute</b> values to use it; define every letter you use.</>],
      check: [mc('Hire a bike: $5 plus $3 per hour (h). Formula for cost C?', ['C = 8h', 'C = 5 + 3h', 'C = 3 + 5h', 'C = 5h + 3h'], 1, 'Fixed $5 + $3 for each hour.'), inp('Using C = 5 + 3h, find C when h = 4.', '17', '5 + 12 = 17.')] },
    { n: '9.3', t: 'Changing the subject', w: 'steps',
      cfg: { rounds: [
        { p: 'Make x the subject of y = 3x + 5', start: 'y = 3x + 5', steps: [['− 5', 'y − 5 = 3x'], ['÷ 3', 'x = (y − 5)/3']], opts: ['− 5', '÷ 3', '+ 5', '× 3'] },
        { p: 'Make u the subject of v = u + at', start: 'v = u + at', steps: [['− at', 'u = v − at']], opts: ['− at', '÷ a', '+ v', '× t'] },
        { p: 'Make r the subject of C = 2πr', start: 'C = 2πr', steps: [['÷ 2π', 'r = C/(2π)']], opts: ['÷ 2π', '− 2π', '× r', '÷ C'] },
        { p: 'Make a the subject of P = 2(a + b)', start: 'P = 2(a + b)', steps: [['÷ 2', 'P/2 = a + b'], ['− b', 'a = P/2 − b']], opts: ['÷ 2', '− b', '− 2', '× 2'] },
      ] },
      intro: 'Rearrange each formula. Choose the inverse operation to do to both sides, one step at a time.',
      tasks: DONE,
      notice: [<>The <b>subject</b> is the letter on its own on one side.</>, <>Use <b>inverse operations</b>, doing the same to both sides, like solving an equation.</>, <>Undo in <b>reverse order</b>: the last thing done to the letter is undone first.</>],
      check: [mc('Make t the subject of s = d/t.', ['t = sd', 't = d/s', 't = s/d', 't = d − s'], 1, 'Multiply by t: st = d. Then divide by s.'), mc('Make x the subject of y = (x − 4)/2.', ['x = 2y + 4', 'x = 2y − 4', 'x = y/2 + 4', 'x = 2(y − 4)'], 0, '× 2 gives 2y = x − 4, then + 4.')] },
  ],
  practice: [inp('x → x/2 + 1. Output for x = 10?', '6', '10/2 + 1.'), mc('Area of a triangle: A = ½bh. Make h the subject.', ['h = 2A/b', 'h = A/2b', 'h = 2b/A', 'h = Ab/2'], 0, '× 2 then ÷ b.'), inp('F = 1.8C + 32. Find F when C = 25.', '77', '45 + 32.')],
  challenge: [mc('Which machine is NOT a function?', ['x → 2x', 'x → x²', 'x → ±√x', 'x → x + 1'], 2, '±√x gives two outputs for one input.'), inp('Rearrange F = 1.8C + 32 to find C when F = 50.', '10', '(50 − 32)/1.8 = 10.')],
  recap: { points: ['A function maps each input to exactly one output.', 'Formulae: build from words; substitute values.', 'Change the subject using inverse operations in reverse order.'], terms: [['Function', 'A rule with exactly one output per input.'], ['Subject', 'The letter a formula is written in terms of.'], ['Inverse', 'The operation that undoes another.']] } },

{ id: 'm10', subj: 'maths', n: 10, title: 'Fractions', strand: 'Number', codes: ['8Nf.02', '8Nf.03'],
  secs: [
    { n: '10.1', t: 'Subtracting mixed numbers', w: 'mixed',
      intro: 'Set two mixed numbers. Follow the steps, and see when you need to borrow a whole.',
      tasks: [['Make a subtraction that needs borrowing', s => s.borrow && s.pos], ['Make the denominators different', s => s.L > 1 && s.pos]],
      notice: [<><b>Estimate</b> first by rounding to whole numbers.</>, <>Write both fractions with a <b>common denominator</b>.</>, <>If the first fraction is smaller, <b>borrow 1 whole</b>: 3¼ = 2 + 5/4.</>],
      check: [mc('4⅓ − 1½ = ?', ['3⅙', '2⅚', '3⅚', '2⅙'], 1, '4 2/6 − 1 3/6 → borrow: 3 8/6 − 1 3/6 = 2 5/6.'), mc('Estimate 5⅞ − 2⅛.', ['3', '4', '7', '8'], 1, '6 − 2 = 4.')] },
    { n: '10.2', t: 'Multiplying and dividing integers by fractions', w: 'fracdiv',
      intro: 'See how many fraction pieces fit into an integer, then multiply an integer by a mixed number.',
      tasks: [['Divide an integer by a fraction', s => s.mode === '÷' && s.q > 2], ['Multiply an integer by a mixed number', s => s.mode === '×']],
      notice: [<>Dividing by a fraction asks "<b>how many of these fit?</b>" 3 ÷ ¼ = 12.</>, <>So <b>÷ p/q = × q/p</b> (flip and multiply).</>, <>For an integer × mixed number, <b>split</b>: 3 × 2¼ = 6 + ¾ = 6¾.</>],
      check: [inp('5 ÷ ⅓ = ?', '15', 'There are 3 thirds in each whole, and 5 × 3 = 15.'), mc('4 × 1⅔ = ?', ['4⅔', '6⅔', '5⅓', '6'], 1, '4 + 8/3 = 4 + 2⅔ = 6⅔.')] },
  ],
  practice: [mc('3¼ − 1⅔ = ?', ['1 7/12', '2 7/12', '1 5/12', '2 1/12'], 0, '3 3/12 − 1 8/12 → 2 15/12 − 1 8/12 = 1 7/12.'), inp('6 ÷ ⅔ = ?', '9', '6 × 3/2 = 9.'), mc('2 × 3½ = ?', ['6½', '7', '6', '7½'], 1, '6 + 1 = 7.')],
  challenge: [inp('A ribbon is 6 m long. How many pieces of ¾ m can be cut from it?', '8', '6 ÷ ¾ = 6 × 4/3 = 8.'), mc('Why is 4 ÷ ½ bigger than 4?', ['Division always makes bigger', 'There are 2 halves in each whole, so 8 halves in 4', 'It is a mistake', 'Because ½ < 1, you subtract'], 1, 'Dividing by a number less than 1 gives a larger answer.')],
  recap: { points: ['Subtract mixed numbers: common denominator, borrow if needed, simplify.', 'Integer ÷ fraction = integer × reciprocal.', 'Integer × mixed number: multiply the whole and fraction parts separately.'], terms: [['Mixed number', 'A whole number and a fraction, e.g. 2¾.'], ['Reciprocal', 'Flip of a fraction: 3/4 → 4/3.'], ['Common denominator', 'A shared bottom number.']] } },

{ id: 'm11', subj: 'maths', n: 11, title: 'Length, area and volume', strand: 'Geometry', codes: ['8Gg.03', '8Gg.04', '8Gg.06', '8Gg.08'],
  secs: [
    { n: '11.1', t: 'Converting between miles and kilometres', w: 'convert',
      intro: 'Slide the miles and read off the kilometres on the double number line.',
      tasks: [['Convert 25 miles', s => s.m === 25], ['Find the miles for 80 km', s => s.km === 80]],
      notice: [<><b>5 miles ≈ 8 km</b>.</>, <>Miles → km: <b>÷ 5 × 8</b>. Km → miles: <b>÷ 8 × 5</b>.</>, <>A kilometre is <b>shorter</b> than a mile, so there are more km.</>],
      check: [inp('Convert 40 miles to km.', '64', '40 ÷ 5 × 8 = 64.', 'km'), inp('Convert 120 km to miles.', '75', '120 ÷ 8 × 5 = 75.', 'miles')] },
    { n: '11.2', t: 'Area of 2D shapes', w: 'area',
      intro: 'Cut and slide the parallelogram, then double the trapezium, to see where each area formula comes from.',
      tasks: [['Cut and slide a parallelogram', s => s.shape === 'para' && s.cut], ['Double a trapezium', s => s.shape === 'trap' && s.cut]],
      notice: [<>Parallelogram: <b>A = bh</b>, using the <b>perpendicular</b> height.</>, <>Trapezium: <b>A = ½(a + b)h</b>.</>, <>Both come from rectangles and triangles you already know.</>],
      check: [inp('Parallelogram: base 9 cm, perpendicular height 4 cm. Area?', '36', '9 × 4.', 'cm²'), inp('Trapezium: parallel sides 5 cm and 9 cm, height 6 cm. Area?', '42', '½ × 14 × 6.', 'cm²')] },
    { n: '11.3', t: 'Volume of triangular prisms', w: 'prism',
      intro: 'Change the triangle and the length. Volume = cross-section area × length.',
      tasks: [['Make a prism with volume 60 cm³', s => s.V === 60], ['Change all three dimensions', (s, H) => H('b', 6) || H('h', 5)]],
      notice: [<>The cross-section of a triangular prism is a <b>triangle</b>: area ½bh.</>, <><b>V = ½bh × l</b>.</>, <>Volume is measured in <b>cubic units</b> (cm³, m³).</>],
      check: [inp('Triangle base 6 cm, height 4 cm, prism length 10 cm. Volume?', '120', '½ × 6 × 4 = 12; × 10.', 'cm³'), mc('Which units are for volume?', ['cm', 'cm²', 'cm³', 'cm⁴'], 2, 'Three dimensions.')] },
    { n: '11.4', t: 'Surface area of 3D shapes', w: 'net',
      intro: 'Look at the net of each shape. Change the dimensions and add up the areas of all the faces.',
      tasks: [['Find the surface area of a 4 × 3 × 2 cuboid', s => s.shape === 'cuboid' && s.a === 4 && s.b === 3 && s.c === 2], ['Look at a square pyramid', s => s.shape === 'pyr']],
      notice: [<>Surface area = the <b>total area of all faces</b>, so draw the net.</>, <>Cuboid: <b>2(lw + lh + wh)</b>.</>, <>Square pyramid: base + <b>4 triangles</b> (using the slant height).</>],
      check: [inp('Surface area of a cube with edge 3 cm?', '54', '6 × 9.', 'cm²'), inp('Cuboid 5 × 2 × 1. Surface area?', '34', '2(10 + 5 + 2) = 34.', 'cm²')] },
  ],
  practice: [inp('15 miles ≈ ? km', '24', '15 ÷ 5 × 8.'), inp('Trapezium a = 3, b = 7, h = 4. Area?', '20', '½ × 10 × 4.'), inp('Triangular prism: cross-section 15 cm², length 8 cm. Volume?', '120', '15 × 8.')],
  challenge: [inp('A tent is a triangular prism: triangle base 2 m, height 1.5 m, length 3 m. Volume?', '4.5', '½ × 2 × 1.5 = 1.5; × 3.', 'm³'), mc('Two cuboids have the same volume. Must they have the same surface area?', ['Yes', 'No: e.g. 1×1×8 and 2×2×2 both have volume 8 but SA 34 and 24', 'Only if they are cubes', 'Yes, if made of the same material'], 1, 'Different shapes can enclose the same volume.')],
  recap: { points: ['5 miles ≈ 8 km.', 'Parallelogram A = bh; trapezium A = ½(a + b)h.', 'Prism V = cross-section × length.', 'Surface area = sum of the face areas (use a net).'], terms: [['Perpendicular height', 'Height at 90° to the base.'], ['Cross-section', 'The shape you see when you slice through a prism.'], ['Net', 'A flat shape that folds into a 3D solid.']] } },

{ id: 'm12', subj: 'maths', n: 12, title: 'Probability 1', strand: 'Probability', codes: ['8Sp.01', '8Sp.04'],
  secs: [
    { n: '12.1', t: 'Complementary events', w: 'spinner',
      intro: 'Set up a spinner. Compare P(red) and P(not red), then spin it.',
      tasks: [['Make P(red) = 1/4', s => s.red / s.n === 0.25], ['Spin the spinner', s => s.last != null]],
      notice: [<>An event and its <b>complement</b> cover every outcome.</>, <>P(A) + P(not A) = <b>1</b>.</>, <>So <b>P(not A) = 1 − P(A)</b>.</>],
      check: [inp('P(rain) = 0.35. P(no rain)?', ['0.65', '.65'], '1 − 0.35.'), mc('P(win) = 3/8. P(not win)?', ['3/8', '5/8', '8/3', '1/8'], 1, '1 − 3/8.')] },
    { n: '12.2', t: 'Experimental probability', w: 'experiment',
      intro: 'Run lots of trials. Watch the relative frequency settle towards the theoretical probability.',
      tasks: [['Do at least 1000 trials', s => s.tot >= 1000]],
      notice: [<><b>Relative frequency</b> = successes ÷ trials.</>, <>With <b>more trials</b> it gets closer to the theoretical probability.</>, <>A big difference after many trials suggests the dice or coin may be <b>biased</b>.</>],
      check: [inp('A drawing pin lands point-up 36 times in 120 throws. Relative frequency?', ['0.3', '.3', '3/10'], '36 ÷ 120.'), mc('Which gives the best estimate of a probability?', ['10 trials', '50 trials', '500 trials', 'One trial'], 2, 'More trials give a more reliable estimate.')] },
  ],
  practice: [inp('P(A) = 0.92. P(not A)?', ['0.08', '.08'], '1 − 0.92.'), inp('Rolled 200 times; 46 sixes. Relative frequency of a 6?', ['0.23', '.23'], '46/200.'), mc('Theoretical P(6) on a fair dice?', ['1/2', '1/3', '1/6', '6'], 2, 'One of six outcomes.')],
  challenge: [mc('A dice is rolled 600 times and lands on 6 a total of 180 times. What does this suggest?', ['Fair', 'Probably biased towards 6: you would expect about 100', 'Too few trials', 'Nothing'], 1, '180/600 = 0.3, much more than 1/6 ≈ 0.17.'), inp('A bag has red, blue and green. P(red) = 0.4, P(blue) = 0.25. P(green)?', ['0.35', '.35'], '1 − 0.4 − 0.25.')],
  recap: { points: ['P(not A) = 1 − P(A).', 'Relative frequency = successes ÷ trials.', 'More trials give a better estimate of the probability.'], terms: [['Complement', 'The event that A does not happen.'], ['Relative frequency', 'The experimental probability.'], ['Biased', 'Not every outcome is equally likely.']] } },

{ id: 'm13', subj: 'maths', n: 13, title: 'Calculations', strand: 'Number', codes: ['8Ni.01', '8Nf.04'],
  secs: [
    { n: '13.1', t: 'Order of operations', w: 'order',
      cfg: { rounds: [
        { p: 'Put the steps for 3 + 4 × (6 − 2)² in the right order', items: ['Brackets: 6 − 2 = 4', 'Indices: 4² = 16', 'Multiply: 4 × 16 = 64', 'Add: 3 + 64 = 67'] },
        { p: 'Order the steps for 20 − 12 ÷ 3 + √25', items: ['Root: √25 = 5', 'Divide: 12 ÷ 3 = 4', 'Subtract (left to right): 20 − 4 = 16', 'Add: 16 + 5 = 21'] },
        { p: 'Order the steps for (2 + 3)³ ÷ 5 − 1', items: ['Brackets: 2 + 3 = 5', 'Index: 5³ = 125', 'Divide: 125 ÷ 5 = 25', 'Subtract: 25 − 1 = 24'] },
      ] },
      intro: 'Put the working steps in the correct order: Brackets, Indices and roots, × ÷, then + −.',
      tasks: DONE,
      notice: [<><b>B</b>rackets → <b>I</b>ndices (including roots) → <b>D</b>ivision / <b>M</b>ultiplication → <b>A</b>ddition / <b>S</b>ubtraction.</>, <>× and ÷ have equal priority, so work <b>left to right</b>. The same goes for + and −.</>, <>A fraction bar acts like brackets around the top and bottom.</>],
      check: [inp('Calculate 5 + 3 × 2².', '17', '2² = 4, then 3 × 4 = 12, then 5 + 12 = 17.'), inp('Calculate (18 − 6) ÷ 3 + 1.', '5', '12 ÷ 3 = 4, then + 1.')] },
    { n: '13.2', t: 'Simplifying calculations with decimals and fractions', w: 'match',
      cfg: { h: ['Calculation', 'Easier way'], pairs: [['0.25 × 37 × 4', '(0.25 × 4) × 37 = 37'], ['4.7 × 6 + 5.3 × 6', '(4.7 + 5.3) × 6 = 60'], ['¾ × 19 − ¾ × 15', '¾ × (19 − 15) = 3'], ['2.5 × 8.4 × 0.4', '(2.5 × 0.4) × 8.4 = 8.4'], ['99 × 0.6', '100 × 0.6 − 0.6 = 59.4']] },
      intro: 'Match each calculation to the clever way to work it out using the laws of arithmetic.',
      tasks: DONE,
      notice: [<><b>Commutative</b> and <b>associative</b> laws: reorder and regroup multiplications (0.25 × 4 = 1).</>, <><b>Distributive</b> law: a × b + a × c = a(b + c).</>, <>Look for numbers that make <b>1, 10 or 100</b>.</>],
      check: [inp('Work out 0.5 × 23 × 2.', '23', '0.5 × 2 = 1.'), inp('Work out 3.2 × 7 + 6.8 × 7.', '70', '(3.2 + 6.8) × 7 = 10 × 7.')] },
  ],
  practice: [inp('12 − 8 ÷ 4 × 3 = ?', '6', '8 ÷ 4 = 2; × 3 = 6; 12 − 6 = 6.'), inp('(4 + 2)² ÷ 9 = ?', '4', '36 ÷ 9.'), inp('⅖ × 13 + ⅖ × 7 = ?', '8', '⅖ × 20.')],
  challenge: [mc('Which needs brackets to make 30? 2 + 4 × 5', ['(2 + 4) × 5', '2 + (4 × 5)', '2 × (4 + 5)', 'No brackets needed'], 0, '6 × 5 = 30.'), inp('Calculate (3 + √16)² − 10 ÷ 2.', '44', '(3 + 4)² = 49; 49 − 5 = 44.')],
  recap: { points: ['BIDMAS: brackets, indices, ×÷ (left to right), +− (left to right).', 'Use the commutative, associative and distributive laws to simplify.', 'Look for pairs that make 1, 10 or 100.'], terms: [['Distributive law', 'a(b + c) = ab + ac.'], ['Associative', 'Grouping doesn\'t change the result for × or +.'], ['Commutative', 'Order doesn\'t change the result for × or +.']] } },

{ id: 'm14', subj: 'maths', n: 14, title: 'Equations and inequalities', strand: 'Algebra', codes: ['8Ae.06', '8Ae.07'],
  secs: [
    { n: '14.1', t: 'Solving equations with brackets and fractions', w: 'steps',
      cfg: { rounds: [
        { p: 'Solve 3(x + 4) = 27', start: '3(x + 4) = 27', steps: [['÷ 3', 'x + 4 = 9'], ['− 4', 'x = 5']], opts: ['÷ 3', '− 4', '× 3', '+ 4'] },
        { p: 'Solve x/5 + 2 = 6', start: 'x/5 + 2 = 6', steps: [['− 2', 'x/5 = 4'], ['× 5', 'x = 20']], opts: ['− 2', '× 5', '÷ 5', '+ 2'] },
        { p: 'Solve (2x − 1)/3 = 5', start: '(2x − 1)/3 = 5', steps: [['× 3', '2x − 1 = 15'], ['+ 1', '2x = 16'], ['÷ 2', 'x = 8']], opts: ['× 3', '+ 1', '÷ 2', '− 1', '÷ 3'] },
      ] },
      intro: 'Choose the inverse operation to do to both sides at each step.',
      tasks: DONE,
      notice: [<>With a bracket, you can <b>divide first</b> or <b>expand first</b>.</>, <>With a fraction, <b>multiply both sides</b> by the denominator.</>, <>Check by substituting your answer back in.</>],
      check: [inp('Solve 4(x − 2) = 20.', '7', 'x − 2 = 5.'), inp('Solve x/3 − 1 = 4.', '15', 'x/3 = 5.')] },
    { n: '14.2', t: 'Solving equations with unknowns on both sides', w: 'balance',
      cfg: { eqs: [[5, 2, 2, 17], [7, -4, 3, 8], [6, 1, 2, 13]] },
      intro: 'Keep the scales balanced. Remove x-blocks and number tiles from both sides until x is alone.',
      tasks: DONE,
      notice: [<>Remove the <b>smaller x term</b> from both sides first.</>, <>Then deal with the numbers, then divide.</>, <>Whatever you do to one side, <b>do to the other</b>.</>],
      check: [inp('Solve 5x + 3 = 2x + 15.', '4', '3x = 12.'), inp('Solve 7x − 5 = 3x + 11.', '4', '4x = 16.')] },
    { n: '14.3', t: 'Constructing equations', w: 'slots',
      cfg: { rounds: [
        { p: 'I think of a number, multiply by 4 and add 7. The answer is 31.', t: '{} n {} 7 = {}', a: ['4', '+', '31'], x: ['3', '−', '7'] },
        { p: 'A rectangle has length (x + 5) and width 3. Its area is 24.', t: '{}(x {} 5) = {}', a: ['3', '+', '24'], x: ['2', '−', '12'] },
        { p: 'Ali is 3 times as old as Ben. Together they are 48.', t: 'b + {}b = {}', a: ['3', '48'], x: ['2', '45'] },
      ] },
      intro: 'Turn each word problem into an equation. Fill the gaps with the right tiles.',
      tasks: DONE,
      notice: [<><b>Choose a letter</b> for the unknown and say what it means.</>, <>Translate the words step by step into symbols.</>, <>Then <b>solve</b> it and answer the question in words.</>],
      check: [mc('Three consecutive numbers add to 57. If the first is n, which equation?', ['3n = 57', 'n + (n + 1) + (n + 2) = 57', 'n + 3 = 57', '3n + 1 = 57'], 1, 'Consecutive means n, n + 1, n + 2.'), inp('Solve 4n + 7 = 31.', '6', '4n = 24.')] },
    { n: '14.4', t: 'Inequalities', w: 'ineq',
      intro: 'Change the inequality and watch it on the number line. Open circles mean "not included".',
      tasks: [['Show −2 ≤ x < 3', s => s.both && s.a === -2 && s.la === '≤' && s.b === 3 && s.lb === '<'], ['Show a one-sided inequality', s => !s.both]],
      notice: [<><b>&lt;</b> and <b>&gt;</b> use an <b>open circle</b>: the end is not included.</>, <><b>≤</b> and <b>≥</b> use a <b>filled circle</b>: the end is included.</>, <>An inequality like −1 &lt; x ≤ 4 describes an <b>interval</b> of values.</>],
      check: [mc('Which integers satisfy −1 < x ≤ 2?', ['−1, 0, 1, 2', '0, 1, 2', '0, 1', '−1, 0, 1'], 1, '−1 is not included; 2 is included.'), mc('A filled circle at 5 with an arrow left shows…', ['x < 5', 'x ≤ 5', 'x > 5', 'x ≥ 5'], 1, 'Filled means included; left means less than.')] },
  ],
  practice: [inp('Solve 2(3x + 1) = 26.', '4', '6x + 2 = 26.'), inp('Solve 9x − 4 = 5x + 8.', '3', '4x = 12.'), mc('List the integers with 3 ≤ n < 6.', ['3, 4, 5', '4, 5, 6', '3, 4, 5, 6', '4, 5'], 0, '3 included; 6 not.')],
  challenge: [inp('Two sides of an isosceles triangle are (3x + 2) cm and (5x − 6) cm, and they are equal. Find x.', '4', '3x + 2 = 5x − 6 → 8 = 2x.'), inp('Solve (x + 3)/2 = (x + 9)/4.', '3', '× 4: 2(x + 3) = x + 9 → 2x + 6 = x + 9.')],
  recap: { points: ['Do the same to both sides; undo in reverse order.', 'Unknowns on both sides: remove the smaller x term first.', 'Construct equations by defining a letter and translating the words.', 'Inequalities: open circle for < >, filled circle for ≤ ≥.'], terms: [['Inequality', 'A statement using <, >, ≤ or ≥.'], ['Interval', 'A range of values between two limits.'], ['Solve', 'Find the value that makes the equation true.']] } },

{ id: 'm15', subj: 'maths', n: 15, title: 'Midpoints', strand: 'Geometry', codes: ['8Gp.02'],
  secs: [
    { n: '15.1', t: 'Midpoint of a line segment', w: 'midpoint',
      intro: 'Drag A and B anywhere on the grid. Watch the midpoint and the calculation.',
      tasks: [['Make a midpoint with a non-integer coordinate', s => !Number.isInteger(s.M[0]) || !Number.isInteger(s.M[1])], ['Put one end in a negative quadrant', s => s.A[0] < 0 && s.A[1] < 0 || s.B[0] < 0 && s.B[1] < 0], ['Make the midpoint (0, 0)', s => s.M[0] === 0 && s.M[1] === 0]],
      notice: [<>Midpoint = <b>(mean of the x-coordinates, mean of the y-coordinates)</b>.</>, <>M = ((x₁ + x₂)/2, (y₁ + y₂)/2).</>, <>It works with <b>negative</b> coordinates too.</>],
      check: [mc('Midpoint of (2, 7) and (8, 3)?', ['(5, 5)', '(10, 10)', '(3, 2)', '(6, −4)'], 0, '(10/2, 10/2).'), mc('Midpoint of (−4, 1) and (2, −5)?', ['(−1, −2)', '(−3, 3)', '(1, 2)', '(−2, −4)'], 0, '(−2/2, −4/2).')] },
  ],
  practice: [mc('Midpoint of (0, 0) and (6, 10)?', ['(3, 5)', '(6, 10)', '(12, 20)', '(5, 3)'], 0, 'Halve each.'), mc('Midpoint of (−3, −3) and (5, 1)?', ['(1, −1)', '(2, −2)', '(4, 2)', '(−1, 1)'], 0, '(2/2, −2/2).')],
  challenge: [mc('M(3, 4) is the midpoint of AB, and A is (1, 1). Find B.', ['(5, 7)', '(2, 2.5)', '(4, 5)', '(2, 3)'], 0, 'From A to M: +2, +3. Same again from M: (5, 7).'), mc('Ravi says the midpoint of (2, 6) and (8, 2) is (6, −4). What did he do?', ['Correct', 'He subtracted instead of adding and halving', 'He added only', 'He swapped x and y'], 1, '8 − 2 = 6, 2 − 6 = −4 are differences, not means.')],
  recap: { points: ['Midpoint = average of the x-coordinates and average of the y-coordinates.', 'Works in all four quadrants.', 'Work backwards from a midpoint by repeating the step.'], terms: [['Midpoint', 'The point exactly halfway along a line segment.'], ['Line segment', 'Part of a line with two end points.'], ['Coordinate', 'A position (x, y).']] } },

{ id: 'm16', subj: 'maths', n: 16, title: 'Fractions, decimals and percentages', strand: 'Number', codes: ['8Nf.01', '8Nf.06'],
  secs: [
    { n: '16.1', t: 'Recurring decimals', w: 'longdiv',
      intro: 'Change the fraction and watch the long division. Does the decimal stop or repeat?',
      tasks: [['Find a fraction with a 1-digit repeating cycle', s => s.period === 1], ['Find one with a cycle of 6 digits', s => s.period === 6], ['Find a terminating decimal', s => s.term]],
      notice: [<>Some fractions give <b>terminating</b> decimals (⅛ = 0.125); others give <b>recurring</b> decimals (⅓ = 0.333…).</>, <>A dot or bar shows the repeating digits: 0.1̇6̇ or 0.1666…</>, <>A fraction in simplest form terminates only if the denominator's prime factors are <b>2s and 5s</b>.</>],
      check: [mc('Which recurs?', ['3/8', '7/20', '5/12', '9/25'], 2, '12 has the prime factor 3.'), mc('2/9 as a decimal?', ['0.29', '0.2̇', '0.22', '0.4'], 1, '0.222…')] },
    { n: '16.2', t: 'Comparing fractions and decimals', w: 'compare',
      intro: 'Compare a fraction and a decimal on the number line. Try negative numbers too.',
      tasks: [['Make them equal', s => s.sym === '='], ['Compare two negative numbers', s => s.neg]],
      notice: [<>Convert the fraction to a <b>decimal</b> to compare.</>, <>Use the symbols <b>=, ≠, &lt;, &gt;, ≤, ≥</b>.</>, <>For negatives, the number further <b>left</b> is smaller: −0.8 &lt; −0.75.</>],
      check: [mc('Which is true?', ['5/8 > 0.65', '5/8 < 0.65', '5/8 = 0.65', '5/8 ≥ 0.7'], 1, '5/8 = 0.625.'), mc('Which is true?', ['−3/4 > −0.7', '−3/4 < −0.7', '−3/4 = −0.7', '−0.7 < −3/4'], 1, '−0.75 is further left than −0.7.')] },
    { n: '16.3', t: 'Comparing fractions by converting to percentages', w: 'pctbar',
      intro: 'Compare two test scores out of different totals by turning each into a percentage.',
      tasks: [['Make the scores equal as percentages but with different fractions', s => Math.abs(s.p1 - s.p2) < 0.01 && s.b !== s.d], ['Make 17/20 vs 21/25 and compare', s => s.a === 17 && s.b === 20 && s.c === 21 && s.d === 25]],
      notice: [<>Percentage = <b>fraction × 100</b>.</>, <>Percentages are all "out of 100", so they are easy to compare.</>, <>Useful when the totals are different: 17/20 = 85%, 21/25 = 84%.</>],
      check: [inp('Write 13/20 as a percentage.', '65', '13 × 5 = 65.', '%'), mc('Which is the better score: 18/25 or 29/40?', ['18/25 (72%)', '29/40 (72.5%)', 'Equal', 'Can\'t tell'], 1, '29/40 = 72.5%.')] },
  ],
  practice: [mc('7/11 as a decimal…', ['terminates', 'recurs', 'is 0.7', 'is 7.11'], 1, '11 is not made of 2s and 5s.'), mc('Order: 0.6, 5/8, 61%', ['0.6, 61%, 5/8', '5/8, 0.6, 61%', '61%, 0.6, 5/8', '0.6, 5/8, 61%'], 0, '0.6, 0.61, 0.625.'), inp('9/16 as a percentage?', '56.25', '9 ÷ 16 = 0.5625.', '%')],
  challenge: [mc('Is 3/7 terminating or recurring, and why?', ['Terminating: 7 is prime', 'Recurring: 7 is a prime factor other than 2 or 5', 'Terminating: 3/7 < 1', 'Neither'], 1, 'Only denominators made of 2s and 5s terminate.'), mc('Which symbol makes this true: −0.45 ? −4/9', ['<', '>', '=', '≤'], 0, '−4/9 = −0.444…, and −0.45 is further left.')],
  recap: { points: ['Terminating if the denominator (simplest form) has only 2 and 5 as prime factors.', 'Compare by converting to the same form.', 'Percentages make comparing different totals easy.'], terms: [['Recurring decimal', 'Digits that repeat for ever.'], ['Terminating decimal', 'A decimal that ends.'], ['≠', 'Not equal to.']] } },
);
})();
