Permalink
Browse files

refactors for D797

  • Loading branch information...
1 parent 69bc78b commit 0c7b1bc3aa2b5cd5bd36bbe19f24c9699b4a0ae2 Stephanie H. Chang committed Oct 4, 2012
Showing with 33 additions and 72 deletions.
  1. +11 −7 exercises/matrix_addition_subtraction.html
  2. +22 −65 exercises/scalar_matrix_multiplication.html
@@ -22,6 +22,7 @@
<var id="MAT_A">randRange(-2, 4, ROWS, COLS)</var>
<var id="MAT_B">randRange(-2, 4, ROWS, COLS)</var>
<var id="OPERATION">randFromArray(["+", "-"])</var>
+
<var id="SOLN_MAT">
deepZipWith(2, function(a, b) {
if (OPERATION === "+") {
@@ -31,17 +32,22 @@
}
}, MAT_A, MAT_B)
</var>
+
+ <var id="MAT_A_COLOR">BLUE</var>
+ <var id="MAT_B_COLOR">GREEN</var>
+ <var id="SOLN_MAT_COLOR">PINK</var>
+
<var id="PRETTY_MAT_A">
- printMatrix(MAT_A, BLUE)
+ printMatrix(MAT_A, MAT_A_COLOR)
</var>
<var id="PRETTY_MAT_B">
- printMatrix(MAT_B, GREEN)
+ printMatrix(MAT_B, MAT_B_COLOR)
</var>
<var id="PRETTY_HINT_MAT">
- printMatrix(MAT_A, BLUE, MAT_B, GREEN, OPERATION)
+ printMatrix(MAT_A, MAT_A_COLOR, MAT_B, MAT_B_COLOR, OPERATION)
</var>
<var id="PRETTY_SOLN_MAT">
- printMatrix(SOLN_MAT, PINK)
+ printMatrix(SOLN_MAT, SOLN_MAT_COLOR)
</var>
</div>
@@ -64,9 +70,7 @@
the corresponding items between each matrix.
</p>
<div>
- <p>
- <code>\Large{<var>PRETTY_HINT_MAT</var>}</code>
- </p>
+ <code>\Large{<var>PRETTY_HINT_MAT</var>}</code>
</div>
</div>
<div>
@@ -18,7 +18,7 @@
<div class="exercise">
<div class="vars">
- <var id="MAT_A">randRange(-5, 10, ROWS, COLS)</var>
+ <var id="MAT_A">randRange(-2, 4, ROWS, COLS)</var>
<var id="SCALAR">randRange(-5, 5)</var>
<var id="OPERATION">"*"</var>
<var id="SOLN_MAT">
@@ -27,15 +27,16 @@
}, MAT_A)
</var>
- <var id="MAT_A_COLOR">KhanUtil.BLUE</var>
- <var id="SCALAR_COLOR">KhanUtil.GREEN</var>
- <var id="SOLN_MAT_COLOR">KhanUtil.RED</var>
<var id="SCALAR_MAT">
deepZipWith(2, function(a) {
return SCALAR;
}, MAT_A)
</var>
+ <var id="MAT_A_COLOR">BLUE</var>
+ <var id="SCALAR_COLOR">GREEN</var>
+ <var id="SOLN_MAT_COLOR">PINK</var>
+
<var id="PRETTY_MAT_A">
printMatrix(MAT_A, MAT_A_COLOR)
</var>
@@ -48,26 +49,20 @@
</div>
<div class="question">
- <div class="graphie">
- init({
- range: [ [0, 12], [-1, 1] ]
- });
-
- var color = "\\color{" + SCALAR_COLOR + "}{" + SCALAR + "}";
-
- label( [0, 0],
- "\\Large{" + color + OPERATION + PRETTY_MAT_A + " = {?}}",
- "right" );
- </div>
+ <code>
+ \Large{
+ \color{<var>SCALAR_COLOR</var>}{<var>SCALAR</var>}
+ <var>OPERATION</var>
+ <var>PRETTY_MAT_A</var> = {?}
+ }
+ </code>
</div>
<div class="hints">
<div>
<p>To multiply a matrix by a number, multiply each item of the matrix by the number.</p>
<div>
- <p>
- <code>\Large{<var>PRETTY_HINT_MAT</var>}</code>
- </p>
+ <code>\Large{<var>PRETTY_HINT_MAT</var>}</code>
</div>
</div>
<div>
@@ -78,82 +73,44 @@
</div>
</div>
+ <div class="solution" data-type="multiple">
+ <p data-each="SOLN_MAT as row" class="row">
+ <span data-each="row as elem" class="sol">
+ <var>elem</var>
+ </span>
+ </p>
+ </div>
+
<div class="problems">
<div id="2x2">
<div class="vars" data-apply="prependVars">
<var id="ROWS">2</var>
<var id="COLS">2</var>
</div>
- <div class="solution" data-type="multiple">
- <p class="row">
- <span class="sol"><var>SOLN_MAT[0][0]</var></span>
- <span class="sol"><var>SOLN_MAT[0][1]</var></span>
- </p>
- <p class="row">
- <span class="sol"><var>SOLN_MAT[1][0]</var></span>
- <span class="sol"><var>SOLN_MAT[1][1]</var></span>
- </p>
- </div>
</div>
<div id="2x3">
<div class="vars" data-apply="prependVars">
<var id="ROWS">2</var>
<var id="COLS">3</var>
</div>
- <div class="solution" data-type="multiple">
- <p class="row">
- <span class="sol"><var>SOLN_MAT[0][0]</var></span>
- <span class="sol"><var>SOLN_MAT[0][1]</var></span>
- <span class="sol"><var>SOLN_MAT[0][2]</var></span>
- </p>
- <p class="row">
- <span class="sol"><var>SOLN_MAT[1][0]</var></span>
- <span class="sol"><var>SOLN_MAT[1][1]</var></span>
- <span class="sol"><var>SOLN_MAT[1][2]</var></span>
- </p>
- </div>
</div>
<div id="3x1">
<div class="vars" data-apply="prependVars">
<var id="ROWS">3</var>
<var id="COLS">1</var>
</div>
- <div class="solution" data-type="multiple">
- <p class="row">
- <span class="sol"><var>SOLN_MAT[0][0]</var></span>
- </p>
- <p class="row">
- <span class="sol"><var>SOLN_MAT[1][0]</var></span>
- </p>
- <p class="row">
- <span class="sol"><var>SOLN_MAT[2][0]</var></span>
- </p>
- </div>
</div>
<div id="3x2">
<div class="vars" data-apply="prependVars">
<var id="ROWS">3</var>
<var id="COLS">2</var>
</div>
- <div class="solution" data-type="multiple">
- <p class="row">
- <span class="sol"><var>SOLN_MAT[0][0]</var></span>
- <span class="sol"><var>SOLN_MAT[0][1]</var></span>
- </p>
- <p class="row">
- <span class="sol"><var>SOLN_MAT[1][0]</var></span>
- <span class="sol"><var>SOLN_MAT[1][1]</var></span>
- </p>
- <p class="row">
- <span class="sol"><var>SOLN_MAT[2][0]</var></span>
- <span class="sol"><var>SOLN_MAT[2][1]</var></span>
- </p>
- </div>
</div>
</div>
+
</div>
</body>
</html>

0 comments on commit 0c7b1bc

Please sign in to comment.