Skip to content
Newer
Older
100644 495 lines (470 sloc) 20.4 KB
62b80f8 @marcia Add exercise -- line graph intuition
marcia authored Jun 23, 2011
1 <!DOCTYPE html>
7041f1b @jeresig Re-run the linter on the exercises.
jeresig authored Apr 23, 2013
2 <html data-require="math math-format expressions graphie graphie-helpers interactive word-problems">
3 <head>
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4e4cb9b @beneater lint: tabs->spaces and jQuery->$ for exercises
beneater authored Apr 10, 2012
5 <title>Line graph intuition</title>
ac1415e @spicyj Use requirejs for module loading
spicyj authored Mar 5, 2014
6 <script data-main="../local-only/main.js" src="../local-only/require.js"></script>
62b80f8 @marcia Add exercise -- line graph intuition
marcia authored Jun 24, 2011
7 </head>
8 <body>
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
9 <div class="exercise">
10 <div class="problems">
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
11 <div id="graph-slope" data-weight="1">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
12 <div class="vars">
1eb9480 @petercollingridge Avoid question that is already answered
petercollingridge authored May 24, 2014
13 <var id="SLOPE">rand(4)</var>
14 <var id="SLOPE_NAME">[
15 $._("a positive"),
16 $._("a negative"),
17 $._("a zero"),
18 $._("an undefined")
19 ][SLOPE]</var>
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
20 <var id="POINTS">{}</var>
21 </div>
22
23 <p class="question">
6d7f8c2 @Atrytone Grammatical error
Atrytone authored Aug 20, 2013
24 Graph a line that has <var>SLOPE_NAME</var> slope:
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
25 </p>
26
d53a57c @jeresig Two doctypes were being output. Only output one.
jeresig authored Apr 16, 2013
27 <div class="graphie" id="grid">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
28 graphInit({
29 range: 11,
30 scale: 20,
31 axisArrows: "&lt;-&gt;",
32 tickStep: 1,
33 labelStep: 1,
34 gridOpacity: 0.05,
35 axisOpacity: 0.2,
36 tickOpacity: 0.4,
37 labelOpacity: 0.5
38 });
39
40 label([0, 11], "y", "above");
41 label([11, 0], "x", "right");
42
43 addMouseLayer();
44 POINTS.pointA = addMovablePoint({
45 coord: [-5, 5],
46 snapX: 0.5,
47 snapY: 0.5,
48 });
49 POINTS.pointB = addMovablePoint({
50 coord: [5, 5],
51 snapX: 0.5,
52 snapY: 0.5,
53 });
54 graph.line1 = addMovableLineSegment({
55 pointA: POINTS.pointA,
56 pointZ: POINTS.pointB,
57 fixed: true,
58 extendLine: true,
59 normalStyle: {
42dced0 @joelburget Remove unneeded KhanUtils
joelburget authored Aug 27, 2012
60 stroke: ORANGE,
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
61 "stroke-width": 2
62 }
63 });
64
65 // A and B can't be in the same place
66 POINTS.pointA.onMove = function(x, y) {
67 return (x !== POINTS.pointB.coord[0] ||
68 y !== POINTS.pointB.coord[1]);
69 }
70 POINTS.pointB.onMove = function(x, y) {
71 return (x !== POINTS.pointA.coord[0] ||
72 y !== POINTS.pointA.coord[1]);
73 }
74
75 POINTS.pointA.toFront();
76 POINTS.pointB.toFront();
77 </div>
78
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
79 <div class="solution" data-type="custom">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
80 <div class="instruction">
81 Drag the two points to move the line into the correct
82 position.
83 </div>
84 <div class="guess">
85 [POINTS.pointA.coord, POINTS.pointB.coord]
86 </div>
87 <div class="validator-function">
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 3, 2013
88 if (SLOPE !== 2&amp;&amp;
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
89 guess[0][0] === -5 &amp;&amp;
90 guess[0][1] === 5 &amp;&amp;
91 guess[1][0] === 5 &amp;&amp;
92 guess[1][1] === 5) {
93 return "";
94 }
95 var slope = (guess[1][1] - guess[0][1]) /
96 (guess[1][0] - guess[0][0]);
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
97 if (SLOPE === 0) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
98 return slope &gt; 0;
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
99 } else if (SLOPE === 1) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
100 return slope &lt; 0;
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
101 } else if (SLOPE === 2) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
102 return abs(slope) &lt; 0.001;
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
103 } else if (SLOPE === 3) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
104 return guess[1][0] === guess[0][0];
105 }
106 </div>
107 <div class="show-guess">
108 POINTS.pointA.setCoord(guess[0]);
109 POINTS.pointB.setCoord(guess[1]);
110 graph.line1.transform(true);
111 </div>
112 </div>
113
114 <div class="hints">
115 <p>
116 The slope of a line is the ratio of the change in
117 <code>y</code> over the change in <code>x</code>. Also
118 known as rise over run.
119 </p>
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
120 <p data-if="SLOPE === 0">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
121 For a positive slope, if the change in <code>y</code> from
122 one point to another is positive then the change in
123 <code>x</code> should also be positive.
124 </p>
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
125 <p data-else-if="SLOPE === 1">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
126 For a negative slope, if the change in <code>y</code> from
127 one point to another is positive then the change in
128 <code>x</code> should be negative.
129 </p>
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
130 <p data-else-if="SLOPE === 2">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
131 For a zero slope, the change in <code>y</code> should be
132 zero from any point to another point.
133 </p>
ced362c @jeresig Run the exercise cleaner.
jeresig authored Apr 23, 2013
134 <p data-else="">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
135 For an undefined slope, the change in <code>x</code> should
136 be zero from any point to another point.
137 </p>
138 <div>
139 <p>
42559c3 @Atrytone Update the hint to match the modified variable string.
Atrytone authored Aug 20, 2013
140 A line with <var>SLOPE_NAME</var> slope looks like:
ea8ecb9 @jeresig Rewrite linting to be contained within a single method.
jeresig authored Mar 15, 2013
141 </p>
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
142 <div class="graphie" style="margin-left: 30px">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
143 graphInit({
144 range: 6,
145 scale: 20,
146 axisArrows: "&lt;-&gt;",
147 tickStep: 1,
148 labelStep: 10,
149 gridOpacity: 0.05,
150 axisOpacity: 0.2,
151 tickOpacity: 0.4,
152 labelOpacity: 0.5
153 });
154
155 style({ stroke: ORANGE }, function() {
156 var intercept = randRange(-3, 3);
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
157 if (SLOPE === 0) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
158 plot(function(x) {
159 return x + intercept;
160 }, [-6, 6]);
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
161 } else if (SLOPE === 1) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
162 var yInt = randRange(-3, 3);
163 plot(function(x) {
164 return -x + intercept;
165 }, [-6, 6]);
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
166 } else if (SLOPE === 2) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
167 var y = randRangeNonZero(-3, 3);
168 path([[-6, intercept], [6, intercept]]);
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
169 } else if (SLOPE === 3) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
170 var x = randRangeNonZero(-3, 3);
171 path([[intercept, -6], [intercept, 6]]);
172 }
173 });
174 </div>
175 </div>
176 </div>
4e4cb9b @beneater lint: tabs->spaces and jQuery->$ for exercises
beneater authored Apr 10, 2012
177 </div>
62b80f8 @marcia Add exercise -- line graph intuition
marcia authored Jun 24, 2011
178
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
179 <div id="graph-compare" data-type="graph-slope" data-weight="1">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
180 <div class="vars">
181 <var id="SLOPE_N">randRangeNonZero(-5, 5)</var>
182 <var id="SLOPE_D">randRange(1, 5)</var>
183 <var id="Y_INT">randRange(-5, 5)</var>
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
184 <var id="GOAL_NEGATIVE,GOAL">[SLOPE_N &lt; 0, SLOPE_N &lt; 0 ? $._("negative") : $._("positive")]</var>
185 <var id="CHANGE,CHANGE_NAME">randFromArray([[0, "greater"], [1, "less"]])</var>
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
186 <var id="NEW_SLOPE">(function() {
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
187 if (GOAL_NEGATIVE) {
188 if (CHANGE === 0) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
189 return (SLOPE_N / SLOPE_D) / 2;
190 } else {
191 return (SLOPE_N / SLOPE_D) * 2;
192 }
193 } else {
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
194 if (CHANGE === 1) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
195 return (SLOPE_N / SLOPE_D) / 2;
196 } else {
197 return (SLOPE_N / SLOPE_D) * 2;
198 }
199 }
200 })()</var>
201 </div>
202 <p class="question">
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
203 Graph a line that has a slope that is
204 <em><var>GOAL</var></em> and
205 <em><var>CHANGE_NAME</var> than</em> the slope of the blue line.
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
206 </p>
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
207 <div class="graphie" data-update="grid">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
208 plot(function(x) {
209 return (SLOPE_N / SLOPE_D) * x + Y_INT;
210 }, [-11, 11], {
211 stroke: BLUE
212 }).toBack();
213 </div>
214
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
215 <div class="solution" data-type="custom">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
216 <div class="instruction">
217 Drag the two points to move the line into the correct
218 position.
4e4cb9b @beneater lint: tabs->spaces and jQuery->$ for exercises
beneater authored Apr 10, 2012
219 </div>
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
220 <div class="guess">
221 [POINTS.pointA.coord, POINTS.pointB.coord]
222 </div>
223 <div class="validator-function">
224 if (guess[0][0] === -5 &amp;&amp;
225 guess[0][1] === 5 &amp;&amp;
226 guess[1][0] === 5 &amp;&amp;
227 guess[1][1] === 5) {
228 return "";
229 }
230 var slope = (guess[1][1] - guess[0][1]) /
231 (guess[1][0] - guess[0][0]);
62b80f8 @marcia Add exercise -- line graph intuition
marcia authored Jun 24, 2011
232
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
233 if (!GOAL_NEGATIVE &amp;&amp;
234 CHANGE === 1) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
235 return (slope &gt; 0) &amp;&amp;
236 (slope &lt; SLOPE_N / SLOPE_D);
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
237 } else if (!GOAL_NEGATIVE &amp;&amp;
238 CHANGE === 0) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
239 return (slope &gt; 0) &amp;&amp;
240 (slope &gt; SLOPE_N / SLOPE_D);
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
241 } else if (GOAL_NEGATIVE &amp;&amp;
242 CHANGE === 1) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
243 return (slope &lt; 0) &amp;&amp;
244 (slope &lt; SLOPE_N / SLOPE_D);
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
245 } else if (GOAL_NEGATIVE &amp;&amp;
246 CHANGE === 0) {
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
247 return (slope &lt; 0) &amp;&amp;
248 (slope &gt; SLOPE_N / SLOPE_D);
249 }
250 </div>
251 <div class="show-guess">
252 POINTS.pointA.setCoord(guess[0]);
253 POINTS.pointB.setCoord(guess[1]);
254 graph.line1.transform(true);
255 </div>
256 </div>
257 <div class="hints">
258 <p>
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
259 <span data-if="GOAL_NEGATIVE">
260 The slope of the original line is negative.
261 </span><span data-else="">
262 The slope of the original line is positive.
263 </span>
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
264 </p>
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
265 <div data-if="GOAL_NEGATIVE">
266 <div data-if="CHANGE === 0">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
267 <p>
268 If the slope of the new line is negative and
269 greater than the slope of the original line with
270 negative slope then the new line should be less
271 steep.
272 </p>
273 </div>
ced362c @jeresig Run the exercise cleaner.
jeresig authored Apr 23, 2013
274 <div data-else="">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
275 <p>
276 If the slope of the new line is negative and less
277 than the slope of the original line with negative
278 slope, then the new line should be steeper.
279 </p>
280 </div>
281 </div>
ced362c @jeresig Run the exercise cleaner.
jeresig authored Apr 23, 2013
282 <div data-else="">
de19411 @xymostech Manually i18nize all of the minor exercises
xymostech authored Jun 4, 2013
283 <div data-if="CHANGE === 0">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
284 <p>
285 If the slope of the new line is positive and greater
286 than the slope of the original line with positive
287 slope, then the new line should be steeper.
288 </p>
289 </div>
ced362c @jeresig Run the exercise cleaner.
jeresig authored Apr 23, 2013
290 <div data-else="">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
291 <p>
292 If the slope of the new line is positive and less
293 than the slope of the original line with positive
294 slope, then the new line should be less steep.
295 </p>
296 </div>
297 </div>
298 <div>
299 <p>
300 Since the original slope is <code>
301 <var>fractionReduce(SLOPE_N, SLOPE_D)</var></code>,
302 the slope of the new line could be <code>
303 <var>decimalFraction(NEW_SLOPE, true, true)</var>
304 </code> and could look like this:
ced362c @jeresig Run the exercise cleaner.
jeresig authored Apr 23, 2013
305 </p><p>
306 </p><div class="graphie" style="margin-left: 30px">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
307 graphInit({
308 range: 11,
309 scale: 10,
310 axisArrows: "&lt;-&gt;",
311 tickStep: 1,
312 labelStep: 20,
313 gridOpacity: 0.05,
314 axisOpacity: 0.2,
315 tickOpacity: 0.4,
316 labelOpacity: 0.5
317 });
318
319 style({ stroke: BLUE }, function() {
320 plot(function(x) {
321 return x * (SLOPE_N / SLOPE_D) + Y_INT;
322 }, [-11, 11]);
323 });
324
325 style({ stroke: ORANGE }, function() {
326 plot(function(x) {
327 return x * NEW_SLOPE + 2;
328 }, [-11, 11]);
329 });
330 </div>
331 </div>
332 </div>
333 </div>
334
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
335 <div id="find-slope-and-yint" data-weight="1">
1eb9480 @petercollingridge Avoid question that is already answered
petercollingridge authored May 24, 2014
336 <div class="vars" data-ensure="!(M === 1 &amp;&amp; B === 1) &amp;&amp;
ced362c @jeresig Run the exercise cleaner.
jeresig authored Apr 23, 2013
337 abs(M) &lt; 10 &amp;&amp; abs(B) &lt; 10 &amp;&amp; INCR &lt; 6">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
338 <var id="X1, X2">randRangeUnique(-8, 8, 2)</var>
339 <var id="Y1, Y2">randRangeUnique(-8, 8, 2)</var>
340 <var id="RISE">Y2 - Y1</var>
341 <var id="RUN">X2 - X1</var>
342 <var id="M">RISE / RUN</var>
343 <var id="B">Y1 - X1 * M</var>
344 <var id="INCR">abs(RUN) / getGCD(abs(RISE), abs(RUN))</var>
345 <var id="GRAPH">{}</var>
346 </div>
347
348 <p class="question">
349 Adjust the slope and y-intercept until it connects the two
350 points. How do the slope and y-intercept values affect the line?
351 </p>
352
d53a57c @jeresig Two doctypes were being output. Only output one.
jeresig authored Apr 16, 2013
353 <div class="graphie" id="grid">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
354 graphInit({
355 range: 11,
356 scale: 20,
357 axisArrows: "&lt;-&gt;",
358 tickStep: 1,
359 labelStep: 1,
360 gridOpacity: 0.05,
361 axisOpacity: 0.2,
362 tickOpacity: 0.4,
363 labelOpacity: 0.5
364 });
365
366 label([0, 11], "y", "above");
367 label([11, 0], "x", "right");
368
369 style({
370 stroke: BLUE,
371 fill: BLUE
372 }, function() {
373 circle([X1, Y1], 0.2);
374 circle([X2, Y2], 0.2);
375 });
376
377 GRAPH.MN = 1;
378 GRAPH.MD = 1;
379 GRAPH.BN = 1;
380 GRAPH.BD = 1;
381 var plot = line([-11, -11 * GRAPH.MN / GRAPH.MD +
382 GRAPH.BN / GRAPH.BD], [11, 11 * GRAPH.MN / GRAPH.MD +
383 GRAPH.BN / GRAPH.BD], { stroke: BLUE });
384
385 GRAPH.redraw = function() {
386 plot.remove();
387 plot = line([-11, -11 * GRAPH.MN / GRAPH.MD +
388 GRAPH.BN / GRAPH.BD], [11, 11 * GRAPH.MN / GRAPH.MD +
389 GRAPH.BN / GRAPH.BD], { stroke: BLUE });
390 GRAPH.updateLabels();
391 };
392
393 GRAPH.changeSlope = function(dir) {
394 var prevDenom = GRAPH.MD;
395 GRAPH.MD = getLCM(prevDenom, INCR);
396 GRAPH.MN = (GRAPH.MD / prevDenom * GRAPH.MN) +
397 (dir * GRAPH.MD / INCR);
398 GRAPH.redraw();
399 };
400
401 GRAPH.changeIntercept = function(dir) {
402 var prevDenom = GRAPH.BD;
403 GRAPH.BD = getLCM(prevDenom, INCR)
404 GRAPH.BN = (GRAPH.BD / prevDenom * GRAPH.BN) +
405 (dir * GRAPH.BD / INCR);
406 GRAPH.redraw();
407 };
408 </div>
409
0f0c630 @cbhl Clean up the exercise files using the new cleaning utility. (II)
cbhl authored Apr 16, 2013
410 <div class="solution" data-type="custom">
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
411 <div class="instruction">
412 <div style="clear: left;">
413 Adjust this equation by clicking on the arrows:
414 </div>
415 <div class="graphie">
416 init({
417 range: [[0, 4], [0.5, 2.5]]
418 });
419 label([0, 1.5], "y = ", "right");
420 var slopeLabel = label([1.7, 1.5], "1", "left");
421 label([1.45, 1.5], "x", "right");
422 signLabel = label([1.8, 1.5], "+", "right");
423 var interceptLabel = label([2.2, 1.5], "1", "right");
424 addMouseLayer();
425 addArrowWidget({
426 coord: [1.4, 2.1],
427 direction: "up",
428 onClick: function() {
429 GRAPH.changeSlope(1);
430 }
431 });
432 addArrowWidget({
433 coord: [1.4, 0.8],
434 direction: "down",
435 onClick: function() {
436 GRAPH.changeSlope(-1);
437 }
438 });
439 addArrowWidget({
440 coord: [2.5, 2.1],
441 direction: "up",
442 onClick: function() {
443 GRAPH.changeIntercept(1);
444 }
445 });
446 addArrowWidget({
447 coord: [2.5, 0.8],
448 direction: "down",
449 onClick: function() {
450 GRAPH.changeIntercept(-1);
451 }
452 });
453 GRAPH.updateLabels = function() {
454 slopeLabel.remove();
455 signLabel.remove();
456 interceptLabel.remove();
457 slopeLabel = label([1.7, 1.5],
458 fractionReduce(GRAPH.MN, GRAPH.MD), "left");
459 signLabel = label([1.8, 1.5],
460 (GRAPH.BN &lt; 0 ? "-" : "+"), "right");
461 interceptLabel = label([2.2, 1.5],
462 fractionReduce(abs(GRAPH.BN), GRAPH.BD),
463 "right");
4e4cb9b @beneater lint: tabs->spaces and jQuery->$ for exercises
beneater authored Apr 10, 2012
464 };
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
465 </div>
466 </div>
467 <div class="guess">
468 [GRAPH.MN / GRAPH.MD, GRAPH.BN / GRAPH.BD]
4e4cb9b @beneater lint: tabs->spaces and jQuery->$ for exercises
beneater authored Apr 10, 2012
469 </div>
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
470 <div class="validator-function">
d3a8290 @xymostech Fix issues 28803 by rearranging validate
xymostech authored Aug 26, 2012
471 if ((abs(guess[0] - M) &lt; 0.001) &amp;&amp;
472 (abs(guess[1] - B) &lt; 0.001)) {
473 return true;
474 }
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
475 if (guess[0] === 1 &amp;&amp; guess[1] === 1) {
476 return "";
477 }
d3a8290 @xymostech Fix issues 28803 by rearranging validate
xymostech authored Aug 26, 2012
478 return false;
4e4cb9b @beneater lint: tabs->spaces and jQuery->$ for exercises
beneater authored Apr 10, 2012
479 </div>
037cb1f @joelburget Port line graph intuition to use a custom answer type
joelburget authored Aug 15, 2012
480 <div class="show-guess">
481 guess = guess.length ? guess : [1, 1, 1, 1];
482 GRAPH.MN = guess[0];
483 GRAPH.MD = 1;
484 GRAPH.BN = guess[1];
485 GRAPH.BD = 1;
486 GRAPH.updateLabels();
487 GRAPH.redraw();
488 </div>
4e4cb9b @beneater lint: tabs->spaces and jQuery->$ for exercises
beneater authored Apr 10, 2012
489 </div>
490 </div>
491 </div>
80788e1 @beneater Add new problem types and refactor line_graph_intuition
beneater authored Jul 27, 2012
492 </div>
7041f1b @jeresig Re-run the linter on the exercises.
jeresig authored Apr 23, 2013
493 </body>
494 </html>
Something went wrong with that request. Please try again.