Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
86 lines (81 sloc) 3.69 KB
<!DOCTYPE html>
<html data-require="math graphie word-problems interactive">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Number line 1</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="SCALE">randRange(1, 4)</var>
<var id="LOWER_BOUND">0</var>
<var id="UPPER_BOUND">10 * SCALE</var>
<var id="NUMBER">randRangeNonZero(3, 10) * SCALE</var>
</div>
<div class="problems">
<div>
<div class="question">
<p class="question">Where is <code><var>NUMBER</var></code> on the number line?</p>
<div class="graphie" id="number-line">
var scale = 40 / SCALE;
init({
range: [[LOWER_BOUND - (30 / scale), UPPER_BOUND + (30 / scale)], [-1, 1]],
scale: [40 / SCALE, 40]
});
line([LOWER_BOUND - (25 / scale), 0], [UPPER_BOUND + (25 / scale), 0], { arrows: "-&gt;" });
line([UPPER_BOUND + (25 / scale), 0], [LOWER_BOUND - (25 / scale), 0], { arrows: "-&gt;" });
for (var x = LOWER_BOUND; x &lt;= UPPER_BOUND; x += SCALE) {
line([x, -0.2], [x, 0.2 ]);
}
style({ stroke: "#6495ED", strokeWidth: 3.5 });
line( [ 0, -0.2], [0, 0.2]);
label( [ 0, -0.53 ], "0", "center");
label( [ SCALE, -0.53 ], SCALE, "center");
addMouseLayer();
var snap = SCALE / 4;
if (SCALE === 3) {
snap = SCALE / 3;
}
graph.movablePoint = addMovablePoint({ constraints: { constrainY: true }, snapX: snap });
graph.movablePoint.onMove = function( x, y ) {
return [ min( max( LOWER_BOUND, x ), UPPER_BOUND ), y ];
};
</div>
</div>
<div class="solution" data-type="custom">
<span class="instruction"> Move the orange dot to select your answer. </span>
<div class="guess"> graph.movablePoint.coord[0] </div>
<div class="validator-function">
if (guess === 0) {
return "";
}
return abs(NUMBER - guess) &lt; 0.001;
</div>
<div class="show-guess">
graph.movablePoint.setCoord([guess, 0]);
</div>
</div>
<div class="hints">
<p>We know each tick mark is <code><var>SCALE</var></code> because <code>0</code> and <code><var>SCALE</var></code> are labeled.</p>
<div>
<p>Label the rest of the number line.</p>
<div class="graphie" data-update="number-line">
for (var x = LOWER_BOUND; x &lt;= UPPER_BOUND; x += SCALE) {
label([x, -0.53], ("" + x).replace(/-/, "\\llap{-}"), "center");
}
</div>
</div>
<div>
<p>The orange number shows where <var>NUMBER</var> is on the number line.</p>
<div class="graphie" data-update="number-line">
label([ NUMBER, -0.53], ("" + NUMBER).replace(/-/, "\\llap{-}"), "center", { color: ORANGE });
graph.movablePoint.moveTo(NUMBER, 0);
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.