WeBWorK Problems

Context for Using Popups within a data table under a weighted grader.

by tim Payer -
Number of replies: 2

Greetings,

I am trying to use pop-ups within a data table with a weighted grader option.

My context for this entry is incorrect. Can you please help determine how these pop-ups should be entered?

[$pop7->menu]* works for PGML, But this must be adjusted for PG code to work within a data table. Neither of these attempts below work and I do not see a guide for using popups with data tables and a weighted grader. Could you please offer a solution? $$pop7->menu$$* $$pop7->menu()$$* I have attached a sample code problem with error. Please forgive my hacking guess-work… Tim # 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(); loadMacros( "PGstandard.pl", "PGunion.pl", "niceTables.pl", "unionTables.pl", "PGstatisticsmacros.pl", "PGnumericalmacros.pl", "MathObjects.pl", "parserPopUp.pl", "parserFormulaUpToConstant.pl", "PGML.pl", "weightedGrader.pl" ); install_problem_grader(~~&std_problem_grader);$showPartialCorrectAnswers = 1;

Context("Numeric");

$pop7 = PopUp( ["Choose:", "is", "is not"], "is");$pop8 = PopUp(

["Choose:", "p < ", "p >"], "p < ");

$pop9 = PopUp( ["Choose:", "<", ">"], ">"); Context()->flags->set( tolerance => 0.0001, tolType => "absolute", );$m = random(20,35,1);

$s =random(4,8,1);$h =random(1,3,1);

$l =random(1,3,1);$hi =Compute("$m +$s+$h");$lo =Compute("$m -$s-$l");$zl =Compute("($lo -$m)/$s");$zh =Compute("($hi -$m)/$s"); ## Calculating the probability of a single success ## using Z-tables.$zl4 = sprintf("%0.4f",$zl);$zh4 = sprintf("%0.4f",$zh);$ans7 =Compute("$zl4");$ans8 =Compute("$zh4");$zl2 =sprintf("%0.2f",$zl);$zh2 =sprintf("%0.2f",$zh);$ans9 =Compute("$zl2");$ans10 =Compute("$zh2");$pc = normal_prob($ans9,$ans10,  mean=>0, deviation=>1);

$ans11 =Compute("$pc");

$crab = list_random('four', 'five', 'six', 'seven', 'eight'); #$crab ='eight';

if($crab eq four ) {$pop10 = PopUp(

["Choose:", "4", "5", "6","7", "8"], "4");

$ans12 = Compute("$ans11**4");

} elsif ($crab eq five) {$pop10 = PopUp(

["Choose:", "4", "5", "6","7", "8"], "5");

$ans12 = Compute("$ans11**5");

} elsif ($crab eq six) {$pop10 = PopUp(

["Choose:", "4", "5", "6","7", "8"], "6");

$ans12 = Compute("$ans11**6");

} elsif ($crab eq seven) {$pop10 = PopUp(

["Choose:", "4", "5", "6","7", "8"], "7");

$ans12 = Compute("$ans11**7");

} else

{

$pop10 = PopUp( ["Choose:", "4", "5", "6","7", "8"], "8");$ans12 = Compute("$ans11**8"); ## Until the error that results from a display of Popup answers within columns ## can be resolved, single lettered entries will used. ## The popups just below are preferred, but create error statements: ## Errors parsing PGML: ## Error parsing answer: Unexpected character '='; see position 5 of formula ##$pop1 = PopUp(["choose", "P(Y = $pc1%)", "P(Y =$pc2%)", "P(Y = $pc3%)", "P(Y = ##0.$pc1 )", "P(Y = 0.$pc2 )", "P(Y = 0.$pc3 )", "P(Y =  $nc1 )", "P(Y =$nc2 )", "P(Y =  ##$nc3 )"],"P(Y =$nc1 )");

#$pop1 = PopUp(["choose",$anx], $anx); ## And even these "lettered" Popups can not be run within the columns. #$pop1 = PopUp(["choose", "a", "b", "c", "d", "e", "f", "g", "h", "i"],"g");

#$pop2 = PopUp(["choose", "a", "b", "c", "d", "e", "f", "g", "h", "i"],"h"); #$pop3 = PopUp(["choose", "a", "b", "c", "d", "e", "f", "g", "h", "i"],"i");

$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 like what 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 98% 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. ______________________________________

[$pop8->menu]* [$pop9->menu]*

END_PGML

BEGIN_TEXT

$PAR \{ DataTable( [ [['We assume the data set IS IS NOT, here: ($pop7->menu()) normally distributed because by the Anderson Darling test:  ', ], ' $$\Large{\alpha }$$ '  ],

],

caption => ' Verify normality ',

midrules => 1,

align => '|p{4.3in}|p{1.3in}|',

);

\}

$PAR END_TEXT BEGIN_PGML [7.2b) \quad \Large{P(}] [$pop10->menu]* [\Large{) \approx}]

[____]

END_PGML

WEIGHTED_ANS( ($pop7)->cmp, 2 ); WEIGHTED_ANS( ($ans8)->cmp, 20 );

WEIGHTED_ANS( ($pop9)->cmp, 2 ); WEIGHTED_ANS( ($ans10)->cmp, 20 );

WEIGHTED_ANS( ($ans12)->cmp, 30 ); BEGIN_PGML_SOLUTION *SOLUTION* Solution coming in 2017... END_PGML_SOLUTION ENDDOCUMENT(); In reply to tim Payer Re: Context for Using Popups within a data table under a weighted grader. by Davide Cervone - Try ['We assume the data set '.$pop7->menu.' normally distributed because by the Anderson Darling test:  ' ]

so that the pop-up menu is inserted into the string before the table is processed.

Re: Context for Using Popups within a data table under a weighted grader.

by tim Payer -
Excellent!

Thank you Davide,

I will apply this after this next round of grading,

Best, Tim