From 236a155cfb93e9a80c54df47fd9bf58d072c1c0a Mon Sep 17 00:00:00 2001 From: "Stephanie H. Chang" Date: Fri, 11 Nov 2011 11:07:43 -0800 Subject: [PATCH] added problem type with 0/undefined slope; refactored out embedded JS --- exercises/slope_of_a_line.html | 82 +++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/exercises/slope_of_a_line.html b/exercises/slope_of_a_line.html index f088531ff..12655ac45 100644 --- a/exercises/slope_of_a_line.html +++ b/exercises/slope_of_a_line.html @@ -11,30 +11,11 @@ padding-right: 20px; } -
-
+
randRange(-9, 9) randRange(-9, 9) @@ -132,13 +113,25 @@

So, the slope m is fractionReduce( Y2 - Y1, X2 - X1 ).

-
+
+ [ + { name: "Blue", hex: KhanUtil.BLUE }, + { name: "Orange", hex: KhanUtil.ORANGE }, + { name: "Green", hex: KhanUtil.GREEN }, + { name: "Pink", hex: KhanUtil.PINK } + ] randRange( 2, 5 ) - randRange( -3, 3 ) - randRange( 0, 3 ) + [ + { value: M_INIT, display: M_INIT }, + { value: -1 * M_INIT, display: "-" + M_INIT }, + { value: 1 / M_INIT, display: "\\dfrac{1}{" + M_INIT + "}" }, + { value: -1 / M_INIT, display: "-\\dfrac{1}{" + M_INIT + "}" } + ] + randRange( -3, 3 ) + randRange( 0, 3 ) [ 0, 1, 2, 3 ] - getSlope( WHICH, M_INIT ) + SLOPES[WHICH]

Which graph best depicts a slope of M.display?

@@ -152,18 +145,22 @@ axisArrows: "<->" }); - style({ stroke: getColor( index ).hex }); + style({ stroke: COLORS[index].hex }); plot(function( x ) { - return x * getSlope( index, M_INIT ).value + B; + return x * SLOPES[index].value + B; }, [ -11, 11 ]);
-
\quad \color{getColor( WHICH ).hex}{\text{getColor( WHICH ).name}}
+
\quad \color{COLORS[WHICH].hex}{\text{COLORS[WHICH].name}}
    -
  1. \quad \color{getColor( index ).hex}{\text{getColor( index ).name}}
  2. +
  3. \quad \color{COLORS[index].hex}{\text{COLORS[index].name}}

Remember that the slope corresponds to which direction the line slants, and how much it slants.

+
+

Because the slope is M.display, the line should not slant at all.

+

The answer is either the \text{orange} or \text{pink} graph.

+

Because M.display is negative, the line should slant downwards as we follow it to the right.

The answer is either the \text{orange} or \text{pink} graph.

@@ -173,10 +170,35 @@

The answer is either the \text{blue} or \text{green} graph.

In which graph does the y value change by M.display if the x value changes by 1?

-

The \color{getColor( WHICH ).hex}{\text{getColor( WHICH ).name.toLowerCase()}} graph best depicts a slope of M.display.

+

The \color{COLORS[WHICH].hex}{\text{COLORS[WHICH].name.toLowerCase()}} graph best depicts a slope of M.display.

+
+
+
+
+ [ + { value: M_INIT, display: M_INIT }, + { value: 0, display: 0 }, + { value: Number.POSITIVE_INFINITY, display: "\\infty" }, + { value: 1 / M_INIT, display: "\\dfrac{1}{" + M_INIT + "}" } + ] + randRange( 1, 2 ) + SLOPES[WHICH] +
+
+

Remember that the slope corresponds to how steep the line is. +

Imagine walking up a hill represented by a line. A larger slope means a steeper hill.

+
+

Because the slope is M.display, the hill should not be steep.

+

The answer is either the \text{orange} or \text{pink} graph.

+
+
+

Because the slope is M.display, the hill should be extremely steep.

+

The answer is either the \text{blue} or \text{green} graph.

+
+

The \color{COLORS[WHICH].hex}{\text{COLORS[WHICH].name.toLowerCase()}} graph best depicts a slope of M.display.

- + \ No newline at end of file