This repository has been archived by the owner on May 11, 2021. It is now read-only.
/
number_line_2.html
286 lines (261 loc) · 14.1 KB
/
number_line_2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<!DOCTYPE html>
<html data-require="math graphie word-problems interactive">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Negative numbers on the number line</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="SCALE">randRange(1, 4)</var>
<var id="LOWER_BOUND">-5 * SCALE</var>
<var id="UPPER_BOUND">-1 * LOWER_BOUND</var>
<var id="NUMBER">randRangeExclude(-5, 5, [-1, 0, 1]) * SCALE</var>
<var id="START">LOWER_BOUND - SCALE * 0.6</var>
<var id="STOP">UPPER_BOUND + SCALE * 0.6</var>
<var id="ORANGE_DOT">$._("orange dot")</var>
</div>
<div class="problems">
<div id="where-is-point-horizontal">
<div class="question">
<p>
Move the <strong><code>\orange{\text{<var>ORANGE_DOT</var>}}</code></strong> to
<strong><code>\orange{<var>NUMBER</var>}</code></strong> on the number line.
</p>
<div class="graphie" id="number-line">
init({
range: [[LOWER_BOUND - SCALE * 0.75, UPPER_BOUND + SCALE * 0.75], [-1, 1]],
scale: [40 / SCALE, 40]
});
line([START + 1, 0], [STOP, 0], { arrows: "->" });
line([STOP - 1, 0], [START, 0], { arrows: "->" });
for (var x = LOWER_BOUND; x <= UPPER_BOUND; x += SCALE) {
line([x, -0.2], [x, 0.2]);
}
style({ stroke: BLUE, strokeWidth: 3.5 });
line([0, -0.2], [0, 0.2]);
label([0, -0.53], "0", "center");
label([-SCALE, -0.53], "\\llap{-}" + SCALE, "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">
<div class="guess">graph.movablePoint.coord[0]</div>
<div class="validator-function">
if ( guess === 0 ) {
return "";
}
return abs( NUMBER - guess ) < 0.001;
</div>
<div class="show-guess">
graph.movablePoint.setCoord([guess, 0]);
</div>
</div>
<div class="hints">
<p>We know where <code>0</code> is on the number line because it is labeled.</p>
<p>We know each tick mark represents <code><var>SCALE</var></code> because <code><var>-SCALE</var></code> and <code><var>SCALE</var></code> are labeled.</p>
<p data-if="NUMBER < 0">Because <code><var>NUMBER</var></code> is negative, it will be to the left of <code>0</code>.</p>
<p data-else="">Because <code><var>NUMBER</var></code> is positive, it will be to the right of <code>0</code>.</p>
<div>
<div class="graphie" data-update="number-line">
style({ stroke: BLUE, fill: BLUE, strokeWidth: 3.5, arrows: "->" });
line( [ 0, 0 ], [ NUMBER, 0 ] );
graph.movablePoint.visibleShape.toFront();
</div>
<p data-if="NUMBER < 0">
Each tick mark represents <code><var>SCALE</var></code>,
so <code><var>NUMBER</var></code> will be
<code><var>abs(round(NUMBER / SCALE))</var></code> tick marks
to the left of <code>0</code>.
</p><p data-else="">
Each tick mark represents <code><var>SCALE</var></code>,
so <code><var>NUMBER</var></code> will be
<code><var>abs(round(NUMBER / SCALE))</var></code> tick marks
to the right of <code>0</code>.
</p>
</div>
<div>
<div class="graphie" data-update="number-line">
label([NUMBER, -0.53], NUMBER, "center", { color: ORANGE });
graph.movablePoint.moveTo(NUMBER, 0);
</div>
<p>The orange number shows where <code><var>NUMBER</var></code> is on the number line.</p>
</div>
</div>
</div>
<div id="where-is-point-vertical">
<div class="question">
<p>
Move the <strong><code>\color{orange}{\text{<var>ORANGE_DOT</var>}}</code></strong> to
<strong><code>\color{orange}{<var>NUMBER</var>}</code></strong> on the number line.
</p>
<div class="graphie" id="number-line">
init({
range: [[-5, 5], [LOWER_BOUND - SCALE * 0.75, UPPER_BOUND + SCALE * 0.75]],
scale: [32, 32 / SCALE]
});
line([0, START + 1], [0, STOP], { arrows: "->" });
line([0, STOP - 1], [0, START], { arrows: "->" });
for (var y = LOWER_BOUND; y <= UPPER_BOUND; y += SCALE) {
line([-0.2, y], [0.2, y]);
}
style({ stroke: BLUE, strokeWidth: 3.5 });
line([-0.2, 0], [0.2, 0]);
label([-0.2, 0], "0", "left");
label([-0.2, -SCALE], "\\llap{-}" + SCALE, "left");
label([-0.2, SCALE], SCALE, "left");
addMouseLayer();
var snap = SCALE / 4;
if (SCALE === 3) {
snap = SCALE / 3;
}
graph.movablePoint = addMovablePoint({ constraints: { constrainX: true }, snapY: snap });
graph.movablePoint.onMove = function(x, y) {
return [x, min(max(LOWER_BOUND, y), UPPER_BOUND)];
};
</div>
</div>
<div class="solution" data-type="custom">
<div class="guess">graph.movablePoint.coord[1]</div>
<div class="validator-function">
if (guess === 0) {
return "";
}
return abs(NUMBER - guess) < 0.001;
</div>
<div class="show-guess">
graph.movablePoint.setCoord([0, guess]);
</div>
</div>
<div class="hints">
<p>We know where <code>0</code> is on the number line because it is labeled.</p>
<p>We know each tick mark represents <code><var>SCALE</var></code> because <code><var>-SCALE</var></code> and <code><var>SCALE</var></code> are labeled.</p>
<p data-if="NUMBER < 0">Because <code><var>NUMBER</var></code> is negative, it will be below <code>0</code>.</p>
<p data-else="">Because <code><var>NUMBER</var></code> is positive, it will be above <code>0</code>.</p>
<div>
<div class="graphie" data-update="number-line">
style({ stroke: BLUE, fill: BLUE, strokeWidth: 3.5, arrows: "->" });
line([0, 0], [0, NUMBER] );
graph.movablePoint.visibleShape.toFront();
</div>
<p data-if="NUMBER < 0">
Each tick mark represents <code><var>SCALE</var></code>,
so <code><var>NUMBER</var></code> will be
<code><var>abs(round(NUMBER / SCALE))</var></code> tick marks
below <code>0</code>.
</p><p data-else="">
Each tick mark represents <code><var>SCALE</var></code>,
so <code><var>NUMBER</var></code> will be
<code><var>abs(round(NUMBER / SCALE))</var></code> tick marks
above <code>0</code>.
</p>
</div>
<div>
<div class="graphie" data-update="number-line">
label([-0.2, NUMBER], NUMBER, "left", { color: ORANGE });
graph.movablePoint.moveTo(0, NUMBER);
</div>
<p>The orange number shows where <code><var>NUMBER</var></code> is on the number line.</p>
</div>
</div>
</div>
<div id="what-is-point-horizontal">
<div class="question">
<p>Where is the blue dot on the number line?</p>
<div class="render-answer-area-here"></div>
<div class="graphie" id="number-line-2">
init({
range: [[LOWER_BOUND - SCALE * 0.75, UPPER_BOUND + SCALE * 0.75], [-1, 1]],
scale: [40 / SCALE, 40]
});
line([START + 1, 0], [STOP, 0], { arrows: "->" });
line([STOP - 1, 0], [START, 0], { arrows: "->" });
for (var x = LOWER_BOUND; x <= UPPER_BOUND; x += SCALE) {
line([x, -0.2], [x, 0.2]);
}
style({ strokeWidth: 3.5 });
line([0, -0.2], [0, 0.2]);
label([0, -0.53], "0", "center");
label([-SCALE, -0.53], "\\llap{-}" + SCALE, "center");
label([SCALE, -0.53], SCALE, "center");
style({ stroke: BLUE, fill: BLUE });
graph.blueDot = ellipse([NUMBER, 0], [SCALE * 0.1, 0.1]);
graph.questionLabel = label([NUMBER, -0.53], "{?}", "center", { color: BLUE });
</div>
</div>
<div class="solution" data-forms="integer"><var>NUMBER</var></div>
<div class="hints">
<p>We know where <code>0</code> is on the number line because it is labeled.</p>
<p>We know each tick mark represents <code><var>SCALE</var></code> because <code><var>-SCALE</var></code> and <code><var>SCALE</var></code> are labeled.</p>
<p data-if="NUMBER < 0">Because the blue dot is to the left of <code>0</code>, the number will be negative.</p>
<p data-else="">Because the blue dot is to the right of <code>0</code>, the number will be positive.</p>
<div>
<div class="graphie" data-update="number-line-2">
for (var x = SCALE * 2; x <= UPPER_BOUND; x += SCALE) {
label([x, -0.53], x, "center");
label([-x, -0.53], "\\llap{-}" + x, "center");
}
graph.questionLabel.remove();
label([NUMBER, -0.53], ("" + NUMBER).replace(/-/, "\\llap{-}"), "center", { color: BLUE });
</div>
<p>The blue dot represents the number <code><var>NUMBER</var></code>.</p>
</div>
</div>
</div>
<div id="what-is-point-vertical">
<div class="question">
<p>Where is the blue dot on the number line?</p>
<div class="render-answer-area-here"></div>
<div class="graphie" id="number-line-2">
init({
range: [[-5, 5], [LOWER_BOUND - SCALE * 0.75, UPPER_BOUND + SCALE * 0.75]],
scale: [32, 32 / SCALE]
});
line([0, START + 1], [0, STOP], { arrows: "->" });
line([0, STOP - 1], [0, START], { arrows: "->" });
for (var y = LOWER_BOUND; y <= UPPER_BOUND; y += SCALE) {
line([-0.2, y], [0.2, y]);
}
style({ strokeWidth: 3.5 });
line([-0.2, 0], [0.2, 0]);
label([-0.2, 0], "0", "left");
label([-0.2, -SCALE], "\\llap{-}" + SCALE, "left");
label([-0.2, SCALE], SCALE, "left");
style({ stroke: BLUE, fill: BLUE });
graph.blueDot = ellipse([0, NUMBER], [0.1, 0.1 * SCALE]);
graph.questionLabel = label([-0.2, NUMBER], "{?}", "left", { color: BLUE });;
</div>
</div>
<div class="solution" data-forms="integer"><var>NUMBER</var></div>
<div class="hints">
<p>We know where <code>0</code> is on the number line because it is labeled.</p>
<p>We know each tick mark represents <code><var>SCALE</var></code> because <code><var>-SCALE</var></code> and <code><var>SCALE</var></code> are labeled.</p>
<p data-if="NUMBER < 0">Because the blue dot is below <code>0</code>, the number will be negative.</p>
<p data-else="">Because the blue dot is above <code>0</code>, the number will be positive.</p>
<div>
<div class="graphie" data-update="number-line-2">
for (var x = SCALE * 2; x <= UPPER_BOUND; x += SCALE) {
label([-0.2 ,x], x, "left");
label([-0.2, -x], "\\llap{-}" + x, "left");
}
graph.questionLabel.remove();
label([-0.2, NUMBER], ("" + NUMBER).replace(/-/, "\\llap{-}"), "left", { color: BLUE });
</div>
<p>The blue dot represents the number <code><var>NUMBER</var></code>.</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>