The specific problem I am having is that after I have successfully used the weighted problem grader, somehow the if-else conditional is grabbing only the first condition, regardless of what the given condition is for the if-else assignment for $ans3 and $popup3ans:
# DESCRIPTION Function translations
# Translate descriptions of critical points and function
# into correct notation.
# WeBWorK problem written by TimPayer <tsp1@humboldt.edu>
# ENDDESCRIPTION
## DBsubject(Probability)
## DBchapter(Random variables)
## DBsection(Expectation)
## Institution(Humboldt State University)
## Author(Tim Payer)
## KEYWORDS(probability, translate, notation)
DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGunion.pl",
"MathObjects.pl",
"parserPopUp.pl",
"PGML.pl",
"PGcourse.pl",
"weightedGrader.pl"
);
install_weighted_grader();
#Text(beginproblem()); #uncomment
install_problem_grader(~~&std_problem_grader);
$showPartialCorrectAnswers = 1;
Context("Numeric");
Context()->flags->set(
tolerance => 0.0001,
tolType => "absolute",
);
# create three arrays of the same length "in parallel"
# Using "hashes":
$bird = list_random('goose', 'crow', 'starling', 'penguin','quail','hawk','finch','parrot', 'woodpecker', 'dove','lark', 'swallow', 'sparrow', 'stork','peacock', 'owl', 'jay', 'chicken', 'turtledove', 'turkey', 'magpie', 'raven', 'nightingale', 'snipe', 'heron', 'mallard', 'duck', 'pheasant', 'coot', 'plover');
%birds = (goose=>'geese', crow=>'crows', starling=>'starlings', penguin=>'penguins', quail=>'quails',hawk=>'hawks', finch=>'finches', parrot=>'parrots', woodpecker=>'woodpeckers', dove=>'doves', lark=>'larks',swallow=>'swallows', sparrow=>'sparrows', stork=>'storks', peacock=>'peacocks', owl=>'owls', jay=>'jays', chicken=>'chickens', turtledove=>'turtledoves', turkey=>'turkeys', magpie=>'magpies', raven=>'ravens', nightingale=>'nightingales', snipe=>'snipes', heron=>'herons' , mallard=>'mallards', duck=>'ducks', pheasant=>'pheasants', coot=>'coots', plover=>'plovers' );
%flock= (goose=>'gaggle', crow=>'murder', starling=>'murmuration', penguin=>'colony', quail=>'bevy',hawk=>'cast',finch=>'charm', parrot=>'company',woodpecker=>'descent', dove=>'dole', lark=>'exaltation', swallow=>'flight', sparrow=>'host', stork=>'muster', peacock=>'ostentation', owl=>'parliament', jay=>'party', chicken=>'peep', turtledove=>'pitying', turkey=>'rafter', magpie=>'tidings', raven=>'unkindness', nightingale=>'watch', snipe=>'wisp', heron=>'siege', mallard=>'sord', duck=>'raft', pheasant=>'nye', coot=>'cover', plover=>'congregation');
#@bird = ('goose','crow','starling'); ##This format needs Version 11 or better.
#@birds = ('geese','crows','starlings');
#@flock = ('gaggle','murder','murmuring');
#$i = random(0, 2, 1); # choose an array index at random
$popup1 = PopUp(
["probability notation", "P(V = 0)", "P(V = 1)", "P(V = 2)", "P(V > 0)", "P(V > 1)","P(V < 2)",], "P(V = 2)");
$popup2 = PopUp(
["probability notation", "P(V = 0)", "P(V = 1)", "P(V = 2)", "P(V > 0)", "P(V > 1)","P(V < 2)",], "P(V > 0)");
$popup4 = PopUp(
["draws?", "one", "two", "three",], "two");
$popup5 = PopUp(
["draws?", "one", "two", "three",], "three");
#$v = random(6,28,1);
$v = 17;
$ans1 =Compute("$v*$v/10000");
$ans2 = Compute("1-(1-$v/100)**2");
#$ev = random(0,3,1)
$event = list_random('more than one', 'at least one', 'at most one', 'not every');
#$event = "blank";
if($event == "more than one" )
{
$ans3=Compute("($v/100)**2*(3-2*$v/100)");
$popup3ans = "P(V > 1)";
#$event = "more than one";
} elsif ($event = "at least one")
{
$ans3=Compute("1-(1-$v/100)**3");
$popup3ans = "P(V > 0)";
#$event = "at least one";
} elsif ($event = "at most one")
{
$ans3=Compute("(1+2*$v/100)*(1-$v/100)**2");
$popup3ans = "P(V < 2)";
#$event = "at most one";
} else
{
$ans3=Compute("1-($v/100)**3");
$popup3ans = "P(V < 3)";
#$event = "not every";
}
# } elsif ($event == "not every") {
#$ans3=Compute("1-($v/100)**3");
#$popup3ans = "P(V < 3)";
#}
$popup3 = PopUp(
["probability notation", "P(V = 0)", "P(V = 1)", "P(V = 2)", "P(V = 3)","P(V > 0)", "P(V > 1)","P(V < 2)","P(V < 3)",], $popup3ans);
#[___]{$popup1} = [______]{$ans1}
BEGIN_PGML
4.1) The specific name for a flock of [@$birds{$bird}@] is described as a "[@$flock{$bird}@]" of [@$birds{$bird}@].
Consider the case where [$v]% of a [@$flock{$bird}@] of [@$birds{$bird}@] carry a bird flu virus. If two [@$birds{$bird}@] are drawn at random from the [@$flock{$bird}@], find the following probabilities but first complete the following event variable declaration:
Let V = The number of [@$birds{$bird}@] with the bird flu virus taken from [$popup4->menu]* random draw(s) from the [@$flock{$bird}@].
4.1a.) What is the probability of randomly drawing two [@$birds{$bird}@] from the [@$flock{$bird}@] that both have the bird flu virus? Choose the correct probability notation below and then calculate its associated probability with fourth decimal accuracy.
[$popup1->menu]* = [____]
4.1b.) What is the probability of randomly drawing two [@$birds{$bird}@] such that at least one [$bird] has the bird flu virus? Choose the correct probability notation below and then calculate its associated probability with fourth decimal accuracy.
Hint: Let N = the event of a [$bird] not having the bird flu virus. Then construct a sample space of all the possible combinations of V and N.
[$popup2->menu]* = [____]
4.1c.) Consider the case where three [@$birds{$bird}@] are drawn at random from the [@$flock{$bird}@]. What is the probability that [$event] [$bird] has the bird flu virus? First complete the declaration of the event variable below:
Let V = The number of [@$birds{$bird}@] with the bird flu virus taken from [$popup5->menu]* random draw(s) from the [@$flock{$bird}@].
Choose the correct probability notation below and then calculate its associated probability with fourth decimal accuracy. Hint: Let N = the event of a [$bird] not having the bird flu virus. Then construct a sample space of all the possible combinations of V and N.
[$popup3->menu]* = [____]
END_PGML
#These weighted values cause errors:
WEIGHTED_ANS( ($popup4)->cmp, 2 );
WEIGHTED_ANS( ($popup1)->cmp, 8 );
WEIGHTED_ANS( ($ans1)->cmp, 14 );
WEIGHTED_ANS( ($popup2)->cmp, 8 );
WEIGHTED_ANS( ($ans2)->cmp, 24 );
WEIGHTED_ANS( ($popup5)->cmp, 2 );
WEIGHTED_ANS( ($popup3)->cmp, 8 );
WEIGHTED_ANS( ($ans3)->cmp, 34 );
# Original form before using popups in PGML
#WEIGHTED_ANS( ($popup4)->cmp(), 2 );
#WEIGHTED_ANS( ($popup1)->cmp(), 8 );
#WEIGHTED_ANS( ($ans1)->cmp(), 14 );
#WEIGHTED_ANS( ($popup2)->cmp(), 8 );
#WEIGHTED_ANS( ($ans2)->cmp(), 24 );
#WEIGHTED_ANS( ($popup5)->cmp(), 2 );
#WEIGHTED_ANS( ($popup3)->cmp(), 8 );
#WEIGHTED_ANS( ($ans3)->cmp(), 32 );
BEGIN_PGML_SOLUTION
event = [$event]
popup3ans = [$popup3ans]
ans3 = [$ans3]
The correct answers are coming....in 2017, Hah!
END_PGML_SOLUTION
ENDDOCUMENT();