Greetings Webwork Forum!

Am I wrong to include possible Popup answers in an if-else condition?

I am not clear on the meaning of the error message response of:

The correct choice must be one of the PopUp menu items at line 2 of (eval 6952)

` Died within Value::Error called at line 100 of [PG]/macros/parserPopUp.pl`

` from within parser::PopUp::new called at line 2 of (eval 6952)`

` from within main::PopUp called at line 67 of (eval 6714)`

Does this mean that the if-else conditions were not met that there would be no assignment of an answer for PopUp3 ? Or is there an advisement against using PopUp answers within if-else conditions?

Thanks for any guidance you can share with me,

Tim

Here is the code block:

# DESCRIPTION Probability calculation.

# Use correct notation and sample space

# to find the answer from two, and then three random draws.

# 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",

);

#Text(beginproblem()); #uncomment

install_problem_grader(~~&std_problem_grader);

$showPartialCorrectAnswers = 1;

Context("Numeric");

# create three arrays of the same length "in parallel"

# Using "hashes" we have 30 word triplets coordinating the names of

# singular, plural forms for a given bird with its flock name.

$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');

$event = list_random('more than one', 'at least one', 'at most one', 'not every');

#@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(9,49,1);

$ans1 =Compute("$v*$v/100");

$ans2 = Compute("(2*$v-$v*$v)/100");

if($event == "more than one"){

$ans3 =$v**2*(3-2*$v);

$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)"], "P(V > 1)");

} elsif ($event == "at least one") {

$ans3=1-(1-$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)"], "P(V > 0)");

} elsif ($event == "at most one") {

$ans3=(1+2*$v)*(1-$v)**2;

$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)"], "P(V < 2)");

} elsif ($event == "not every") {

$ans3=1-$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)"], "P(V < 3)");

}

# problems with if-then for 1c depending on Popups

BEGIN_PGML

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} random draw(s) from the [@$flock{$bird}@].

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} = [______]{$ans1}

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} = [______]{$ans2}

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} 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} = [______]{$ans3}

END_PGML

BEGIN_PGML_SOLUTION

The correct answers are coming....:

END_PGML_SOLUTION

ENDDOCUMENT();