# Khan/khan-exercises

Port fractions cut and copy 1 to use a custom answer type

1 parent bb4a8a2 commit 4d6fd619272f476d684814053c321223f7cd2afd joelburget committed Aug 23, 2012
Showing with 48 additions and 32 deletions.
1. +48 −32 exercises/fractions_cut_and_copy_1.html
80 exercises/fractions_cut_and_copy_1.html
 @@ -9,20 +9,20 @@
- randRangeWeighted( 3, 12, 1, 1 / 6 ) - D_PARENT === 1 ? randRange( 3, 12 ) : ( rand( 5 ) > 0 ? D_PARENT : 1 ) + randRangeWeighted(3, 12, 1, 1 / 6) + D_PARENT === 1 ? randRange(3, 12) : (rand(5) > 0 ? D_PARENT : 1)
- D_PARENT === 1 ? randRange( 1, 4 ) : randRangeExclude( 2, 2 * D_PARENT - 1, [ D_PARENT ] ) - D_OFFSPRING === 1 ? randRange( 1, 4 ) : randRangeExclude( 2, 2 * D_OFFSPRING - 1, [ D_OFFSPRING ] ) + D_PARENT === 1 ? randRange(1, 4) : randRangeExclude(2, 2 * D_PARENT - 1, [D_PARENT]) + D_OFFSPRING === 1 ? randRange(1, 4) : randRangeExclude(2, 2 * D_OFFSPRING - 1, [D_OFFSPRING])
- D_PARENT === 1 ? N_PARENT : mixedOrImproper( N_PARENT, D_PARENT ) - D_OFFSPRING === 1 ? N_OFFSPRING : mixedOrImproper( N_OFFSPRING, D_OFFSPRING ) + D_PARENT === 1 ? N_PARENT : mixedOrImproper(N_PARENT, D_PARENT) + D_OFFSPRING === 1 ? N_OFFSPRING : mixedOrImproper(N_OFFSPRING, D_OFFSPRING) N_PARENT / D_PARENT N_OFFSPRING / D_OFFSPRING OFFSPRING / PARENT D_PARENT === 1 ? D_OFFSPRING : D_PARENT - N_PARENT * ( D_PARENT === 1 ? D : 1 ) - N_OFFSPRING * ( D_OFFSPRING === 1 ? D : 1 ) + N_PARENT * (D_PARENT === 1 ? D : 1) + N_OFFSPRING * (D_OFFSPRING === 1 ? D : 1)
@@ -32,48 +32,64 @@

Starting Block:

- initSliceClone([ "current_block" ]); - init({ range: [ [ 0, 1 ], [ 0, 1 ] ],scale: [ 600, 25 ] }); - rectchart( [ 1, 0 ], [ "#e00", "#999" ] ); + initSliceClone(["current_block"]); + init({range: [[0, 1], [0, 1]], scale: [600, 25 ]}); + rectchart([1, 0], ["#e00", "#999"]);

Current Block:

- init({ range: [ [ 0, 1 ], [ 0, 1 ] ],scale: [ 600, 25 ] }); - rectchart( [ 1, 0 ], [ "#e00", "#999" ] ); + init({ range: [[0, 1], [0, 1] ], scale: [600, 25]}); + rectchart([1, 0], ["#e00", "#999"]);

Goal Block:

- init({ range: [ [ 0, 1 ], [ 0, 1 ] ],scale: [ 600 * ANSWER, 25 ] }); - rectchart( [ 1, 0 ], [ BLUE, "#999" ] ); + init({range: [[0, 1], [0, 1]], scale: [600 * ANSWER, 25]}); + rectchart([1, 0], [BLUE, "#999"]);
-
-
- Cut into - - 1 piece - -
+
+
+
+ Cut into + + 1 piece + +
-
- Copy - - 1 time - +
+ Copy + + 1 time + +
- +
+ [pieces, times['current_block']] +
+
+ return roundTo(3, guess[1] / guess[0]) === roundTo(3, ANSWER); +
+
+ pieces = guess[0]; + times['current_block'] = guess[1]; + updateGraphAndAnswer(); +
+
+ \$('#pieces').text(plural(guess[0], 'piece')); + \$(current_block_times).text(plural(guess[1], 'time')); +
-

The starting block of length CODE_PARENT units - can be rewritten as fraction( N_PARENT_EXPANDED, D ).

-

The goal block of length CODE_OFFSPRING units - can be rewritten as fraction( N_OFFSPRING_EXPANDED, D ).

+

The starting block of length CODE_PARENT units + can be rewritten as fraction(N_PARENT_EXPANDED, D).

+

The goal block of length CODE_OFFSPRING units + can be rewritten as fraction(N_OFFSPRING_EXPANDED, D).

Cutting the starting block into x pieces is the same as dividing it by x.

Therefore cutting the starting block into N_PARENT_EXPANDED pieces is the same as: