## WeBWorK Problems

### Answer blank syntax for weighted grader within a table

by tim Payer -
Number of replies: 2

Greetings,

At Davide Cervone's sugestion I used the format of

['text '.$pop7->menu.' text ' ] to embed popup answers with a weighted grader within a table. This worked beautifully. But I forgot to ask how to handle standard answer blanks under the same scenario. Can you please help me determine how standard answer blanks should be entered in a data table with a weighted grader? Attempts such as the one below fails. .$normp->menu.

Most appreciated, this is the missing piece.

Below is the code block

# DESCRIPTION

# Data type identification

# WeBWorK problem written by TimPayer <tsp1@humboldt.edu>

# ENDDESCRIPTION

## DBsubject(Statistics)

## DBchapter(Exploratory data analysis/descriptive statistics)

## DBsection(Summary statistics)

## Institution(Humboldt State University)

## Author(Tim Payer)

## KEYWORDS(summations, mean, sd)

DOCUMENT();

"PGstandard.pl",

"PGunion.pl",

"niceTables.pl",

"unionTables.pl",

"PGstatisticsmacros.pl",

"PGnumericalmacros.pl",

"MathObjects.pl",

"parserPopUp.pl",

"parserFormulaUpToConstant.pl",

"PGML.pl",

);

$showPartialCorrectAnswers = 1; Context("Numeric"); ### Begin Problem Q5.1 ########## # [$pop1->menu]*

#[$pop2->menu]* [________] [$pop3->menu]* [$pop4->menu]*$pop1 = PopUp(

["?", "is", "is not"], "is");

$pop2 = PopUp( ["?", "< ", ">"], ">");$pop3 = PopUp(

["?", "<", ">"], ">");

$pop4 = PopUp( ["LOS ?", "0.001"," 0.005", "0.01", "0.02","0.025", "0.05","0.10", "0.20"], "0.01");$pop5 = PopUp(

["?", "is", "is not"], "is");

$pop6 = PopUp( ["?", "A", "B","C", "D","E", "F"], "D"); Context()->flags->set( tolerance => 0.01, tolType => "absolute", );$conf = list_random(80, 90, 95, 98, 99, 99.9);

$normp =Compute("0.2881");$m = Compute("17.18182");

$sd = Compute("3.850001");$n =22; ## then df = 21 which is constant for now....

if($conf == 80){$zint = 1.282;

$tint = 1.32125; } if($conf == 90){

$zint = 1.645;$tint = 1.71715;

} if($conf == 95){$zint = 1.960;

$tint = 2.0739; } if($conf == 98){

$zint = 2.326;$tint = 2.5083;

} if($conf == 99){$zint = 2.576;

$tint = 2.8187; } if($conf == 99.9){

$zint = 3.291;$tint = 3.792;

}

###  Prob Q5.1: tint CI on u  ####

$lbt = Compute("$m - $tint*$sd/sqrt($n)");$ubt = Compute("$m +$tint*$sd/sqrt($n)");

###  Prob Q5.1: Z-int CI on u to trigger a warning about using wrong table. ####

#$lbz = Compute("$m - $zint*$sd/sqrt($n)"); #$ubz = Compute("$m +$zint*$sd/sqrt($n)");

### Begin Problem Q5.2  ##########

$n2 = random(14, 20,1);$conf2 = list_random(80, 90, 95, 98, 99, 99.9);

$comp1 =100-$conf2;

$comp =sprintf("%0.1f",$comp1);

if($conf2 == 80){$znt = 1.282;

if($n2==14) {$tnt = 1.35019;

} elsif($n2==15) {$tnt = 1.34502;

} elsif($n2==16) {$tnt = 1.34060;

} elsif($n2==17) {$tnt = 1.33677;

} elsif($n2==18) {$tnt = 1.33338;

} elsif($n2==19) {$tnt = 1.33036;

} else {

$tnt = 1.32775; } } if($conf2 == 90){

$znt = 1.645; if($n2==14) {

$tnt = 1.77094; } elsif($n2==15) {

$tnt = 1.76133; } elsif($n2==16) {

$tnt = 1.75307; } elsif($n2==17) {

$tnt = 1.74587; } elsif($n2==18) {

$tnt = 1.73962; } elsif($n2==19) {

$tnt = 1.73407; } else {$tnt = 1.72911;

}

} if($conf2 == 95){$znt = 1.960;

if($n2==14) {$tnt = 2.1604;

} elsif($n2==15) {$tnt = 2.1448;

} elsif($n2==16) {$tnt = 2.1315;

} elsif($n2==17) {$tnt = 2.1199;

} elsif($n2==18) {$tnt = 2.1098;

} elsif($n2==19) {$tnt = 2.1009;

} else {

$tnt = 2.0930; } } if($conf2== 98){

$znt = 2.326; if($n2==14) {

$tnt = 2.6503; } elsif($n2==15) {

$tnt = 2.6245; } elsif($n2==16) {

$tnt = 2.6025; } elsif($n2==17) {

$tnt = 2.5835; } elsif($n2==18) {

$tnt = 2.5669; } elsif($n2==19) {

$tnt = 2.5524; } else {$tnt = 2.5395;

}

} if($conf2 == 99){$znt = 2.576;

if($n2==14) {$tnt = 3.0123;

} elsif($n2==15) {$tnt = 2.9768;;

} elsif($n2==16) {$tnt = 2.9467;

} elsif($n2==17) {$tnt = 2.9208;

} elsif($n2==18) {$tnt = 2.8982;

} elsif($n2==19) {$tnt = 2.8784;

} else {

$tnt = 2.8610; } } if($conf2 == 99.9){

$znt = 3.291; if($n2==14) {

$tnt = 4.221; } elsif($n2==15) {

$tnt = 4.140; } elsif($n2==16) {

$tnt = 4.073; } elsif($n2==17) {

$tnt = 4.015; } elsif($n2==18) {

$tnt = 3.965; } elsif($n2==19) {

$tnt = 3.922; } else {$tnt = 3.883;

}

}

$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' );$birds = $birds{$bird};

$xbar = random(2.3, 4.8,0.1);$s = random(0.4, 0.8, 0.1);

$lbt2 = Compute("$xbar - $tnt*$s/sqrt($n2)");$ubt2 = Compute("$xbar +$tnt*$s/sqrt($n2)");

$column1 = PGML::Format(<<END_PGML); *Quiz Prep 5: Drawn From Lecture Notes: Week 6, Day 1.* *Q5.1)* As of 2016 the Center for Disease Control (CDC) estimates that the average number of antibiotic treatments (called courses) proscribed during the first twenty years of life for an American citizen will be at 17. A doctor of a small rural county hospital samples the medical records for 22 randomly drawn 20 year old patients to determine if the frequency of antibiotic courses of their 20 year old patients is consistent with the CDC's estimate. *Note!* The instructions on Quiz 5 will NOT prompt you to check for normality, you must know to check for normality if means are being used! The data is shown at the right and can also be accessed at the address below, or the link beneath the data set: users.humboldt.edu/tpayer/Stat_109 [\Rightarrow ] Data_Files [\Rightarrow ] antibio.csv *Note!* An abbreviated Z-table, a T-table and the following two lines of R-code that you see below will be attached to the back of the quiz 5 paper: *install.packages("nortest")* *library(nortest)* END_PGML$column2 =$BCENTER.$BR."Number of antibiotic courses per 20 year old:".$BR.image("course_bio.png", width=>94, height=>485, tex_size=>700).$BR."Find the URL at the following link:".$BR.htmlLink( "http://users.humboldt.edu/tpayer/Stat_109/Data%20Files/antibio.csv","Number_of_courses_data_set").$BR." ".$BR.$ECENTER;

TEXT(ColumnTable($column1,$column2));

BEGIN_TEXT

$PAR \{ image( "Z_Table_CI.png", width=>222, height=>224, tex_size=>700) \}$PAR

\{image("T_Table_CI.png", width=>614, height=>716, tex_size=>700, extra_html_tags=>'alt="Both the Z-table and T-table will be attached to quiz 5." ' ) \}

END_TEXT

BEGIN_PGML

*Q5.1a)* Given that previous research has shown a reliable standard deviation of [\LARGE {\sigma} ]= 3.4 for the number of courses of antibiotic courses proscribed to rural 20 year olds, determine a [$conf]% confidence interval for the mean number of antibiotic courses proscribed to 20 year olds of this rural county. Note! The prompts for entry below are just for the extra credit Quiz 5. On the hard copy Quiz 5 the prompts for cell entries will not be given, and only white space will exist below this line. ______________________________________ This answer blank is for$normp = [______]

Given weighted answer blanks how would this "$normp" answer be placed in the table below? END_PGML BEGIN_TEXT$PAR

$PAR \{ DataTable( [ ['We assume the data set '.$pop1->menu.' normally $BR distributed because by the Anderson Darling test: ',' ',['$$\hspace{20pt} \Large{\text{p}}$$ '.$pop2->menu.' $$\Large{\alpha }$$ $BR normp '.$pop3->menu.''.pop4->menu.'', cellcss=> 'border:1px solid black;', ]], ], caption => 'Verify Normality:', midrules=>0, align => 'p{3.4in} p{0.2in} p{2.1in}' ); \}BR

$PAR END_TEXT BEGIN_PGML The [$conf] % confidence interval on the mean number of courses of antibiotics taken by a 20-year old in this rural county is:

[ \Large{(}] [____] [ \Large{,}] [____] [\Large{)}].  (Use second decimal accuracy.)

*Q5.2*  A graduate student determined the clutch size (the number of eggs in a nest for a breeding pair) for a random sample of [$n2] [$bird] nests. Given that the sample returned a mean clutch size of [\bar x] = [$xbar] and an sd = [$s], find a [$conf2]% confidence interval on the clutch size for the population of [$birds].

*Note:* We can not test for normality with summarized values, however since we are forming a confidence interval on the mean value and the use of mean values implies a normal distribution exists, we must acknowledge this by stating:

We assume that the data [$pop5->menu]* normally distributed. (And yes, we must state this for summarized values on the hardcopy quiz.) The [$conf2] % confidence interval on the mean clutch size for [$birds] is: [ \Large{(}] [____] [ \Large{,}] [____] [\Large{)}]. (Use second decimal accuracy.) *Q5.3* Interpret the meaning of confidence for the [$conf2]% confidence interval of the previous problem. Use the context of the problem, [$bird] clutch size, to indicate what [$conf2]% confidence implies. That is, [$conf2]% of what is true? Note that while this problem uses a multiple choice scenario, the hard copy quiz will require that you write your own sentence. [$pop6->menu]*

A.)  There is a [$conf2]% chance that a random sample mean clutch size for the [$bird] will fall within the confidence interval that we have constructed.

B.)  [$conf2]% of all random sample means of the [$birds] clutch size will be bracketed by the confidence interval that we have constructed, while [$comp]% of the sample means of the [$birds] clutch size will fall outside the confidence interval.

C.)  [$conf2]% of all true means of the clutch size for a [$bird] will be bracketed by the confidence interval, while [$comp]% of the true means will fall outside the confidence interval for the clutch size for the [$bird].

D.)  [$conf2]% of all confidence intervals constructed from random samples of the clutch size for the [$bird] will bracket the true mean clutch size for the [$bird]. E.) There is a [$conf2]% chance that the true mean clutch size for the [$bird] will fall within the confidence interval that we have constructed. F.) [$conf2]% of all clutch sizes for the [$bird] will be bracketed by the [$conf2]% confidence.

END_PGML

WEIGHTED_ANS( ($pop1)->cmp, 4 ); WEIGHTED_ANS( ($pop2)->cmp, 4 );

WEIGHTED_ANS( ($normp)->cmp, 8 ); WEIGHTED_ANS( ($pop3)->cmp, 4 );

WEIGHTED_ANS( ($pop4)->cmp, 4 ); WEIGHTED_ANS( ($lbt)->cmp, 15 );

WEIGHTED_ANS( ($ubt)->cmp, 15 ); WEIGHTED_ANS( ($pop5)->cmp, 4 );

WEIGHTED_ANS( ($lbt2)->cmp, 15 ); WEIGHTED_ANS( ($ubt2)->cmp, 15 );

WEIGHTED_ANS( ($pop6)->cmp, 12 ); BEGIN_PGML_SOLUTION *SOLUTION* Solution coming in 2017... END_PGML_SOLUTION ENDDOCUMENT(); In reply to tim Payer ### Re: Answer blank syntax for weighted grader within a table by Davide Cervone - Use ['text '.$normp->ans_rule(width).' text ' ]

and then
WEIGHTED_ANS(\$normp->cmp,weight);

as you do with the other values.
In reply to Davide Cervone

### Re: Answer blank syntax for weighted grader within a table

by tim Payer -
Thanks again,

I really appreciate the help!

I am looking forward to to have this all come together.