Permalink
Browse files

Added second arithmetic word problem type.

  • Loading branch information...
1 parent 8280b02 commit e381f26d0cd7758ac4cf8063c0c0bed4e53a514f @bradleyt bradleyt committed May 26, 2011
Showing with 126 additions and 23 deletions.
  1. +64 −22 exercises/arithmetic_word_problems.html
  2. +1 −1 utils/math.js
  3. +61 −0 utils/word-problems.js
@@ -7,20 +7,27 @@
<body>
<div class="exercise">
<div class="vars">
+ <!-- vars for type 1 -->
<var id="ITEMS_PER_GROUP">randRange( 3, 12 )</var>
<var id="ITEMS_LEFT">randRange( 1, ITEMS_PER_GROUP - 1 )</var>
<var data-ensure="getFactors( ITEMS_PER_GROUP * GROUPS + ITEMS_LEFT ).length > 2"
id="GROUPS">randRange( 2, 12 )</var>
<var id="ITEMS_IN_GROUPS">GROUPS * ITEMS_PER_GROUP</var>
<var id="TOTAL_ITEMS">ITEMS_IN_GROUPS + ITEMS_LEFT</var>
- <var id="NEW_ITEMS_PER_GROUP">getRandomFactor( TOTAL_ITEMS )</var>
+ <var id="NEW_ITEMS_PER_GROUP">getNontrivialFactor( TOTAL_ITEMS )</var>
<var id="NEW_GROUPS">TOTAL_ITEMS / NEW_ITEMS_PER_GROUP</var>
+ <!-- vars for type 2 -->
+ <var id="ITEM_1_COUNT">randRange( 4, 12 )</var>
+ <var id="ITEM_1_COST">randRange( 4, 12 )</var>
+ <var id="ITEM_2_COST">randRange( 4, 12 )</var>
+ <var id="TOTAL_SPENT_ON_1">ITEM_1_COUNT * ITEM_1_COST</var>
+ <var id="TOTAL_SPENT">TOTAL_SPENT_ON_1 + ITEM_2_COST</var>
</div>
<div class="problems">
- <div>
+ <div id="type-1">
<p class="question">
<var>person(1)</var> is putting <var>itemPlural(1)</var> into
<var>groupPlural(1)</var>.
@@ -30,34 +37,69 @@
<var>plural( GROUPS, group(1), groupPlural(1) )</var> and have
<var>plural( ITEMS_LEFT, item(1), itemPlural(1) )</var> left over.
If <var>he(1)</var> instead puts
- <var>NEW_ITEMS_PER_GROUP</var> <var>itemPlural(1)</var> in each
+ <var>plural( NEW_ITEMS_PER_GROUP, item(1), itemPlural(1) )</var> in each
<var>group(1)</var>, how many <var>groupPlural(1)</var> of
<var>itemPlural(1)</var> can <var>he(1)</var> <var>groupVerb(1)</var>?
</p>
+
<p class="solution"><var>NEW_GROUPS</var></p>
+
+ <div class="hints">
+ <p class="hint1">
+ <var>plural( GROUPS, group(1), groupPlural(1) )</var> of
+ <var>plural( ITEMS_PER_GROUP, item(1), itemPlural(1) )</var> each results in
+ <code><var>GROUPS</var> \times <var>ITEMS_PER_GROUP</var> = <var>ITEMS_IN_GROUPS</var></code>
+ <var>itemPlural(1)</var>.
+ </p>
+
+ <p class="hint2">
+ <var>plural( ITEMS_IN_GROUPS, item(1), itemPlural(1) )</var> plus
+ <var>ITEMS_LEFT</var> left over equals
+ <var>TOTAL_ITEMS</var> total <var>itemPlural(1)</var>.
+ </p>
+
+ <p class="hint3">
+ <var>plural( TOTAL_ITEMS, item(1), itemPlural(1) )</var>
+ divided into groups of <var>NEW_ITEMS_PER_GROUP</var> is
+ <code><var>TOTAL_ITEMS</var> \div <var>NEW_ITEMS_PER_GROUP</var> = <var>NEW_GROUPS</var></code>
+ <var>groupPlural(1)</var>.
+ </p>
+ </div>
</div>
- </div>
- <div class="hints">
- <p>
- <var>plural( GROUPS, group(1), groupPlural(1) )</var> of
- <var>plural( ITEMS_PER_GROUP, item(1), itemPlural(1) )</var> each results in
- <code><var>GROUPS</var> \times <var>ITEMS_PER_GROUP</var> = <var>ITEMS_IN_GROUPS</var></code>
- <var>itemPlural(1)</var>.
- </p>
+ <div id="type-2">
+ <p class="question">
+ <var>person(1)</var> bought <var>plural(ITEM_1_COUNT, storeItem(1, 1), storeItemPlural(1, 1))</var>,
+ all costing the same amount, from the <var>store(1)</var> store. <var>He(1)</var> also bought a
+ <var>storeItem(1, 2)</var> for <var>plural(ITEM_2_COST, "dollar")</var>. <var>He(1)</var> spent a total of
+ <var>plural(TOTAL_SPENT, "dollar")</var>. How much did each <var>storeItem(1, 1)</var> cost?
+ </p>
- <p>
- <var>plural( ITEMS_IN_GROUPS, item(1), itemPlural(1) )</var> plus
- <var>ITEMS_LEFT</var> left over equals
- <var>TOTAL_ITEMS</var> total <var>itemPlural(1)</var>.
- </p>
+ <p class="solution"><var>ITEM_1_COST</var></p>
- <p>
- <var>plural( TOTAL_ITEMS, item(1), itemPlural(1) )</var>
- divided into groups of <var>NEW_ITEMS_PER_GROUP</var> is
- <code><var>TOTAL_ITEMS</var> \div <var>NEW_ITEMS_PER_GROUP</var> = <var>NEW_GROUPS</var></code>
- <var>groupPlural(1)</var>.
-
+ <div class="hints">
+ <p class="hint1">
+ Of the <var>plural(TOTAL_SPENT, "dollar")</var>, <var>he(1)</var> spent
+ <var>plural(ITEM_2_COST, "dollar")</var> on a <var>storeItem(1, 2)</var>, so <var>he(1)</var> must have spent
+ a total of <code><var>TOTAL_SPENT</var> - <var>ITEM_2_COST</var> = <var>TOTAL_SPENT_ON_1</var></code>
+ dollars on <var>storeItemPlural(1, 1)</var>.
+ </p>
+
+ <p class="hint2">
+ <var>He(1)</var> spent <var>plural(TOTAL_SPENT_ON_1, "dollar")</var> on
+ <var>plural(ITEM_1_COUNT, storeItem(1, 1), storeItemPlural(1, 1))</var>,
+ so he must have spent
+ <code><var>TOTAL_SPENT_ON_1</var> \div <var>ITEM_1_COUNT</var> = <var>ITEM_1_COST</var></code>
+ dollars on each <var>storeItem(1, 1)</var>.
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div class="hints">
+ <p class="hint1"></p>
+ <p class="hint2"></p>
+ <p class="hint3"></p>
</div>
</div>
</body>
View
@@ -145,7 +145,7 @@ jQuery.extend(KhanUtil, {
},
// Get a random factor of a composite number which is not 1 or that number
- getRandomFactor: function( number ) {
+ getNontrivialFactor: function( number ) {
var factors = this.getFactors( number );
return factors[ this.randRange( 1, factors.length - 2 ) ];
},
View
@@ -100,6 +100,51 @@ jQuery.fn[ "word-problemsLoad" ] = function() {
["can of food", "cans of food", "box", "boxes", "fill"]
]);
+ var stores = KhanUtil.shuffle([
+ {
+ name: "office supply",
+ items: KhanUtil.shuffle([
+ ["pen", "pens"],
+ ["pencil", "pencils"],
+ ["notebook", "notebooks"]
+ ])
+ },
+ {
+ name: "hardware",
+ items: KhanUtil.shuffle([
+ ["hammer", "hammers"],
+ ["nail", "nails"],
+ ["saw", "saws"]
+ ])
+ },
+ {
+ name: "grocery",
+ items: KhanUtil.shuffle([
+ ["banana", "bananas"],
+ ["loaf of bread", "loaves of bread"],
+ ["gallon of milk", "gallons of milk"],
+ ["potato", "potatoes"]
+ ])
+ },
+ {
+ name: "gift",
+ items: KhanUtil.shuffle([
+ ["toy", "toys"],
+ ["game", "games"],
+ ["souvenir", "souvenirs"]
+ ])
+ },
+ {
+ name: "toy",
+ items: KhanUtil.shuffle([
+ ["stuffed animal", "stuffed animals"],
+ ["video game", "video games"],
+ ["race car", "race cars"],
+ ["doll", "dolls"]
+ ])
+ }
+ ]);
+
jQuery.extend( KhanUtil, {
person: function( i ) {
return people[i - 1][0];
@@ -121,6 +166,10 @@ jQuery.fn[ "word-problemsLoad" ] = function() {
return people[i - 1][1] == "m" ? "him" : "her";
},
+ Him: function( i ) {
+ return people[i - 1][1] == "m" ? "Him" : "Her";
+ },
+
his: function( i ) {
return people[i - 1][1] == "m" ? "his" : "her";
},
@@ -171,6 +220,18 @@ jQuery.fn[ "word-problemsLoad" ] = function() {
groupVerb: function( i ) {
return collections[i - 1][4];
+ },
+
+ store: function( i ) {
+ return stores[i].name;
+ },
+
+ storeItem: function( i, j ) {
+ return stores[i].items[j][0];
+ },
+
+ storeItemPlural: function( i, j ) {
+ return stores[i].items[j][1];
}
});
};

0 comments on commit e381f26

Please sign in to comment.