Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

18.3 KB
Raw Blame
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Unit Rate and Unit Price — Elementary Mathematics</title><link rel="stylesheet" href="../lib/engine.css"><link rel="expect" href="#bar" blocking="render"><style>.band .prompt{font-size:27px}.side .keys{font-size:19px}.screen .blanks .bline{gap:12px}.screen .blanks .box{width:7ch!important}.screen .blanks .why{font-size:22px}.screen .blanks .bline svg tspan{font-style:normal}</style></head><body>
<script src="../lib/engine.js"></script><script src="audio/en/timings.js"></script><script>
'use strict';
const CHAPTER={number:16,title:'Unit Rate and Unit Price',minutes:10,language:'en', next: '../ch17/' };
// Reuse ch15 text/math entrance pattern; quantities blue, time/item denominator coral, focus amber.
const urText=(p,s,x,y,t=0,size=30,col=COL.chalk,anchor='start')=>{const e=T(p,s,{x,y,size,fill:col,anchor,o:0});show(e,t);return e;};
const urMath=(p,s,x,y,t=0,size=52,col=COL.chalk)=>{const e=M(p,Array.isArray(s)?s:[s],{x,y,size,fill:col,anchor:'middle',o:0});show(e,t);return e;};
const urTitle=(p,s,sub='')=>{urText(p,s,100,110,.1,43);if(sub)urText(p,sub,100,165,.15,27,COL.dim);};
function urParcel(p,id,x,y){const g=G(p,{x,y});g.dataset.objectId=id;mk('rect',{x:-24,y:-21,width:48,height:42,rx:3,fill:mix(COL.board,COL.whole,.3),stroke:COL.whole,'stroke-width':3},g);path(g,'M-24 -7H24 M0 -21V-7',{stroke:COL.whole,'stroke-width':2});return g;}
function urDelivery(p,grouped=false){const parcels=Array.from({length:12},(_,i)=>urParcel(p,'parcel-'+i,grouped?550+i%4*100:350+i%6*100,grouped?290+Math.floor(i/4)*130:325+Math.floor(i/6)*100));const times=[0,1,2].map(i=>{const g=G(p,{x:1120,y:290+i*130});g.dataset.timeId='minute-'+i;mk('rect',{x:-100,y:-40,width:200,height:80,rx:10,fill:'none',stroke:COL.nat,'stroke-width':3},g);T(g,'1 minute',{y:11,size:30,fill:COL.nat,anchor:'middle'});return g;});return {parcels,times};}
function urRegroup(model,t){model.parcels.forEach((e,i)=>tw(e,{x:550+i%4*100,y:290+Math.floor(i/4)*130},t,2,io));}
function urDistance(p,id,x,y,n,w=180){const g=G(p,{x,y});g.dataset.distanceId=id;g.dataset.km=String(n/4);for(let i=0;i<n;i++)mk('rect',{x:i*w,y:0,width:w,height:70,fill:mix(COL.board,COL.whole,.3),stroke:COL.whole,'stroke-width':2},g);return g;}
function urSwim(p,x0=300){const cells=[0,1,2].map(i=>urDistance(p,'observed-'+i,x0+i*180,295,1));const time=G(p,{x:x0,y:460});mk('rect',{width:540,height:70,fill:mix(COL.board,COL.nat,.25),stroke:COL.nat,'stroke-width':3},time);T(time,'½ hour',{x:270,y:46,size:33,fill:COL.nat,anchor:'middle'});urText(p,'distance · each tile = ¼ km',x0,275,0,30,COL.whole);urText(p,'time',x0,440,0,30,COL.nat);return {cells,time};}
function urBottle(p,id,x,y){const g=G(p,{x,y});g.dataset.bottleId=id;path(g,'M-12 -44H12V-26L25 -10V40Q25 47 18 47H-18Q-25 47 -25 40V-10L-12 -26Z',{fill:mix(COL.board,COL.nat,.2),stroke:COL.nat,'stroke-width':3});path(g,'M-23 10H23',{stroke:COL.nat,'stroke-width':3});return g;}
function urMoney(p){const bottles=[0,1,2,3].map(i=>urBottle(p,'bottle-'+i,275+i*350,285));const dimes=Array.from({length:36},(_,i)=>{const g=G(p,{x:440+i%12*60,y:390+Math.floor(i/12)*60});g.dataset.dimeId='dime-'+i;g.dataset.cents='10';mk('circle',{r:18,fill:mix(COL.board,COL.whole,.35),stroke:COL.whole,'stroke-width':2},g);mk('circle',{r:14,fill:'none',stroke:COL.whole,'stroke-width':1},g);T(g,'10¢',{y:5,size:14,weight:600,fill:COL.chalk,anchor:'middle'});return g;});urText(p,'36 dime tiles · each = $0.10 · total = $3.60',800,625,0,32,COL.whole,'middle');return {bottles,dimes};}
function urPack(p,x,y,name,n,cost,t=0){const g=G(p,{x,y});urText(g,name,0,0,t,33,COL.chalk);const money=mk('rect',{x:0,y:40,width:cost*70,height:65,fill:mix(COL.board,COL.whole,.3),stroke:COL.whole,'stroke-width':2},g);const count=mk('rect',{x:0,y:165,width:n*70,height:65,fill:mix(COL.board,COL.nat,.25),stroke:COL.nat,'stroke-width':2},g);const costLab=urText(g,'$'+cost.toFixed(2)+' total',0,140,t,30,COL.whole),countLab=urText(g,n+' notebooks',0,265,t,30,COL.nat);return {g,money,count,n,cost,costLab,countLab};}
const BEATS=[
['intro','Unit Rate and Unit Price',(m,D)=>{const g=G(scene,{o:0,y:24});T(g,'Unit 2 · Ratios, Proportions, and Percents · Chapter 16',{x:800,y:200,size:28,fill:COL.dim,anchor:'middle'});T(g,'Unit Rate',{x:800,y:330,size:86,weight:600,anchor:'middle'});T(g,'and Unit Price',{x:800,y:435,size:86,weight:600,anchor:'middle'});T(g,'4 parcels / 1 minute',{x:800,y:580,size:52,fill:COL.task,anchor:'middle'});tw(g,{o:1,y:0},.2,1,out);urText(g,'Keep the units · compare per one',800,735,m('sub'),36,COL.dim,'middle');hide(g,D-.8,.7);}],
['rate','Different quantities, different units',m=>{const p=panel(0);urTitle(p,'Twelve parcels · three minutes');S.urDelivery=urDelivery(p);urText(p,'12 parcels',590,245,m('units'),35,COL.whole,'middle');urText(p,'3 minutes',1120,205,m('units'),35,COL.nat,'middle');urText(p,'parcels per minute',800,680,m('ordered'),48,COL.task,'middle');urText(p,'parcels ÷ minutes',800,790,m('ordered',2),38,COL.chalk,'middle');}],
['groups','Share the same work across time',m=>{const p=panel(0);urTitle(p,'Same twelve parcels · three equal groups');S.urDelivery=urDelivery(p);urRegroup(S.urDelivery,m('share'));[0,1,2].forEach(i=>urText(p,'4 parcels',350,300+i*130,m('each'),32,COL.whole,'middle'));urText(p,'12 parcels / 3 minutes = 4 parcels / 1 minute',800,755,m('rate'),37,COL.task,'middle');}],
['unit','Make the denominator one',m=>{const p=panel(0);urTitle(p,'Unit rate = rate per ONE');S.urDelivery=urDelivery(p,true);const focus=mk('rect',{x:480,y:225,width:760,height:125,rx:14,fill:'none',stroke:COL.task,'stroke-width':4},p);put(focus,{o:0});show(focus,m('one'));urMath(p,'12 ÷ 3 = 4',395,690,m('divide'),53,COL.whole);urMath(p,'3 ÷ 3 = 1',1130,690,m('divide',1),53,COL.nat);urText(p,'4 parcels per 1 minute',800,785,m('one'),47,COL.task,'middle');urText(p,'4 parcels per minute, on average',800,850,m('meaning'),29,COL.dim,'middle');}],
['direction','The question chooses the direction',m=>{const p=panel(0);urTitle(p,'Parcels per minute ↔ minutes per parcel');const a=G(p,{x:800,y:330}),b=G(p,{x:800,y:510});T(a,'12 parcels',{size:52,anchor:'middle',fill:COL.whole});T(b,'3 minutes',{size:52,anchor:'middle',fill:COL.nat});const rule=path(p,'M560 405H1040',{stroke:COL.chalk,'stroke-width':3});hide(rule,m('swap'),.2);show(rule,m('swap',2),.2);const first=urText(p,'12 ÷ 3 = 4 parcels/minute',800,710,m('forward'),44,COL.chalk,'middle');hide(first,m('swap'),.5);tw(a,{x:1000,y:420},m('swap'),1,io);tw(b,{x:600,y:420},m('swap'),1,io);tw(a,{x:800,y:510},m('swap',1),1,io);tw(b,{x:800,y:330},m('swap',1),1,io);urText(p,'3 ÷ 12 = ¼ minute/parcel',800,710,m('inverse'),44,COL.task,'middle');urText(p,'Same work · different question · different units',800,815,m('inverse',2),32,COL.dim,'middle');S.urSwap={a,b,rule};}],
['q1','Choose the per-minute picture',()=>{const p=panel(0);urTitle(p,'Four parcels per minute','Which picture puts FOUR parcels beside ONE minute?');S.urChoices=[[4,1],[1,4],[3,1]].map(([n,time],i)=>{const x=290+i*510,g=G(p);for(let j=0;j<n;j++)urParcel(g,'q1-'+i+'-'+j,x+(j-(n-1)/2)*62,315);mk('rect',{x:x-130,y:415,width:260,height:80,rx:12,fill:'none',stroke:COL.nat,'stroke-width':3},g);urText(g,time+(time===1?' minute':' minutes'),x,465,0,33,COL.nat,'middle');urText(g,n+(n===1?' parcel':' parcels'),x,250,0,32,COL.whole,'middle');return {el:g,box:[x-220,210,440,350],label:n+' parcels in '+time+' minutes'};});},{ask:done=>quiz(BAND,[{id:'c-per-minute',prompt:'Select the picture for 4 parcels per minute.',build:pickEls(S.urChoices,0,'Four parcels beside one minute. Units tell you the direction.',i=>i===1?'That is one parcel in four minutes, not four parcels per minute.':'That shows three parcels per minute; the requested count is four.')}],done)}],
['swim','Divide by fractional time',m=>{const p=panel(0);urTitle(p,'A swimmer: ¾ km in ½ hour');S.urSwim=urSwim(p);urText(p,'¾ km',880,347,m('distance'),48,COL.whole);urText(p,'½ hour',880,512,m('time'),48,COL.nat);urText(p,'¾ km',1270,418,m('question'),50,COL.whole,'middle');const fb=path(p,'M1160 440H1380',{stroke:COL.chalk,'stroke-width':4});put(fb,{o:0});show(fb,m('question'));urText(p,'½ hour',1270,495,m('question'),50,COL.nat,'middle');urText(p,'kilometres ÷ hours',1270,590,m('question'),32,COL.task,'middle');urText(p,'Wanted: kilometres per ONE hour',800,760,m('question',2),42,COL.task,'middle');}],
['reciprocal','How many half hours fit?',m=>{const p=panel(0);urTitle(p,'One hour contains TWO half hours','¾ km in ½ hour');S.urSwim=urSwim(p,260);const time2=G(p,{x:800,y:570,o:0});mk('rect',{width:540,height:70,fill:mix(COL.board,COL.nat,.25),stroke:COL.nat,'stroke-width':3},time2);T(time2,'½ hour',{x:270,y:46,size:33,fill:COL.nat,anchor:'middle'});show(time2,m('extend'),.5);tw(time2,{y:460},m('extend'),2,io);const copies=[0,1,2].map(i=>{const e=urDistance(p,'projected-'+i,800+i*180,395,1);put(e,{o:0});show(e,m('extend'),.5);tw(e,{y:295},m('extend'),2,io);return e;});urText(p,'first half hour',530,568,0,27,COL.dim,'middle');urText(p,'another half hour · same pace',1070,568,m('extend',2),27,COL.dim,'middle');const brace=path(p,'M262 590V604H1338V590 M800 604V614',{stroke:COL.nat,'stroke-width':3,fill:'none'});put(brace,{o:0});show(brace,m('extend',2));urText(p,'1 hour',800,650,m('extend',2),36,COL.nat,'middle');const eq=tokens(p,[[F(3,4)],' ÷ ',[F(1,2)],' = ',[F(3,4)],' × 2'],{x:810,y:752,size:72,anchor:'end',o:0});[0,0,0,1,1,1].forEach((k,i)=>show(eq[i],m(['divide','reciprocal'][k])));urText(p,'= 1.5 km/hour',830,752,m('answer'),58,COL.task);urText(p,'Distance and time both double; the pace stays the same.',800,850,m('answer',1),31,COL.dim,'middle');S.urSwim.copies=copies;S.urSwim.time2=time2;}],
['q2','Extend to one hour',()=>{const p=panel(0);urTitle(p,'¾ km in ½ hour · same pace for 1 hour','All distance strips use the same scale. Which is the one-hour distance?');S.urChoices=[[3,25,'⅜ km'],[3,50,'¾ km'],[6,50,'1½ km']].map(([n,w,label],i)=>{const x=290+i*510,g=G(p);for(let j=0;j<n;j++)mk('rect',{x:x-n*w/2+j*w,y:300,width:w,height:70,fill:mix(COL.board,COL.whole,.3),stroke:COL.whole,'stroke-width':2},g);urText(g,label,x,435,0,43,COL.whole,'middle');urText(g,'in 1 hour',x,525,0,31,COL.nat,'middle');g.dataset.km=String(n*w/200);return {el:g,box:[x-220,245,440,330],label:label+' in one hour'};});},{ask:done=>quiz(BAND,[{id:'c-half-hour',prompt:'Pick the distance for ONE hour at the same pace.',build:pickEls(S.urChoices,2,'One hour is two half hours: ¾ × 2 = 1½ kilometres.',i=>i===0?'That multiplies the distance by ½. Divide by ½ hour to get per hour.':'¾ kilometre is the half-hour distance. One whole hour gives twice as far.')}],done)}],
['average','A fractional rate; whole completed objects',m=>{const p=panel(0);urTitle(p,'Seven completed badges in two minutes','One possible steady schedule; every badge stays whole.');const badges=Array.from({length:7},(_,i)=>{const g=G(p,{x:350+i*125,y:310});g.dataset.badgeId='badge-'+i;g.dataset.completion=String(2*(i+1)/7);mk('circle',{r:25,fill:mix(COL.board,COL.whole,.3),stroke:COL.whole,'stroke-width':3},g);T(g,String(i+1),{y:9,size:25,anchor:'middle',fill:COL.whole});tw(g,{x:200+1000*(i+1)/7,y:420},m('timeline'),2,io);return g;});const axis=G(p,{o:0});path(axis,'M200 500H1200',{stroke:COL.nat,'stroke-width':3});[0,1,2].forEach(i=>{path(axis,`M${200+i*500} 488V512`,{stroke:COL.nat,'stroke-width':3});T(axis,i+' min',{x:200+i*500,y:555,size:30,fill:COL.nat,anchor:'middle'});});path(axis,'M700 365V500', {stroke:COL.task,'stroke-width':3,'stroke-dasharray':'8 8'});show(axis,m('timeline'));urText(p,'1 minute falls between badges 3 and 4',800,640,m('timeline',4.3),31,COL.task,'middle');urText(p,'7 ÷ 2 = 3.5 badges/minute on average',800,735,m('average'),42,COL.chalk,'middle');urText(p,'Total work ÷ total time · no badge is cut in half',800,835,m('whole'),32,COL.dim,'middle');S.urBadges=badges;}],
['price','Cost goes on top',m=>{const p=panel(0);urTitle(p,'Four bottles cost $3.60');[0,1,2,3].forEach(i=>urBottle(p,'price-'+i,370+i*180,350));urText(p,'$3.60 cost',1200,305,m('cost'),45,COL.whole,'middle');const bar=path(p,'M1010 370H1390',{stroke:COL.chalk,'stroke-width':3});put(bar,{o:0});show(bar,m('cost'));urText(p,'4 bottles',1200,450,m('items'),45,COL.nat,'middle');urText(p,'$3.60 ÷ 4 bottles',800,670,m('fraction'),50,COL.chalk,'middle');urText(p,'Wanted: dollars per bottle',800,805,m('fraction',2),38,COL.task,'middle');}],
['splitprice','Share the cost without changing the total',m=>{const p=panel(0);urTitle(p,'Thirty-six dimes shared among four bottles');S.urMoney=urMoney(p);S.urMoney.dimes.forEach((e,i)=>{const b=Math.floor(i/9),j=i%9;tw(e,{x:235+b*350+j%3*40,y:390+Math.floor(j/3)*55},m('share'),2,io);});[0,1,2,3].forEach(i=>urText(p,'9 dimes = $0.90',275+i*350,555,m('each'),29,COL.whole,'middle'));urText(p,'$3.60 ÷ 4 = $0.90 per bottle',800,755,m('price'),47,COL.task,'middle');urText(p,'Four equal costs still total $3.60',800,840,m('price',1),31,COL.dim,'middle');}],
['compare','Compare the cost of one matching item',m=>{const p=panel(0);urTitle(p,'Notebook packs A and B');S.urPacks=[urPack(p,230,270,'Pack A: 3 for $4.50',3,4.5),urPack(p,890,270,'Pack B: 5 for $7.00',5,7)];urText(p,'Identical notebooks · no extra charges',100,165,m('assumption'),27,COL.task);S.urPacks.forEach((a,i)=>{hide(a.costLab,m('normalize'),.4);hide(a.countLab,m('normalize'),.4);urText(a.g,'1 notebook',0,265,m('normalize',2),30,COL.nat);tw(a.money,{'a_width':a.cost/a.n*70},m('normalize'),2,io);tw(a.count,{'a_width':70},m('normalize'),2,io);const by=urText(p,'÷ '+a.n+' for both bars',465+i*660,620,m('normalize'),30,COL.task,'middle');hide(by,m('normalize',2),.4);urText(p,'$'+(a.cost/a.n).toFixed(2)+' / 1 notebook',465+i*660,630,m('normalize',[6.9,9.7][i]),40,COL.chalk,'middle');});urText(p,'Pack B: $0.10 less per notebook',800,765,m('compare'),42,COL.task,'middle');urText(p,'Higher total cost can still mean lower unit price.',800,845,m('compare',1),30,COL.dim,'middle');}],
['q3','Choose the lower unit price',()=>{const p=panel(0);urTitle(p,'Same markers · no extra charges','Compare dollars per marker, not total cost alone.');S.urChoices=[[4,2.8],[6,3.9]].map(([n,c],i)=>{const x=450+i*700,g=G(p);for(let j=0;j<n;j++)mk('rect',{x:x+(j-(n-1)/2)*48-10,y:270,width:20,height:100,rx:5,fill:mix(COL.board,COL.nat,.3),stroke:COL.nat,'stroke-width':2},g);urText(g,'Pack '+['A','B'][i]+': '+n+' markers',x,225,0,36,COL.nat,'middle');urText(g,'$'+c.toFixed(2)+' total',x,440,0,36,COL.whole,'middle');g.dataset.count=String(n);g.dataset.cost=String(c);return {el:g,box:[x-290,190,580,410],label:'Pack '+['A','B'][i]+', '+n+' markers for $'+c.toFixed(2)};});},{ask:done=>quiz(BAND,[{id:'c-unit-price',prompt:'Pick the pack with the LOWER price per marker.',build:pickEls(S.urChoices,1,'Pack B: $3.90 ÷ 6 = $0.65 per marker, lower than $0.70.',()=> 'Pack A costs less in total, but each marker costs $0.70. Pack B is $0.65 per marker.')}],done)}],
['trap','Let the units catch a reversed division',m=>{const p=panel(0);urTitle(p,'Unit price asks COST per ITEM');urText(p,'4 bottles ÷ $3.60',800,320,m('flip'),51,COL.chalk,'middle');urText(p,'gives bottles per dollar',800,405,m('flip'),33,COL.dim,'middle');const cross=path(p,'M480 275L1120 345 M480 345L1120 275',{stroke:COL.bad,'stroke-width':4},{d:0});draw(cross,m('flip',2),.8);urText(p,'$3.60 ÷ 4 bottles = $0.90 per bottle',800,555,m('correct'),44,COL.task,'middle');urText(p,'Compare matching units AND identical products.',800,720,m('compare'),37,COL.chalk,'middle');urText(p,'A pack is not automatically one bottle.',800,815,m('compare',1),32,COL.dim,'middle');}],
['wrap','Per one, with meaning',m=>{const p=panel(0);urTitle(p,'Four habits for rates and prices');[['Name the direction; keep both units.','w1'],['Divide first quantity by second; make denominator 1.','w2'],['Fractional time still means divide by time.','w3'],['Price = cost/item; fractional counts can describe averages.','w4']].forEach(([s,key],i)=>{const g=G(p,{x:-16,y:285+i*145,o:0});mk('circle',{cx:130,cy:-10,r:26,fill:COL.task},g);T(g,String(i+1),{x:130,y:0,size:30,anchor:'middle',fill:COL.board});T(g,s,{x:195,size:32});tw(g,{x:0,o:1},m(key),.6);});}],
['final1','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-rates',prompt:'Find the unit rate in the units shown. Exact fractions or decimals are accepted.',build:blanks([
{parts:['45 km in 3 hours: ',{box:'15'},' km/hour'],why:'45 ÷ 3 = 15 kilometres per hour.'},
{parts:['⅔ km in ⅙ hour: ',{box:'4'},' km/hour'],why:'(2/3) ÷ (1/6) = (2/3) × 6 = 4 kilometres per hour.'},
{parts:['9 signs in 4 hours: ',{box:'2.25'},' signs/hour on average'],why:'9 ÷ 4 = 2.25 completed signs per hour on average; each sign stays whole.'},
{parts:['8 minutes for 4 parcels: ',{box:'2'},' minutes/parcel'],why:'Time per parcel: 8 minutes ÷ 4 parcels = 2 minutes per parcel.'}
])}],done,'Chapter practice · set 1 of 3')}],
['final2','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[{id:'p-prices',prompt:'Calculate cost per item. The $ and units are already supplied.',build:blanks([
{parts:['$5.40 for 6 folders: $',{box:'0.90'},' per folder'],why:'5.40 ÷ 6 = 0.90 dollars per folder.'},
{parts:['$8.75 for 5 rolls: $',{box:'1.75'},' per roll'],why:'8.75 ÷ 5 = 1.75 dollars per roll.'},
{parts:['$6.30 for 9 cards: $',{box:'0.70'},' per card'],why:'6.30 ÷ 9 = 0.70 dollars per card.'}
])}],done,'Chapter practice · set 2 of 3')}],
['final3','Chapter practice',()=>panel(0),{ask:done=>quiz(SCREEN,[
{id:'p-compare',prompt:'Identical pencils, no extra charges: A has 8 for $3.20; B has 10 for $4.50. Which has the lower cost per pencil?',build:choice(['Pack A','Pack B','Same unit price'],0,'A: $3.20 ÷ 8 = $0.40 per pencil, less than B at $0.45.',['','More pencils does not guarantee a lower unit price. Compare $0.40 with $0.45.','The unit prices differ: $0.40 and $0.45.'])},
{id:'p-average',prompt:'A potter finishes 5 whole pots in 2 hours. What does 2.5 pots/hour mean?',build:choice(['Every hour must end with half a pot completed','An average: 5 completed pots divided by 2 hours','The potter completed only 2 whole pots'],1,'An average of 2.5 pots/hour summarizes five whole completed pots in two hours.',['The average is total completed pots divided by total time; no completed pot is cut in half.','','There were five completed pots, not two.'])}
],done,'Chapter practice · set 3 of 3')}],
['finish','Finished',()=>panel(0),{ask:finishCard}]
].map(([id,title,run,extra])=>({id,title,run,...extra}));
boot();
</script></body></html>