form 1 topics added

This commit is contained in:
2026-07-05 11:12:45 -04:00
parent a614532810
commit a23fa53772
58 changed files with 7089 additions and 475 deletions

View File

@@ -7,6 +7,58 @@ function nextId() {
return `rp-${++counter}-${Date.now()}`;
}
export function generateDefineRatio(difficulty: Difficulty): MathProblem {
const contexts = [
{ a: "red", b: "blue", item: "counters in a bag" },
{ a: "boys", b: "girls", item: "in the class" },
{ a: "cats", b: "dogs", item: "at the shelter" },
{ a: "apples", b: "oranges", item: "in the basket" },
];
const ctx = randomChoice(contexts);
const g = randomChoice(difficulty === 1 ? [1, 2] : difficulty === 2 ? [2, 3, 4] : [3, 4, 5, 6]);
const x = randomInt(1, difficulty === 1 ? 6 : 8) * g;
const y = randomInt(1, difficulty === 1 ? 6 : 8) * g;
const simplified = simplifyRatio([x, y]);
return {
id: nextId(),
prompt: `\\begin{array}{l}\\text{There are ${x} ${ctx.a} and ${y} ${ctx.b} ${ctx.item}.}\\\\\\text{Write the ratio of ${ctx.a} to ${ctx.b} in its simplest form.}\\end{array}`,
answer: { kind: "ratio", parts: simplified },
hints: [
`Write it as ${x} : ${y} first.`,
"Divide both parts by their highest common factor.",
],
steps: [
{ explanation: `The ratio of ${ctx.a} to ${ctx.b} is ${x} : ${y}.` },
{ explanation: `In simplest form: ${simplified.join(" : ")}` },
],
};
}
export function generateFractionsAndRatios(difficulty: Difficulty): MathProblem {
const a = randomInt(1, difficulty === 1 ? 4 : 7);
const b = randomInt(1, difficulty === 1 ? 4 : 7);
const whole = a + b;
const which = randomChoice([0, 1] as const);
const part = which === 0 ? a : b;
const [n, d] = simplifyRatio([part, whole]);
return {
id: nextId(),
prompt: `\\begin{array}{l}\\text{Two amounts are shared in the ratio } ${a} : ${b}.\\\\\\text{What fraction of the whole is the ${which === 0 ? "first" : "second"} part?}\\end{array}`,
answer: { kind: "fraction", numerator: n, denominator: d },
hints: [
`The whole is ${a} + ${b} = ${whole} parts.`,
`The ${which === 0 ? "first" : "second"} part is ${part} out of ${whole}.`,
"Simplify the fraction.",
],
steps: [
{ explanation: `Total parts: ${a} + ${b} = ${whole}.` },
{ explanation: `Fraction = ${part}/${whole}, which simplifies to ${n}/${d}.` },
],
};
}
export function generateSimplifyRatio(difficulty: Difficulty): MathProblem {
const gcd = randomChoice(difficulty === 1 ? [2, 3, 4, 5] : difficulty === 2 ? [3, 4, 5, 6, 7] : [4, 6, 8, 9, 12]);
const a = randomInt(1, difficulty === 1 ? 5 : 10) * gcd;