-
-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy pathBasicProbabilityConcepts_GuidedProblem1.pg
More file actions
283 lines (234 loc) · 6.45 KB
/
Copy pathBasicProbabilityConcepts_GuidedProblem1.pg
File metadata and controls
283 lines (234 loc) · 6.45 KB
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
## DESCRIPTION
## WeBWorK Guided Problems Project — Sample Spaces & Events (Guided / Scaffolded)
## ENDDESCRIPTION
##
## Institution(Dawson College)
## Author(Mehdi Moodi)
## DBsubject(Statistics)
## DBchapter(Probability)
## DBsection(Sample Spaces and Events)
## Level(2)
## KEYWORDS('probability','sample space','event','random experiment','trial')
DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGanswermacros.pl",
"MathObjects.pl",
"contextString.pl",
"scaffold.pl",
);
TEXT(beginproblem());
# ----------------------------------------------------------------
# PILOT: usefulness rating toggle (ACTIVE)
# ----------------------------------------------------------------
$ENABLE_GP_RATING = 1; # set to 0 to hide/remove the rating step
# =======================================================
# Evaluators for set-entry (order doesn't matter)
# =======================================================
Context("String");
# Critical: allow comma-separated lists of strings to be parsed as a List
Context()->operators->redefine(',', using => ',');
# Allowed outcomes
Context()->strings->add(
"WW" => {},
"WB" => {},
"BW" => {},
"BB" => {},
);
$correctS = List( String("WW"), String("WB"), String("BW"), String("BB") );
$correctE = List( String("WB"), String("BW") );
# =======================================================
# Rating evaluator (integer 1–5)
# =======================================================
Context("Numeric");
$cmp_rating = Real(1)->cmp(
checker => sub {
my ($correct, $student, $ansHash) = @_;
return 0 unless defined $student;
my $v = $student->value;
return 0 unless defined $v;
return 0 unless $v == int($v);
return ($v >= 1 && $v <= 5) ? 1 : 0;
}
);
# Switch back to String for the rest of the problem display/inputs
Context("String");
# =======================================================
# Scaffold
# =======================================================
Scaffold::Begin(
numbered => 1,
can_open => "when_previous_correct",
is_open => "correct_or_first_incorrect",
hardcopy_is_open => "always",
);
# -------------------------------------------------------
Section::Begin("Problem Statement");
BEGIN_TEXT
A bag contains 12 white marbles and 8 black marbles.
$PAR
You will draw two marbles, one after the other, with replacement.
END_TEXT
Section::End();
# -------------------------------------------------------
Section::Begin("Build the definitions");
BEGIN_TEXT
For each blank, choose the best option by typing its letter (A, B, or C).
$PAR
Build the definition of a <b>random experiment</b>:
$BR
A random experiment in probability is a (1) ____ procedure or process that can be (2) ____,
has (3) ____ possible outcomes, but whose specific result cannot be predicted with (4) ____ beforehand,
though the set of all possible outcomes (the (5) ____) is known.
$PAR
(1)
$BR
A) random B) well-defined C) unclear
$BR
Answer: \{ ans_rule(2) \}
$PAR
(2)
$BR
A) ignored B) repeated C) guessed
$BR
Answer: \{ ans_rule(2) \}
$PAR
(3)
$BR
A) one B) none C) multiple
$BR
Answer: \{ ans_rule(2) \}
$PAR
(4)
$BR
A) certainty B) luck C) noise
$BR
Answer: \{ ans_rule(2) \}
$PAR
(5)
$BR
A) trial B) sample space C) event
$BR
Answer: \{ ans_rule(2) \}
$PAR
Each performance of the experiment is called a (6) ____.
$BR
A) event B) trial C) outcome
$BR
Answer: \{ ans_rule(2) \}
$PAR
The sample space is the (7) ____ of all possible outcomes.
$BR
A) set B) formula C) number
$BR
Answer: \{ ans_rule(2) \}
$PAR
An event is a (8) ____ of the sample space.
$BR
A) average B) equation C) subset
$BR
Answer: \{ ans_rule(2) \}
$PAR
We say an event (9) ____ when the observed outcome is in that event.
$BR
A) occurred B) repeated C) vanished
$BR
Answer: \{ ans_rule(2) \}
END_TEXT
ANS( str_cmp("B") ); # (1) well-defined
ANS( str_cmp("B") ); # (2) repeated
ANS( str_cmp("C") ); # (3) multiple
ANS( str_cmp("A") ); # (4) certainty
ANS( str_cmp("B") ); # (5) sample space
ANS( str_cmp("B") ); # (6) trial
ANS( str_cmp("A") ); # (7) set
ANS( str_cmp("C") ); # (8) subset
ANS( str_cmp("A") ); # (9) occurred
Section::End();
# -------------------------------------------------------
Section::Begin("Identify the random experiment");
BEGIN_TEXT
Which option correctly describes the random experiment for this situation?
$PAR
A) Draw a marble, replace it, draw again, and record the ordered pair of colors (first, second).
$BR
B) Draw two marbles without replacement and record only the final color.
$BR
C) Shake the bag and predict the color without drawing.
$PAR
Answer (A/B/C): \{ ans_rule(2) \}
END_TEXT
ANS( str_cmp("A") );
Section::End();
# -------------------------------------------------------
Section::Begin("Construct the sample space");
BEGIN_TEXT
We will use W for white and B for black.
$PAR
Example: First draw is white and second draw is black is written as WB.
$PAR
Enter the sample space outcomes as a comma-separated list. Order does not matter.
$PAR
S = { \{ ans_rule(30) \} }
END_TEXT
ANS( $correctS->cmp(ignoreOrder => 1) );
Section::End();
# -------------------------------------------------------
Section::Begin("Define an event");
BEGIN_TEXT
Let E be the event: "Exactly one black marble is drawn."
$PAR
Enter the outcomes in E as a comma-separated list. Order does not matter.
$PAR
E = { \{ ans_rule(20) \} }
END_TEXT
ANS( $correctE->cmp(ignoreOrder => 1) );
Section::End();
# -------------------------------------------------------
Section::Begin("Which event occurred?");
BEGIN_TEXT
Suppose the observed outcome is WB.
$PAR
Which one of the events below occurred?
$PAR
A) At least one white marble was drawn.
$BR
Set form: { WW, WB, BW }
$PAR
B) Both marbles drawn were black.
$BR
Set form: { BB }
$PAR
C) Both marbles drawn were white.
$BR
Set form: { WW }
$PAR
D) The first draw was black.
$BR
Set form: { BW, BB }
$PAR
Answer (A/B/C/D): \{ ans_rule(2) \}
END_TEXT
ANS( str_cmp("A") );
Section::End();
# ----------------------------------------------------------------
# PILOT RATING (ACTIVE)
# ----------------------------------------------------------------
if ($ENABLE_GP_RATING) {
Section::Begin("Feedback");
BEGIN_TEXT
Rate the usefulness of this guided problem on a scale from 1 to 5.
$PAR
(1 = not useful, 2 = slightly useful, 3 = useful, 4 = very useful, 5 = extremely useful)
$BR
Note: Consider using the Email Instructor button below to suggest improvements.
$PAR
Rating: \{ ans_rule(6) \}
END_TEXT
Context("Numeric");
ANS($cmp_rating);
Context("String");
Section::End();
}
Scaffold::End();
ENDDOCUMENT();