This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 863
/
reading_tables_2.html
119 lines (117 loc) · 4.43 KB
/
reading_tables_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
<!DOCTYPE html>
<html data-require="math graphie word-problems">
<head>
<meta charset="UTF-8" />
<title>Reading tables 2</title>
<script src="../khan-exercise.js"></script>
<style>
.reading span {
width: 100px;
}
.reading span:first-child {
width: 130px;
}
</style>
<script>
function fillInCorrectAnswer( schoolIndex, columnIndex, answer, color ) {
var nth = ":nth-child(" + ( columnIndex + 2 ) + ")";
jQuery( ".fake_row" ).eq( schoolIndex ).find( "span" + nth )
.html( answer )
.css( "color", color );
}
</script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="SCHOOLS">[ school(1), school(2), school(3), school(4) ]</var>
<var id="COLUMNS">[ "4th grade", "5th grade", "6th grade", "Total" ]</var>
<var id="COL_INDEX">randRange( 0, COLUMNS.length - 1 )</var>
<var id="SCHOOL_INDEX">randRange( 0, SCHOOLS.length - 1 )</var>
<var id="ENROLLMENTS, ANSWER">
(function() {
var enrollments = [];
var classMin = 60;
var classMax = 80;
for ( var i = 0; i < SCHOOLS.length; i++ ) {
var enroll = randRange( classMin, classMax, COLUMNS.length - 1 );
var total = 0;
jQuery.each( enroll, function( i, e ) {
total += e;
});
enroll.push( total );
enrollments.push( enroll );
}
var answer = enrollments[ SCHOOL_INDEX ][ COL_INDEX ];
enrollments[ SCHOOL_INDEX ][ COL_INDEX ] = " ";
return [ enrollments, answer ];
})()
</var>
</div>
<div class="problems">
<div>
<p>The table below shows the enrollment at four different elementary schools that have 4th through 6th grade students, except one entry is missing.</p>
<p class="question">What number should go in the empty cell?</p>
<div class="fake_header reading">
<span>Schools</span><span data-each="COLUMNS as i, grade"><var>grade</var></span>
</div>
<div class="fake_row reading" data-each="SCHOOLS as i, school">
<span><var>school</var></span><span data-each="ENROLLMENTS[i] as j, enrollment"> <var>enrollment</var> </span>
</div>
<div class="solution" data-type="multiple">
<span style="padding-right: 5px" class="sol"><var>ANSWER</var></span> students
</div>
<div class="hints">
<p>The table is missing <span data-if="COL_INDEX === COLUMNS.length - 1">the total number of</span><span data-else>the number of <var>COLUMNS[ COL_INDEX ]</var></span> students at <var>SCHOOLS[ SCHOOL_INDEX ]</var> Elementary School.</p>
<div data-if="COL_INDEX === COLUMNS.length - 1" data-unwrap>
<div>
<p>The table accounts for <span class="hint_orange"><var>ENROLLMENTS[ SCHOOL_INDEX ].slice( 0, COL_INDEX ).join( "+" )</var></span> students.</p>
<div class="graphie">
jQuery.each( COLUMNS, function( i, c ) {
if ( i !== 0 ) {
jQuery( ".fake_row" ).eq( SCHOOL_INDEX ).find( "span" ).eq( i )
.css( "color", KhanUtil.ORANGE );
}
});
</div>
</div>
<div>
<p>The total number of students at <var>SCHOOLS[ SCHOOL_INDEX ]</var> Elementary School is simply the sum, or <span class="hint_pink"><var>ANSWER</var></span>.</p>
<div class="graphie">
fillInCorrectAnswer( SCHOOL_INDEX, COL_INDEX, ANSWER, KhanUtil.PINK );
</div>
</div>
</div>
<div data-else data-unwrap>
<div>
<p>The total number of students at <var>SCHOOLS[ SCHOOL_INDEX ]</var> Elementary School is <span class="hint_blue"><var>ENROLLMENTS[ SCHOOL_INDEX ][ COLUMNS.length - 1 ]</var></span>.</p>
</p>
<div class="graphie">
jQuery( ".fake_row" ).eq( SCHOOL_INDEX ).find( "span" ).eq( COLUMNS.length )
.css( "color", KhanUtil.BLUE );
</div>
</div>
<div>
<p>The table already accounts for <span class="hint_orange"><var>ENROLLMENTS[ SCHOOL_INDEX ].slice( 0, COL_INDEX ).concat( ENROLLMENTS[ SCHOOL_INDEX ].slice(COL_INDEX + 1, COLUMNS.length - 1 ) ).join( "+" )</var></span> students.</p>
<div class="graphie">
jQuery.each( COLUMNS, function( i, c ) {
if ( i !== 0 ) {
jQuery( ".fake_row" ).eq( SCHOOL_INDEX ).find( "span" ).eq( i )
.css( "color", KhanUtil.ORANGE );
}
});
</div>
</div>
<div>
<p>The missing number must be the difference of the blue and orange numbers, or <span class="hint_pink"><var>ANSWER</var></span>.</p>
<div class="graphie">
fillInCorrectAnswer( SCHOOL_INDEX, COL_INDEX, ANSWER, KhanUtil.PINK );
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>