WeBWorK Problems

Preventing Numeric answer blanks from taking on PopUp prompts?

Preventing Numeric answer blanks from taking on PopUp prompts?

by tim Payer -
Number of replies: 1
Can you determine what is causing the prompts of "??" and "Choose" that normally appear within the PopUp prompts to now appear in numeric answer cells?

I would like for this glitch not to appear even though it does not affect the outcome of the answers upon submission.

If a student sees "Choose" she is likely to think that this answer does not require a numeric answer when in fact it does.

My code block is below...

Please help for any guidance...

Thanks Tim

##DESCRIPTION
##  Confidence intervals on mu and sigma
##  with interpretation of confidence.
##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",
"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",
);

## Problem 16.1 ##
## Fill 2 arrays (@imp, impaled and @liv, live) from random draws of specified ranges.
## Use a range of specified elements to fill each array ($ni, impaled and $nl, live)
## Join the elements of a given array ($ji and $jl) and display elements within a data table.
##

$ni=random(20,30,1);
@imp =();
foreach my $i (0..$ni-1) {
   $imp[$i] = random(15.0, 27.0, 0.1);
}

$ji = join(",   ", @imp);

$nl=random(79,96,1);
@liv =();
foreach my $i (0..$nl-1) {
   $liv[$i] = random(19.0, 30.0, 0.1);
}
$jl = join(",   ", @liv);

$meani = stats_mean(@imp);
$sdi = stats_sd(@imp);
$meani1 = sprintf("%0.1f",$meani);
$sdi1 = sprintf("%0.1f",$sdi);

$meanl = stats_mean(@liv);
$sdl = stats_sd(@liv);
$meanl1 = sprintf("%0.1f",$meanl);
$sdl1 = sprintf("%0.1f",$sdl);

############Start Problem 16.2  ##################

$xbg = random(4.2, 8.3, 0.1);
$xbb = random(3.2, 5.3, 0.1);
$sdg = random(0.5, 1.2, 0.1);
$sdb = random(0.3, 0.9, 0.1);
#$ng = random(21, 35, 0.1);
#$nb = random(21, 35, 0.1);
$ng =35;
$nb =35;



#$df = Compute("($sdg**2/$ng+$sdb**2/$nb)**2/(($sdg**2/$ng)**2/($ng-1)+($sdb**2/$nb)**2/($nb-1)");
## Could not find the "syntax error" above in the expanded form, used variables below:
$dfn =Compute("($sdg**2/$ng+$sdb**2/$nb)**2");
$dfd1 =Compute("($sdg**2/$ng)**2/($ng-1)");
$dfd2 =Compute("(($sdb**2/$nb)**2)/($nb-1)");
$df = Compute("$dfn/($dfd1+$dfd2)");
$dff1 = floor($df);
$dff =Compute("$dff1");




## HW 16.2 find t-criticals for 20 <df < 35 and 7 columns of alpha in t-table
## Note that if any of these random draws result in df calculations that are < 20
##  or > 69 that the student will be marked wrong incorrectly. However I have made 
## sample df calculation at all extremes and all fall safely within these bounds.
## Break the if then condition into two conditions each requiring a different 
## calculation for a CI on the difference of means.


$conf = list_random(60, 80, 90, 95, 98, 99, 99.9);  

if($conf == 60){
   if($dff==20) {
   $tint = 0.85996;
   } elsif($dff==21) {
   $tint = 0.85907;
   } elsif($dff==22) {
   $tint = 0.85827;
   } elsif($dff==23) {
   $tint = 0.85753;
   } elsif($dff==24) {
   $tint = 0.85686;
   } elsif($dff==25) {
   $tint = 0.85624;
   } elsif($dff==26) {
   $tint = 0.85567;
   } elsif($dff==27) {
   $tint = 0.85514;
   } elsif($dff==28) {
   $tint = 0.85465;
   } elsif($dff==29) {
   $tint = 0.85419;
   } elsif($dff==30) {
   $tint = 0.85377;
   } elsif($dff==40) {
   $tint = 0.85070;
   } elsif($dff==50) {
   $tint = 0.84887;
   } else {
   $tint = 0.84765;
   } 
} if($conf == 80){
   if($dff==20) {
   $tint = 1.32533;
   } elsif($dff==21) {
   $tint = 1.32320;
   } elsif($dff==22) {
   $tint = 1.32125;
   } elsif($dff==23) {
   $tint = 1.31944;
   } elsif($dff==24) {
   $tint = 1.31783;
   } elsif($dff==25) {
   $tint = 1.31636;
   } elsif($dff==26) {
   $tint = 1.31497;
   } elsif($dff==27) {
   $tint = 1.31369;
   } elsif($dff==28) {
   $tint = 1.31253;
   } elsif($dff==29) {
   $tint = 1.31142;
   } elsif($dff==30) {
   $tint = 1.31038;
   } elsif($dff==40) {
   $tint = 1.30308;
   } elsif($dff==50) {
   $tint = 1.29868;
   } else {
   $tint = 1.29581;
   } 
} if($conf == 90){
   if($dff==20) {
   $tint = 1.72474;
   } elsif($dff==21) {
   $tint = 1.72074;
   } elsif($dff==22) {
   $tint = 1.71715;
   } elsif($dff==23) {
   $tint = 1.71389;
   } elsif($dff==24) {
   $tint = 1.71087;
   } elsif($dff==25) {
   $tint = 1.70813;
   } elsif($dff==26) {
   $tint = 1.70563;
   } elsif($dff==27) {
   $tint = 1.70326;
   } elsif($dff==28) {
   $tint = 1.70112;
   } elsif($dff==29) {
   $tint = 1.69911;
   } elsif($dff==30) {
   $tint = 1.69724;
   } elsif($dff==40) {
   $tint = 1.68386;
   } elsif($dff==50) {
   $tint = 1.67589;
   } else {
   $tint = 1.67065;
   } 
} if($conf == 95){
   if($dff==20) {
   $tint = 2.0860;
   } elsif($dff==21) {
   $tint = 2.0796;
   } elsif($dff==22) {
   $tint = 2.0739;
   } elsif($dff==23) {
   $tint = 2.0687;
   } elsif($dff==24) {
   $tint = 2.0639;
   } elsif($dff==25) {
   $tint = 2.0595;
   } elsif($dff==26) {
   $tint = 2.0556;
   } elsif($dff==27) {
   $tint = 2.0519;
   } elsif($dff==28) {
   $tint = 2.0484;
   } elsif($dff==29) {
   $tint = 2.0452;
   } elsif($dff==30) {
   $tint = 2.0423;
   } elsif($dff==40) {
   $tint = 2.0211;
   } elsif($dff==50) {
   $tint = 2.0085;
   } else {
   $tint = 2.0003;
   } 
} if($conf == 98){
   if($dff==20) {
   $tint = 2.5280;
   } elsif($dff==21) {
   $tint = 2.5176;
   } elsif($dff==22) {
   $tint = 2.5083;
   } elsif($dff==23) {
   $tint = 2.4999;
   } elsif($dff==24) {
   $tint = 2.4921;
   } elsif($dff==25) {
   $tint = 2.4851;
   } elsif($dff==26) {
   $tint = 2.4786;
   } elsif($dff==27) {
   $tint = 2.4727;
   } elsif($dff==28) {
   $tint = 2.4771;
   } elsif($dff==29) {
   $tint = 2.4620;
   } elsif($dff==30) {
   $tint = 2.4573;
   } elsif($dff==40) {
   $tint = 2.4232;
   } elsif($dff==50) {
   $tint = 2.4033;
   } else {
   $tint = 2.3902;
   } 
} if($conf == 99){
   if($dff==20) {
   $tint = 2.8453;
   } elsif($dff==21) {
   $tint = 2.8314;
   } elsif($dff==22) {
   $tint = 2.8187;
   } elsif($dff==23) {
   $tint = 2.8074;
   } elsif($dff==24) {
   $tint = 2.7969;
   } elsif($dff==25) {
   $tint = 2.7874;
   } elsif($dff==26) {
   $tint = 2.7787;
   } elsif($dff==27) {
   $tint = 2.7707;
   } elsif($dff==28) {
   $tint = 2.7633;
   } elsif($dff==29) {
   $tint = 2.7564;
   } elsif($dff==30) {
   $tint = 2.7500;
   } elsif($dff==40) {
   $tint = 2.7045;
   } elsif($dff==50) {
   $tint = 2.6778;
   } else {
   $tint = 2.6604;
   } 
} if($conf == 99.9){
   if($dff==20) {
   $tint = 3.849;
   } elsif($dff==21) {
   $tint = 3.819;
   } elsif($dff==22) {
   $tint = 3.792;
   } elsif($dff==23) {
   $tint = 3.768;
   } elsif($dff==24) {
   $tint = 3.745;
   } elsif($dff==25) {
   $tint = 3.725;
   } elsif($dff==26) {
   $tint = 3.707;
   } elsif($dff==27) {
   $tint = 3.690;
   } elsif($dff==28) {
   $tint = 3.674;
   } elsif($dff==29) {
   $tint = 3.659;
   } elsif($dff==30) {
   $tint = 3.646;
   } elsif($dff==40) {
   $tint = 3.551;
   } elsif($dff==50) {
   $tint = 3.496;
   } else {
   $tint = 3.460;
   } 
}
$tin =Compute("$tint");  # Converting $tint into a math object..
$tint =$tin;


###  Prob 16.2b: tint CI on u  ####
#$lbt = Compute("$xbg-$xbb - $tint*sqrt($sdg**2/$ng+$sdb**2/$nb)");
#$ubt =  Compute("$xbg-$xbb + $tint*sqrt($sdg**2/$ng+$sdb**2/$nb)");

$lbt = Compute("-2.6857");
$ubt = Compute("2");

###  Prob 16.2c: tint CI on u  ####
## Interpret the bounds of the CI in a sentence.

if($lbt < 0 && $ubt > 0){
   $dec = "does not";
   $lbs = abs($lbt);
   $lbday = "shorter";
   $ubs = $ubt;
   $ubday = "longer";
   } elsif ($lbt < 0 && $ubt < 0){
   $dec ="does";
   $lbs = abs($lbt);
   $lbday = "shorter";
   $ubs = abs($ubt);
   $ubday = "shorter";
   } else {
   $dec ="does";
   $lbs = $lbt;
   $lbday = "longer";
   $ubs = $ubt;
   $ubday = "longer";
   } 

$pop1 = PopUp(
["Choose", 'does', 'does not'], $dec);

$popdl = PopUp(
["??", 'shorter', 'longer'], $lbday);
$popdu = PopUp(
["??", 'shorter', 'longer'], $ubday);

$pop2 = PopUp(
["??", 'longer', 'shorter', 'not significantly different'],'shorter');
$ablbt =abs($lbt);
$abubt =abs($ubt);



###  Prob 16.2d: interpretation of confidence on 2 mu  ####

$pop3 = PopUp(
["Choose:",  'all lead times', 'random samples', 'sample proportions', 'the true mean', 'sample means' ], 'random samples');

$pop4 = PopUp(
["Choose:",  'exist within', 'have a mean difference of lead times that fall within', 'show agreement with', 'form confidence intervals that contain', 'contains the true mean lead time as in' ], 'form confidence intervals that contain');

$pop5 = PopUp(
["Choose:",  'true proportion of lead times', 'true difference of mean lead times', 'sample proportion of horn lengths', 'true mean lead time', ' '.$conf.'% confidence interval that we have calculated' ], 'true difference of mean lead times');

####  Begin Problem...

 
BEGIN_PGML 
   *Drawn from Lecture Notes: Week 8 Day 2.*  

END_PGML 

BEGIN_TEXT
$PAR
\{
DataTable(
[
["$BBOLD 16.2) $EBOLD   Violet green swallows, $BITALIC Tachycineta thalassina$EITALIC, arrive in Humboldt county in late March, while barn swallows, $BITALIC Hirundo rustica$EITALIC, tend to arrive during the first few weeks of April. However for both species the males arrive a number of days before their female mates. Given that a long time resident of Humboldt county has kept meticulous records of the lead time in the number of days for which a male swallow arrived in Humboldt county before its mate, is there a significant difference in the lead time arrival in days for the male swallow between the two species? Use a $conf% interval to determine your answer. The summarized data of the male lead time in days for both species are shown in the table below. ",'  ',[image( "MikeDanzenbaker.png", width=>285, height=>353, tex_size=>700 ) .$BR."image by Mike Danzenbaker".$BR.image( "WikipediaVGS.png", width=>935, height=>625, tex_size=>700 ).$BR."Image by Wikipedia" ] ,image( "EugeneBeckesCC3.png", width=>537, height=>598, tex_size=>700 ).$BR."image by Eugene Beckes".$BR.image( "EugeneBeckesCC.png", width=>500, height=>421, tex_size=>700 ).$BR."image by Eugene Beckes",]
  ], 
  caption => 'A comparison of images of the male violet green swallow and barn swallow. ',
  midrules=>0, 
  align => 'p{3.5in} p{0.1in} p{2.5in}p{2.5in}'
);
\}
$PAR
\{
DataTable(
[
[[' Violet green $BR swallow', headerrow => 1],'Barn $BR swallow ',],
[['\(\bar x_1\) = $xbg $BR \(\text{sd}_1\) = $sdg $BR \(\text{n}_1\) = $ng' ],'\(\bar x_2\) = $xbb $BR \(\text{sd}_2\) = $sdb $BR \(\text{n}_2\) = $nb'],
], 
caption => ' A comparison between two species of swallows on the lead time in days that the male swallow arrives in Humboldt county before their respective mates.',
midrules => 1,
align => '|p{1.8in}|p{1.8in}|',
);
\}
$BR
$PAR

END_TEXT

BEGIN_PGML 
*16.2)*  Create a [$conf]% confidence interval for the difference of means in the lead time in days for which males arrive before their respective mates for both species of swallow. Use second decimal accuracy.

*16.2a)*  Calculate for the degrees of freedom and the associated t-critical value for this confidence interval accurate to the second decimal:  
 
df = [_______]

Round your df value down to the next available integer value in the t-table:

t-table df = [_______]
 
Determine the associated t-critical value for a [$conf]% confidence interval on the difference of means.  
 
t-critical =  [_______]
 

*16.2b)*  Calculate the [$conf]% confidence interval on the difference of means in the lead time in days for which males arrive before their respective mates for both species of swallow. Use second decimal accuracy:  
 
[`` = \Large{(\,}``] [_______] [`` \Large{, \,}``] [_______] [``  \Large{)} \text{days}``]  
 
 
*16.2c)*   Does the [$conf]% confidence interval on the difference of the mean male to mate lead time in days show a significant difference between the species of swallows? Explain by completing the following sentences using the bounds of the confidence interval to make your case.  
 
The [$conf]% confidence interval [$pop1->menu]*  support the claim that there is a significant difference in the male to mate lead time between both species of swallows. Male violet green swallows tend to have a lead lead time on their prospective mates that is anywhere from [______] days [$popdl->menu]* to  [______] days [$popdu->menu]* than the lead times for male barn swallows over their respective mates.
 
 
*16.2d)*   Interpret the meaning of the [$conf]% confidence in the context of this problem. If the confidence level can be read as a probability, then there is a [$conf]% chance that what event will occur?  Select the phrase in the next three cells that will form the correct interpretation for the meaning of confidence in the context of both data sets for the mean lead time in days for which a male swallow arrives in Humboldt county ahead of its mate.  
 
[$conf]% confidence means that [$conf]% of [$pop3->menu]* for the lead time in days that a male swallow will arrive in Humboldt county before it mate will [$pop4->menu]* the [$pop5->menu]* between the two swallow populations.


DF = [$dff]  
ng = [$ng]  
nb = [$nb]  
lbt = [$lbt]  
ubt = [$ubt]  
lbs = [$lbs]  
ubs = [$ubs]  


END_PGML

#Adapted weighted answers values:  

## Problems 12.2 ##

WEIGHTED_ANS( ($df)->cmp, 8 );
WEIGHTED_ANS( ($dff)->cmp, 4 );
WEIGHTED_ANS( ($tint)->cmp, 8 );

WEIGHTED_ANS( ($lbt)->cmp, 10 );
WEIGHTED_ANS( ($ubt)->cmp, 10 );

WEIGHTED_ANS( ($pop1)->cmp, 4 );
WEIGHTED_ANS( ($lbs)->cmp, 10 );
WEIGHTED_ANS( ($popdl)->cmp, 4 );
WEIGHTED_ANS( ($ubs)->cmp, 10 );
WEIGHTED_ANS( ($popdu)->cmp, 4 );


WEIGHTED_ANS( ($pop3)->cmp, 8 );
WEIGHTED_ANS( ($pop4)->cmp, 8 );
WEIGHTED_ANS( ($pop5)->cmp, 8 );

BEGIN_PGML_SOLUTION


The correct answers are coming....in 2017, Hah!



END_PGML_SOLUTION

ENDDOCUMENT();
In reply to tim Payer

Re: Preventing Numeric answer blanks from taking on PopUp prompts?

by tim Payer -
I think I over-reacted with this last post.

It has been corrected.

I had switched the order with weighted answers and though I corrected for this error I saw the lingering prompts of "??" and "Choose" from the popups being imposed as initial answers for the numeric entry cells.

This was just webwork holding on to these values as previous entry for these cells. A simple write overreplaced these prompts.

Thanks, Tim