This repository has been archived by the owner on May 11, 2021. It is now read-only.
/
reading_bar_charts_1.html
134 lines (128 loc) · 5.17 KB
/
reading_bar_charts_1.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
<!DOCTYPE html>
<html data-require="math graphie word-problems">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Reading bar charts 1</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
<style>
span.rotate {
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";
}
body.ie span.rotate {
left: 60px !important;
top: 140px !important;
}
</style>
</head>
<body>
<div class="exercise">
<div class="vars">
<!-- I18N: Harry Potter's Hogwarts house names -->
<var id="HOUSES">
[i18n._("Gryffindor"), i18n._("Hufflepuff"),
i18n._("Ravenclaw"), i18n._("Slytherin")]
</var>
<var id="INDEX">randRange( 0, HOUSES.length - 1 )</var>
<var id="VALUES">_.map(randRangeUnique(0, 9, HOUSES.length),
function(n) { return n * 10; })
</var>
</div>
<div class="problems">
<div>
<p class="problem">
At Hogwarts, there are four houses:
<var>toSentence(HOUSES)</var>. The bar chart below shows the
number of house points that each house received today.
</p>
<p class="question">
How many house points did <var>HOUSES[INDEX]</var> receive?
</p>
<p class="render-answer-area-here"></p>
<div class="graphie" id="barchart">
init({
range: [[-2, 14], [-3, 11.5]],
scale: [27, 30]
});
_.times(10, function(y) {
label([0, y], y * 10, "left", false);
style({
stroke: "#000",
strokeWidth: 1,
opacity: 0.2
}, function() {
line([0, y], [13, y]);
});
});
_.each(VALUES, function(value, index) {
style({ stroke: null, fill: "#9ab8ed", opacity: 1.0 });
path([[index * 3 + 1.5, 0], [index * 3 + 1.5, value / 10],
[index * 3 + 2.5, value / 10],
[index * 3 + 2.5, 0], true]);
style({ opacity: 1.0 });
label([index * 3 + 2, 0], HOUSES[index], "below", false);
});
style({ stroke: "#000", strokeWidth: 2, opacity: 1.0 });
line( [ 0, 0 ], [ 13, 0 ] );
line( [ 0, 0 ], [ 0, 10 ] );
label( [ 6.5, -0.8 ],
i18n._("House"),
"below", false ).css('font-weight', 'bold');
label( [ -1.5, 5 ],
"House points",
"center", false ).addClass( "rotate" )
.css('font-weight', 'bold');
label( [ 6.5, 10.5 ],
"House points earned today",
"above", false ).css('font-weight', 'bold');
</div>
<div class="solution" data-type="multiple">
<span class="sol" data-forms="integer, decimal">
<var>VALUES[INDEX]</var>
</span> house points
</div>
<div class="hints">
<div>
<p>Find the bar for <var>HOUSES[INDEX]</var>.</p>
<div class="graphie" data-update="barchart">
style({ stroke: PINK, fill: null, strokeWidth: 2 });
ellipse([INDEX * 3 + 2, -0.6], [1.5, 0.5]);
</div>
</div>
<div data-if="VALUES[INDEX] === 0">
<p>
There is no bar for <var>HOUSES[INDEX]</var>, which
means <var>HOUSES[INDEX]</var> recieved <code>0</code>
house points.
</p>
</div>
<div data-else="" data-unwrap="">
<div>
<p>
Compare the height of the bar for
<var>HOUSES[INDEX]</var> to the scale on the left.
</p>
<div class="graphie" data-update="barchart">
style({
stroke: PINK,
strokeWidth: 2,
arrows: "->",
strokeDasharray: "-"
});
line([INDEX * 3 + 1.5, VALUES[INDEX] / 10],
[0, VALUES[INDEX] / 10]);
</div>
</div>
<p>
<var>HOUSES[INDEX]</var> received
<code><var>VALUES[INDEX]</var></code> house points.
</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>