-
Notifications
You must be signed in to change notification settings - Fork 4
/
multiChoiceTests.html
405 lines (349 loc) · 11.5 KB
/
multiChoiceTests.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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<!DOCTYPE html>
<html>
<head>
<title class="setTitle"></title>
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="eCourses Author, Title" name="description">
<!-- Bootstrap -->
<!-- bootstrap_plus.css contains styling for the dropdown menu and other common core styles -->
<link href="css/bootstrap_plus.css" rel="stylesheet" media="screen">
<!-- widgets.css contains styling for the interactive brix -->
<link href="css/widgets.css" rel="stylesheet">
<!-- eCourse-master.css contains styling for all the navigation -->
<link href="css/eCourse-master.css" rel="stylesheet" media="screen">
<!-- content_styles.css contains styling for the narrative layout and responsive design -->
<link href="css/content_styles.css" rel="stylesheet" media="screen">
</head>
<body>
<div class="container">
<div class="span12 lc_ec_page">
<section class="lc_ec_fiftyFifty lc_ec_pageInner">
<div class="lc_ec_content">
<h2 class="lc_ec_bHead"><span class='number setId'></span>
<span class="setTitle"></span>
</h2>
<div class="lc_ec_leading">
<div><p>0. Radio button w/ 4 answers</p>
<p>Q1: Why?</p>
<div id="rb-test" style="margin: 0 0 15px 15px;"></div>
<p>In order to manually test that selecting an answer correctly
publishes the selected event, we have an event handler that displays
the answer key of the selection. It should change as you manually
select an answer.</p>
<p>The answer key selected is: <b id="rb-test-key">none</b>.</p>
<p id="rb-test-resp"></p>
</div>
<hr />
<div id="radioRnd"><p>Q1-test. Multiple Choice question, randomized</p></div>
<hr />
<div id="radioOrd"><p>Q2-test. Multiple Choice question, nonrandomized</p></div>
<hr />
</div>
<div class="lc_ec_trailing">
<div id="graphIn"><p>4. Graphs as responses (radio buttons containing widgets)</p></div>
<hr />
<div id="traceIn"><p>5. Traces as responses (choose a trace)</p></div>
</div>
</div>
</section>
</div>
</div>
<script src="js/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-ui-1.10.2.custom.js"></script>
<script src="js/toc-structure.js"></script>
<script src="js/eCourse-master.js"></script>
<script src="js/d3.v3.min.js"></script>
<script src="js/brixlib-compiled.js"></script>
<!--
<script src="../closure/closure-library/closure/goog/base.js"></script>
<script src="../closure/closure-library/closure/goog/deps.js"></script>
<script src="js/eventmanager.js"></script>
<script src="js/widget-base.js"></script>
<script src="js/widget-image.js"></script>
<script src="js/widget-carousel.js"></script>
<script src="js/widget-imageviewer.js"></script>
<script src="js/widget-labelgroup.js"></script>
<script src="js/widget-callouts.js"></script>
<script src="js/widget-markergroup.js"></script>
<script src="js/widget-barchart.js"></script>
<script src="js/widget-radiogroup.js"></script>
<script src="js/widget-button.js"></script>
<script src="js/widget-multiplechoicequestion.js"></script>
<script src="js/fakeactivitydb.js"></script>
<script src="js/answerman.js"></script>
<script src="js/submitmanager.js"></script>
<script src="js/widget-selectgroup.js"></script>
<script src="js/widget-linegraph.js"></script>
-->
<script>
var eventManager = new pearson.utils.EventManager();
var MultipleChoiceQuestion = pearson.brix.MultipleChoiceQuestion;
var Button = pearson.brix.Button;
var RadioGroup = pearson.brix.RadioGroup;
var SelectGroup = pearson.brix.SelectGroup;
var LineGraph = pearson.brix.LineGraph;
var AnswerMan = pearson.brix.utils.AnswerMan;
var SubmitManager = pearson.brix.utils.SubmitManager;
var submitManager = new SubmitManager(eventManager, new AnswerMan());
var Q1Choices = [
{
content: "Because as the population increases, the absolute number of births increases even though the growth rate stays constant.",
response: "Growth rate stays constant.",
answerKey: "answer000"
},
{
content: "Because the growth rate increases as the population rises.",
response: "Does the growth rate change with population size?",
answerKey: "answer001"
},
{
content: "Because the total fertility rate increases with population.",
response: "Does the fertility rate change with population size?",
answerKey: "answer002"
},
{
content: "Because social behaviors change and people decide to have more children.",
response: "This might happen but is it something is necessarily occurs?",
answerKey: "answer003"
}
];
//<div id="radioRnd"><p>0. Multiple Choice question, randomized</p></div>
var radioButtons = new RadioGroup({
id: "RG1",
choices: Q1Choices,
numberFormat: "number"
}, eventManager);
radioButtons.draw(d3.select("#rb-test"));
// Manual test that making a selection on the radio group fires the selectedEventId
var handle_radioButtons_selected = function (eventDetails)
{
d3.select("#rb-test-key").text(eventDetails.selectKey);
d3.select("#rb-test-resp").text(radioButtons.selectedItem().response);
};
eventManager.subscribe(radioButtons.selectedEventId, handle_radioButtons_selected);
// Test a select one question using a radio group widget
var Q1 = new MultipleChoiceQuestion({
id: "Q1",
questionId: "SanVan001",
question: "Why does it take less and less time to add each additional billion people to the planet?",
choices: Q1Choices,
order: "randomized",
widget: RadioGroup,
widgetConfig: { numberFormat: "latin-upper" },
}, eventManager);
Q1.draw(d3.select("#radioRnd"));
submitManager.handleRequestsFrom(Q1);
//<div id="radioOrd"><p>1. Multiple Choice question, nonrandomized</p></div>
var Q2 = new MultipleChoiceQuestion({
id: "Q2",
questionId: "SanVan001",
question: "Why?",
choices: Q1Choices,
order: "ordered",
widget: RadioGroup,
widgetConfig: { numberFormat: "latin-lower" },
}, eventManager);
Q2.draw(d3.select("#radioOrd"));
submitManager.handleRequestsFrom(Q2);
// <div id="graphIn"><p>Graphs as content</p></div>
var NorthAmerica = [
{x: 1500, y: 0.01075},
{x: 1600, y: 0.01378},
{x: 1700, y: 0.01542},
{x: 1750, y: 0.02000},
{x: 1800, y: 0.07000},
{x: 1850, y: 0.02600},
{x: 1900, y: 0.082000},
{x: 1910, y: 0.099923},
{x: 1920, y: 0.117330},
{x: 1930, y: 0.134728},
{x: 1940, y: 0.151627},
{x: 1950, y: 0.171615},
{x: 1955, y: 0.186960},
{x: 1960, y: 0.204318},
{x: 1965, y: 0.219224},
{x: 1970, y: 0.231284},
{x: 1975, y: 0.242360},
{x: 1980, y: 0.254097},
{x: 1985, y: 0.266572},
{x: 1990, y: 0.282688},
{x: 1995, y: 0.300073},
{x: 2000, y: 0.318654},
{x: 2005, y: 0.335175},
{x: 2010, y: 0.351659}];
var LatinAmerica = [
{x: 1500, y: 0.008597},
{x: 1600, y: 0.011024},
{x: 1700, y: 0.012339},
{x: 1750, y: 0.016000},
{x: 1800, y: 0.024000},
{x: 1850, y: 0.038000},
{x: 1900, y: 0.074000},
{x: 1910, y: 0.092661},
{x: 1920, y: 0.112448},
{x: 1930, y: 0.133889},
{x: 1940, y: 0.157552},
{x: 1950, y: 0.167307},
{x: 1955, y: 0.191596},
{x: 1960, y: 0.219651},
{x: 1965, y: 0.252204},
{x: 1970, y: 0.286472},
{x: 1975, y: 0.323323},
{x: 1980, y: 0.362655},
{x: 1985, y: 0.402103},
{x: 1990, y: 0.442310},
{x: 1995, y: 0.482265},
{x: 2000, y: 0.521228},
{x: 2005, y: 0.556512},
{x: 2010, y: 0.588649}];
var Asia = [
{x: 1500, y: 0.269722},
{x: 1600, y: 0.345879},
{x: 1700, y: 0.387130},
{x: 1750, y: 0.502000},
{x: 1800, y: 0.635000},
{x: 1850, y: 0.809000},
{x: 1900, y: 0.947000},
{x: 1910, y: 1.038177},
{x: 1920, y: 1.138897},
{x: 1930, y: 1.249916},
{x: 1940, y: 1.377124},
{x: 1950, y: 1.402887},
{x: 1955, y: 1.541775},
{x: 1960, y: 1.693992},
{x: 1965, y: 1.885955},
{x: 1970, y: 2.125393},
{x: 1975, y: 2.379374},
{x: 1980, y: 2.622565},
{x: 1985, y: 2.889608},
{x: 1990, y: 3.178810},
{x: 1995, y: 3.448034},
{x: 2000, y: 3.698296},
{x: 2005, y: 3.936536},
{x: 2010, y: 4.166741}];
var Africa = [
{x: 1500, y: 0.056953},
{x: 1600, y: 0.073034},
{x: 1700, y: 0.081745},
{x: 1750, y: 0.106000},
{x: 1800, y: 0.107000},
{x: 1850, y: 0.111000},
{x: 1900, y: 0.133000},
{x: 1910, y: 0.151854},
{x: 1920, y: 0.172163},
{x: 1930, y: 0.194740},
{x: 1940, y: 0.220254},
{x: 1950, y: 0.227270},
{x: 1955, y: 0.253397},
{x: 1960, y: 0.285049},
{x: 1965, y: 0.322309},
{x: 1970, y: 0.366792},
{x: 1975, y: 0.418765},
{x: 1980, y: 0.482236},
{x: 1985, y: 0.556131},
{x: 1990, y: 0.638729},
{x: 1995, y: 0.726285},
{x: 2000, y: 0.819462},
{x: 2005, y: 0.921073},
{x: 2010, y: 1.033043}];
var Africalg = {
Data: [Africa],
type: "lines",
xAxisFormat: { type: "linear",
ticks: 5,
orientation: "bottom",
label: "Year" },
yAxisFormat: { type: "linear",
ticks: 8,
orientation: "left",
label: "Human Population (Billions)" },
};
var Asialg = {
Data: [Asia],
type: "lines",
xAxisFormat: { type: "linear",
ticks: 5,
orientation: "bottom",
label: "Year" },
yAxisFormat: { type: "linear",
ticks: 8,
orientation: "left",
label: "Human Population (Billions)" },
};
var NAlg = {
Data: [NorthAmerica],
type: "lines",
xAxisFormat: { type: "linear",
ticks: 5,
orientation: "bottom",
label: "Year" },
yAxisFormat: { type: "linear",
ticks: 8,
orientation: "left",
label: "Human Population (Billions)" },
};
var LAlg = {
Data: [LatinAmerica],
type: "lines",
xAxisFormat: { type: "linear",
ticks: 5,
orientation: "bottom",
label: "Year" },
yAxisFormat: { type: "linear",
ticks: 8,
orientation: "left",
label: "Human Population (Billions)" },
};
var Q4Choices = [
{
content: new LineGraph(Asialg),
response: "Asia currently has a population over 4 Billion, and is the most populous continent on the earth.",
answerKey: "correct"
},
{
content: new LineGraph(LAlg),
response: "Asia currently has a larger population, and it's population is still growing, not leveling off.",
answerKey: "wrong1",
},
{
content: new LineGraph(Africalg),
response: "Although the overall shape is right, Asia has a larger current population even than Africa.",
answerKey: "wrong2",
},
{
content: new LineGraph(NAlg),
response: "Asia currently has a larger population, this is the curve for North America.",
answerKey: "wrong3"
}
];
var Q4 = new MultipleChoiceQuestion({
id: "Q4",
question: "Wherefore?",
choices: Q4Choices,
order: "randomized",
widget: RadioGroup,
widgetConfig: { numberFormat: "latin-upper", svgWidgetSize: {height: 100, width: 200} }
}, eventManager);
Q4.draw(d3.select("#graphIn"));
eventManager.subscribe(radioButtons.submitEventId,
handleSubmit);
/************************************************************************
* handleSubmit *//**
*
* handleSubmit is called from the event handler for one of
* the input widgets when the user submits an answer. It scores
* the triggering widget and returns any answer response.
*
* @param eventDetails These are the keyed values returned by
* the event, in this case, a submission.
*************************************************************************/
function handleSubmit(eventDetails)
{
//Handler needs to get written into each page,
//each widget will have it's own way of responding
eventDetails.id.score(eventDetails.selectKey);
}
</script>
</body>
</html>