Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added arithmetic word problems.

  • Loading branch information...
commit 8674af0df8d4293c139573eb156eefcd1d1c3225 1 parent 6edcccd
@bradleyt bradleyt authored
View
64 exercises/arithmetic_word_problems.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html data-require="math word-problems">
+<head>
+ <title>Arithmetic word problems</title>
+ <script src="../khan-exercise.js"></script>
+</head>
+<body>
+ <div class="exercise">
+ <div class="vars">
+ <var id="ITEMS_PER_GROUP">randRange( 3, 12 )</var>
+ <var id="ITEMS_LEFT">randRange( 1, ITEMS_PER_GROUP - 1 )</var>
+ <var data-prevent="getFactors( ITEMS_PER_GROUP * GROUPS + ITEMS_LEFT ).length < 3"
+ 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_GROUPS">TOTAL_ITEMS / NEW_ITEMS_PER_GROUP</var>
+
+ </div>
+
+ <div class="problems">
+ <div>
+ <p class="question">
+ <var>person(1)</var> is putting <var>itemPlural(1)</var> into
+ <var>groupPlural(1)</var>.
+ If <var>he(1)</var> puts
+ <var>plural( ITEMS_PER_GROUP, item(1), itemPlural(1) )</var>
+ in each <var>group(1)</var> <var>he(1)</var> will <var>groupVerb(1)</var>
+ <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>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>
+ </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>
+
+ <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>
+ <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>
+ </div>
+</body>
+</html>
View
6 utils/math.js
@@ -143,6 +143,12 @@ jQuery.extend(KhanUtil, {
return a - b;
});
},
+
+ // Get a random factor of a composite number which is not 1 or that number
+ getRandomFactor: function( number ) {
+ var factors = this.getFactors( number );
+ return factors[ this.randRange( 1, factors.length - 2 ) ];
+ },
getMultiples: function( number, upperLimit ) {
var multiples = [];
View
28 utils/word-problems.js
@@ -92,6 +92,14 @@ jQuery.fn[ "word-problemsLoad" ] = function() {
"\\triangleright"
]);
+ var collections = KhanUtil.shuffle([
+ ["chair", "chairs", "row", "rows", "make"],
+ ["party favor", "party favors", "bag", "bags", "fill"],
+ ["jelly bean", "jelly beans", "pile", "piles", "make"],
+ ["book", "books", "shelf", "shelves", "fill"],
+ ["can of food", "cans of food", "box", "boxes", "fill"]
+ ]);
+
jQuery.extend( KhanUtil, {
person: function( i ) {
return people[i - 1][0];
@@ -143,6 +151,26 @@ jQuery.fn[ "word-problemsLoad" ] = function() {
binop: function( i ) {
return binops[i - 1];
+ },
+
+ item: function( i ) {
+ return collections[i - 1][0];
+ },
+
+ itemPlural: function( i ) {
+ return collections[i - 1][1];
+ },
+
+ group: function( i ) {
+ return collections[i - 1][2];
+ },
+
+ groupPlural: function( i ) {
+ return collections[1 - 1][3];
+ },
+
+ groupVerb: function( i ) {
+ return collections[i - 1][4];
}
});
};
Please sign in to comment.
Something went wrong with that request. Please try again.