Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,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();
Loading