I am using popups with postFilter answerHints within a NAMED_WEIGHTED_ANS scheme.
As long as I use strings values within the popups the answerHints work beautifully, but numeric values apparently require a different syntax that I am lost as to how to find. Either this or there is another error that is preventing the answerHints from displaying.
Below is the troublesome block of code. The entire problem is posted at the end. The answerHint for '80%' will display when selected, but none of the other possible popup selections will display. They remain non-responsive with and without single quotes. And there are no error messages that accompany a run of the HW problem.
Could you please reveal to me my error in syntax?
Thank you so much. The feedback to student for likely errors is most helpful to students.
NAMED_WEIGHTED_ANS(pnot => $popup6->cmp->withPostFilter(
AnswerHints(
'0'=>"The proportion is not zero.",
Compute("$phat")=>"Sample data should not be used in the hypothesis statement.",
'80%'=>"Percents are not the same as proportions.",
'0.80'=>"Yes.",
)), 7 );
##DESCRIPTION
## Hypothesis test on one proportion.
##ENDDESCRIPTION
##KEYWORDS('confidence interval', 'confidence interpretation')
## DBsubject('Statisitics')
## DBchapter('confidence intervals')
## DBsection('Real Numbers')
## Date('11/7/2016')
## Author('Tim Payer')
# DESCRIPTION CI on mu for t-intervals and Chi-intervals
# Find the associated probability given mu and sigma.
# Use 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",
"PGnumericalmacros.pl",
"PGstatisticsmacros.pl",
"MathObjects.pl",
"parserPopUp.pl",
"PGML.pl",
"unionTables.pl",
"niceTables.pl",
"PGcourse.pl",
"PGchoicemacros.pl",
"answerHints.pl",
"weightedGrader.pl"
);
install_weighted_grader();
#Text(beginproblem()); #uncomment
install_problem_grader(~~&std_problem_grader);
$showPartialCorrectAnswers = 1;
Context("Numeric");
Context()->flags->set(
tolerance => 0.01,
tolType => "absolute",
);
### Prob 14B.1) ########
$po = 0.8;
$n = random(65, 110,1);
$dd = random(0.60, 0.80, 0.01) ;
$y1 = floor($n*$dd);
$y = Compute("$y1");
$phat1 =$y/$n;
$phat = sprintf("%0.4f",$phat1);
#$phat1 =Compute("$phat2");
$fat ="\frac{$y}{$n}";
$pnp = Compute("$po*$n*(1-$po)");
$zsam =Compute("($phat-$po)/sqrt($po*(1-$po)/$n)");
$alfa = list_random('10%', '5%', '1%', '0.5%', '0.01%', '0.005%', '0.001%');
$popup0 = PopUp(
["Choose:", 'has', 'does not have' ], 'has');
$popup1 = PopUp(
["?", '=', 'not =', ' < ', ' >', '< or =', '> or =' ], '> or =');
$popup13 = PopUp(
["Choose:", 'mu', 'eta', 'p', 'sigma', 'x-bar' ,'x-tilde', 'p-hat', 'sd' ], 'mu');
$popup2 = PopUp(
["Choose:", 'mean', 'median', 'proportion', 'variance', 'standard deviation','percentage'], 'proportion');
$popup3 = PopUp(
["Choose:", 'survive.', 'die.', 'survive will exceed 80%.', 'die will exceed 80%.', 'survive will be about 80%.', 'die will be about 80%.', 'survive will be less than 80%.', 'die will be less than 80%.', 'survive will exceed '.$phat.'.', 'die will exceed '.$phat.'.', 'survive will be about '.$phat.'.', 'die will be about '.$phat.'.', 'survive will be less than '.$phat.'.', 'die will be less than '.$phat.'.'], 'die.');
$popup4 = PopUp(
["Choose:", 'mu', 'eta', 'p', 'sigma', 'x-bar' ,'x-tilde', 'p-hat', 'sd' ], 'p');
$popup5 = PopUp(
["Choose:", '=', 'not =', '< ', '>', '< or =', '> or =' ], '=');
$popup6 = PopUp(
["Choose:", '0', $phat1, '80%', '0.80'], '0.80');
$popup7 = PopUp(
["Choose:", 'mu', 'eta', 'p', 'sigma', 'x-bar' ,'x-tilde', 'p-hat', 'sd' ], 'p');
$popup8 = PopUp(
["Choose:", '=', 'not =', '<', '>', '< or =', '> or =' ], '<');
$popup9 = PopUp(
["Choose:", '0', $phat, '80%', '0.80'], '0.80');
$poplos = PopUp(
["alpha ?", "0.20", "0.10", "0.05", "0.025", "0.02", "0.01", "0.005", "0.002", "0.001","0.0005", "0.0001", "0.00005", "0.00001", "0.000005"], '0.05');
$popup10 = PopUp(
["Choose:", 'upper tailed', 'lower tailed', 'two tailed'], 'upper tailed');
$popup11 = PopUp(
["?", '-', '+', '+ or -'], '+');
$popup12 = PopUp(
["Z-Critical?", "1.282", "1.645","1.960", "2.326", "2.576", "3.090", "3.291", "3.891", "4.491"], "1.645");
$pop14 = PopUp(
["LOS ??", "20%","10%", "5%", "2.5%", "2%", "1%", "0.5%", "0.2%", "0.1%", "0.05%", "0.01%", "0.005%", "0.001%", "0.0005%" ], "5%");
$pop15 = PopUp(
["reject ?", "reject", "do not reject"], "reject");
$pop16 = PopUp(
["?", ">", "<"], ">");
$pop17 = PopUp(
["?", ">", "<"], ">");
$pop18 = PopUp(
["?", "-", "+", "+ or -"], "+");
$pop19 = PopUp(
["Z-Critical?", "1.282", "1.645","1.960", "2.326", "2.576", "3.090", "3.291", "3.891", "4.491"], "1.645");
$pop20 = PopUp(
["?", ">", "<"], "<");
$pop21 = PopUp(
["which bracketed p-value?",
"(p > 0.20)","(p > 0.10)","(0.10 < p < 0.20)", "(0.05 < p < 0.10)", "(0.025 < p < 0.05)", "(0.02 < p < 0.05)", "(0.01 < p < 0.025)","(0.01 < p < 0.02)", "(0.005 < p < 0.01)", "(0.002 < p < 0.01)", "(0.001 < p < 0.005)", "(0.001 < p < 0.002)", "(0.0005 < p < 0.001)", "(0.0001 < p < 0.001)", "(0.00005 < p < 0.0005)", "(0.00001 < p < 0.0001)", "(0.000005 < p < 0.00005)","(p < 0.00001)", "(p < 0.000005)"], "(p < 0.000005)" );
$pop22 = PopUp(
["?", ">", "<"], "<");
$pop23 = PopUp(
["alpha ?", "0.20", "0.10", "0.05", "0.025", "0.02", "0.01", "0.005", "0.002", "0.001","0.0005", "0.0001", "0.00005", "0.00001", "0.000005"], "0.05");
$pop24 = PopUp(
["?", "decreased", "increased", "remained consistent with the incidence"], "increased");
#### Begin Problem...
BEGIN_PGML
*Drawn from Lecture Notes: Week 7 Day 3.*
*14B.2)* In Virginia the big eared bat's population has dropped to a near endangered level of 10,000 due to White Nose Syndrome (WNS). WNS is a fungus the grows on the bats nose and wing tips of the blighted bat and has a mortality rate of 80% for all bats who catch the fungus. In an effort to treat WNS, biologists dusted an anti-fungal powder on a random sample of [$n] bats with WNS and yet [$y] of these bats still died. Was the anti-fungal powder effective in reducing the mortality rate for the big eared bat? Test the hypothesis at the [$alfa] LOS.
fat = [`[$fat]`]
*14B.2) Step 1* Preliminary check on sample size.
Is [``n \cdot p_o(1-p_o) \ge 10``] ?
Then [``n \cdot p_o(1-p_o) ``] = [______] [$popup1->menu]* [``\Large{\text{10}}``]
We conclude that this data set [$popup0->menu]* an ample sample for hypothesis testing on one proportion.
END_PGML
BEGIN_TEXT
$PAR
\(\displaystyle{ $fat }\)
$PAR
\{
DataTable(
[
['$BBOLD Note! $EBOLD Because of the limitations in software most special characters can not be included in a "pop-up" answer format and yet they are needed for the hypothesis formation. The pop-up selections will be in the text-form for the special characters embedded within the pop-up answer. Use the table at the right as a guide if needed.',' ',[image( "Symbol_translation.png", width=>165, height=>290, tex_size=>700 ) ] ,image( "Z_Table.png", width=>235, height=>212, tex_size=>700 ),]
],
caption => 'English text equivalence with special symbols, and an abbreviated Z-table: ',
midrules=>0,
align => 'p{3in} p{0.1in} p{2in}p{3in}'
);
\}
$PAR
END_TEXT
BEGIN_PGML
*14B.2) Step 2* Make selections that will create the best declaration of variable for the biologist's hypothesis.
[$popup13->menu]* = The [$popup2->menu]* of bats with WNS treated with anti-fungal powder that [$popup3->menu("pdes")]*
*14B.2) Step 3* Make selections that will create the correct hypothesis and LOS statement for Sicher's hypothesis.
[``\Large{H_o:}``] [$popup4->menu]* [$popup5->menu]* [$popup6->menu("pnot")]*
[``\Large{H_a:}``] [$popup7->menu]* [$popup8->menu]* [$popup9->menu]*
[``\Large{\alpha =}``] [$poplos->menu]*
*14B.1) Step 4* The decision line for this hypothesis test is: [$popup10->menu]*
*14B.1) Step 5* The Z-critical value for this hypothesis test is:
Z-critical = [$popup11->menu]* [$popup12->menu]*
*14B.1) Step 6* The statistical conclusion for this hypothesis test is:
At the [$pop14->menu]* LOS we [$pop15->menu]* the null hypothesis of [``\large{H_o }``], because:
END_PGML
BEGIN_TEXT
$BR
$PAR
\{
DataTable(
[
[' Z Notational $BR Support: $BR $BR Numeric $BR Validation: ',' \(\hspace{10pt}\) \(\large{Z_{sample}}\) \(\hspace{2pt}\) '.$pop16->menu.' \(\hspace{2pt}\) \(\large{Z_{critical}}\) $BR $BR '.$zsam->ans_rule(5).' '.$pop17->menu.''.$pop18->menu.''.$pop19->menu.'' ],
],
caption => ' ',
midrules=>0,
align => 'p{1.2in}p{7in}'
);
\}
$PAR
\{
DataTable(
[
['p-Notational $BR Support: $BR $BR Numeric $BR Validation: ',' \(\hspace{115pt}\) \(\Large{p} \hspace{2pt}\) '.$pop20->menu.'\(\hspace{2pt} \Large{\alpha}\) $BR $BR '.$pop21->menu.''.$pop22->menu.''.$pop23->menu.'' ],
],
caption => ' ',
midrules=>0,
align => 'p{1.2in}p{7in}'
);
\}
$PAR
$BR
END_TEXT
BEGIN_PGML
*14B.1) Step 7* Write an English sentence conclusion.
The evidence supports the case that peanut allergies among children under 18 years of age has [$pop24->menu]* since 1997.
END_PGML
#Adapted weighted answers values:
## Problems 13.1 ##
WEIGHTED_ANS( ($pnp)->cmp, 7 );
WEIGHTED_ANS( ($popup1)->cmp, 1 );
WEIGHTED_ANS( ($popup0)->cmp, 1 );
WEIGHTED_ANS( ($popup13)->cmp, 4 );
WEIGHTED_ANS( ($popup2)->cmp, 4 );
NAMED_WEIGHTED_ANS(pdes => $popup3->cmp->withPostFilter(
AnswerHints(
"survive." => "No. Just what kind of rate is being measured?",
"die." => "Yes!",
"survive will exceed 80%." => "Survival rates are not sought, and do not restrict your variable declaration to a quantity.",
"die will exceed 80%." => "Do not restrict your variable declaration to a quantity.",
"survive will be about 80%." => "Survival rates are not sought, and do not restrict your variable declaration to a quantity.",
"die will be about 80%." => "Do not restrict your variable declaration to a quantity.",
"survive will be less than 80%." => "Survival rates are not sought, and do not restrict your variable declaration to a quantity.",
"die will be less than 80%." => "Do not restrict your variable declaration to a quantity.",
'survive will exceed '.$phat.'.' => "Survival rates are not sought, and do not restrict your variable declaration to a quantity.",
'die will exceed '.$phat.'.'=> "Do not restrict your variable declaration to a quantity.",
'survive will be about '.$phat.'.' => "Survival rates are not sought, and do not restrict your variable declaration to a quantity.",
'die will be about '.$phat.'.' => "Do not restrict your variable declaration to a quantity.",
'survive will be less than '.$phat.'.' => "Survival rates are not sought, and do not restrict your variable declaration to a quantity.",
'die will be less than '.$phat.'.' => "Do not restrict your variable declaration to a quantity.",
)), 7 );
WEIGHTED_ANS( ($popup4)->cmp, 4 );
WEIGHTED_ANS( ($popup5)->cmp, 1 );
NAMED_WEIGHTED_ANS(pnot => $popup6->cmp->withPostFilter(
AnswerHints(
'0'=>"The proportion is not zero.",
Compute("$phat")=>"Sample data should not be used in the hypothesis statement.",
'80%'=>"Percents are not the same as proportions.",
'0.80'=>"Yes.",
)), 7 );
WEIGHTED_ANS( ($popup7)->cmp, 3 );
WEIGHTED_ANS( ($popup8)->cmp, 3 );
WEIGHTED_ANS( ($popup9)->cmp, 4 );
WEIGHTED_ANS( ($poplos)->cmp, 1 );
WEIGHTED_ANS( ($popup10)->cmp, 4 );
WEIGHTED_ANS( ($popup11)->cmp, 2 );
WEIGHTED_ANS( ($popup12)->cmp, 4 );
WEIGHTED_ANS( ($pop14)->cmp, 1 );
WEIGHTED_ANS( ($pop15)->cmp, 4 );
WEIGHTED_ANS( ($pop16)->cmp, 1 );
WEIGHTED_ANS( ($zsam)->cmp, 16 );
WEIGHTED_ANS( ($pop17)->cmp, 2 );
WEIGHTED_ANS( ($pop18)->cmp, 3 );
WEIGHTED_ANS( ($pop19)->cmp, 4 );
WEIGHTED_ANS( ($pop20)->cmp, 2 );
WEIGHTED_ANS( ($pop21)->cmp, 7 );
WEIGHTED_ANS( ($pop22)->cmp, 1 );
WEIGHTED_ANS( ($pop23)->cmp, 3 );
WEIGHTED_ANS( ($pop24)->cmp, 3 );
BEGIN_PGML_SOLUTION
The correct answers are coming....in 2017, Hah!
END_PGML_SOLUTION
ENDDOCUMENT();