WeBWorK Problems

Popups not working within Column displays?

Popups not working within Column displays?

by tim Payer -
Number of replies: 3
Greetings,

I am trying to use Popup questions with an image in a homework problem where the pop-up question and the image are displayed side by side in two columns.

I am using the nice.tables and Popups macros abut i am getting an error message about contexts.

Could you please help determine my glitch?

Thanks, the Code block is below.

# DESCRIPTION   
# Stat 109 Data summarization
# 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",
"MathObjects.pl",
"PGML.pl",
"parserPopUp.pl",  
"unionTables.pl",
"PGcourse.pl"
);



#TEXT(beginproblem());

install_problem_grader(~~&std_problem_grader);
$showPartialCorrectAnswers = 1;

Context()->texStrings;

#Context("Numeric")->flags->set(
#tolerance => 1.0,
#tolType => 'absolute',
#);
#Context()->variables->add(t=>"Real");


## comment out $d0 soon
$g2 =44;
$d0 = 0;

if($d0 == 0)
{
$popans1 = "Boxplot A";
} elsif ($d0 == 1){
$popans1 = "Boxplot B";
} elsif ($d0 == 2){
$popans1 = "Boxplot C";
} else {
$popans1 = "Boxplot D";
}

$popup1 = PopUp(
["choose", "Boxplot A", "Boxplot B", "Boxplot C", "Boxplot D" ], $popans1);

# Popup notation does not work in column format??
# 3.4b)   Determine which boxplot below is an accurate plot for the histogram of commute # times: [___]{$popans1} 



$column1 = PGML::Format(<<END_PGML);


3.4b)   Determine which boxplot below is an accurate plot for the histogram of commute  times: [___]{$popans1} 

 



END_PGML
$column2 =$BCENTER.image("Hist_HW_3p4.png", width=>1172, height=>611, tex_size=>500).$BR." ".$ECENTER;

 

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

BEGIN_PGML_SOLUTION
*SOLUTION*

The solution will be explained or shown below:  



END_PGML_SOLUTION

ENDDOCUMENT();

In reply to tim Payer

Re: Popups not working within Column displays?

by tim Payer -
Here is some updated code that displays the problem with using popups in a column format:

Standard answers work fine in a column display, but not popup questions.

The error statement claims "Unexpected character '\'; see position 1 of formula.

But I am using no formula.

Can you please help determine my error?

Thank so much,   Tim

# DESCRIPTION   
# Stat 109 Data summarization
# 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",
"MathObjects.pl",
"PGML.pl",
"parserPopUp.pl",  
"unionTables.pl",
"PGcourse.pl"
);



#TEXT(beginproblem());

install_problem_grader(~~&std_problem_grader);
$showPartialCorrectAnswers = 1;

Context()->texStrings;

#Context("Numeric")->flags->set(
#tolerance => 1.0,
#tolType => 'absolute',
#);
#Context()->variables->add(t=>"Real");



@city =('Petaluma', 'Arcata', 'Santa Rosa', 'Burlingame');

$d0 = random(0,3,1);

if($d0 == 0)
{
$box = "Boxplot A";
$graph = "Petaluma_A.png";
$loc = $city[$d0];
$mean = "16.0";
$median = "15";
} elsif ($d0 == 1){
$box = "Boxplot B";
$graph = "Arcata_B.png";
$loc = $city[$d0];
$mean = "5.437";
$median = "5";
} elsif ($d0 == 2){
$box = "Boxplot C";
$graph = "Santa_Rosa_C.png";
$loc = $city[$d0];
$mean = "12.27";
$median = "12";
} else {
$box = "Boxplot D";
$graph = "Burlingame_D.png";
$loc = $city[$d0];
$mean = "26.6";
$median = "26";
}

$pop1 = PopUp(
["choose", "Boxplot A", "Boxplot B", "Boxplot C", "Boxplot D" ], $box);

$pop2 = PopUp(
["choose", "15", "5", "12", "26" ], $median);

$pop3 = PopUp(
["choose", "16.0", "5.437", "12.27", "26.6" ], $mean);

$trial = 4;

# Does Popup notation does not work in a table column format??




$column1 = PGML::Format(<<END_PGML);

 
3.4a)   Determine which boxplot below is an accurate plot for the histogram of [``$loc``] commute times above:  
[___]{$pop1}   
 
3.4b)   Determine the median value for the histogram of [``$loc``] commute times.  
(Use an educated guess, not calculation).  
[``\Large{\tilde x}``] = [___]{$pop2}   
 
3.4c)   Determine the mean value for the histogram of [``$loc``] commute times.  
(Use an educated guess, not calculation).  
[``\bar x``] = [___]{$pop3}  

END_PGML
$column2 =$BCENTER.image($graph, width=>789, height=>793, tex_size=>500).$BR." ".$ECENTER;


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

BEGIN_PGML_SOLUTION
*SOLUTION*

The solution will be explained or shown below:  



END_PGML_SOLUTION

ENDDOCUMENT();
In reply to tim Payer

Re: Popups not working within Column displays?

by tim Payer -
Okay, the Popup issue in columns is still not resolved!

I changed the Context to Strings for a specific popup variable that is being used in a column format.


Context()->strings->add(A => {}, B => {}, C => {}, D => {}, E => {}, F => {}, G => {}, H => {}, I => {}, J => {}, K => {}, L => {});

$pop1 = PopUp(
["choose", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"],"c");

This will permit the correct answer, "c", to be submitted but the student, but the student will not see the choices afforded by the popup menu because the popup display does "pop-up", rather it is an empty display cell.

Can anyone determine what the issue might be here? 
Or is it the case that "popups" can not be used within columns?

Any insight would be most appreciated:

Below is a recent revised code block showing the glitch.

Thanks, 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",
"niceTables.pl",
"unionTables.pl",
"PGunion.pl",
"MathObjects.pl",
"PGML.pl",
"parserPopUp.pl",
"parserFormulaUpToConstant.pl"
);


Context("Numeric");
install_problem_grader(~~&std_problem_grader);
$showPartialCorrectAnswers = 1;

Context()->flags->set(
  tolerance => 0.0001,
  tolType => "absolute",
);

$spotn = random(2,7,1);

do { $nospotn = random(1, 6); } until (($nospotn != $spotn) and (gcd($nospotn,$spotn) == 1));

#$spot = list_random('two', 'three', 'four', 'five', 'six', 'seven');

if($spotn == 2 )
{
$spot ='two'; 
} elsif ($spotn == 3)
{
$spot ='three'; 
} elsif ($spotn == 4)
{
$spot ='four'; 
} elsif ($spotn == 5)
{
$spot ='five'; 
} elsif ($spotn == 6)
{
$spot ='six'; 
} else
{
$spot ='seven';
}

if($nospotn == 1 )
{
$nospot ='one'; 
} elsif ($nospotn == 2)
{
$nospot ='two'; 
} elsif ($nospotn == 3)
{
$nospot ='three'; 
} elsif ($nospotn == 4)
{
$nospot ='four'; 
} elsif ($nospotn == 5)
{
$nospot ='five'; 
} else
{
$nospot ='six';
}

$p = $spotn/($spotn + $nospotn);

## Until the error that results from a display of Popup answers within columns
## can be resolved, single lettered entries will used.

Context()->strings->add(A => {}, B => {}, C => {}, D => {}, E => {}, F => {}, G => {}, H => {}, I => {}, J => {}, K => {}, L => {});

$pop1 = PopUp(
["choose", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"],"c");


#$pop1 = "c";

$p0 = random(0.02, 0.13, 0.01);
$p1 = random(0.38, 0.48, 0.01);
$p3 = random(0.07, 0.21, 0.01);
$p2 = 1-$p0-$p1-$p3;
$mean = 0*$p0+1*$p1 +2*$p2+3*$p3;
$sd = sqrt(0**2*$p0 +1**2*$p1 +2**2*$p2 +3**2*$p3 -$mean**2);
$lb = $mean -$sd;
$ub = $mean +$sd;

##$column2 =$BCENTER.image($graph, width=>789, height=>793, tex_size=>500).$BR." ".$ECENTER;



$column1 = PGML::Format(<<END_PGML);

 
*Drawn From Lecture Notes: Week 4 Day 2.*

*6.1)* The body of the Pacific banana slug, _Ariolimax columbianus_, comes in a variety of color and spot displays. Unlike its bright yellow relative, the California banana slug, the Pacific banana slug can be seen with yellow, green, black, brown, or even white bodies. Dark spots often, but not always, cover much of its skin. The coloration and spots are thought to be dependent upon the slugs diet and local micro-climate.  
 
*6.1a)*   Given that there are [``$spot``] spotted Pacific banana slugs for every [``$nospot``] non spotted Pacific banana slug(s) in Arcata's community forest, let [`x`] represent the probability of drawing a single spotted Pacific banana slug from a single draw of both varieties of spotted and non spotted slugs.  
 
   Find the probability:  P(x) = [_____]{$p}  

*6.1b - 6.1e)*  Use the following declared variable within probability notation to answer the following questions about random draws of the Pacific banana slug from the community forest:  
 
Let [`Y`] = The number of spotted Pacific banana slugs in a random draw of four slugs.

*6.1b)*  Find the probability that three slugs are spotted and one is not from four random draws of the Pacific banana slug. Use the letter from the table below to indicate the correct probability notation for the left side of the equation and then enter the correct probability with accuracy to the fourth decimal.  
 
Use notation first then the numeric answer:  [_____]{$pop1} = [_____]{$p}  
 
 
*6.1c)*  Find the probability that all four slugs are spotted from four random draws of the Pacific banana slug. Use the letter from the table below to indicate the correct probability notation for the left side of the equation and then enter the correct probability with accuracy to the fourth decimal.  
 
*6.1d)*  Find the probability that all four slugs are all the same type. That is all four are spotted or all four are not spotted from four random draws of the Pacific banana slug. Use the letter from the table below to indicate the correct probability notation for the left side of the equation and then enter the correct probability with accuracy to the fourth decimal.  
 
*6.1e)*  Find the typical range for the number of spotted slugs drawn from a four slug draw of the Pacific banana slug. Express this range as a first standard deviation window.  
Lower sd window bound = [_____]{$lb}  
Upper sd window bound = [_____]{$ub}  

spotn = [``$spotn``]  
nospotn = [``$nospotn``] 

spot = [``$spot``]  
nospot = [``$nospot``] 
p = [``$p``]  


END_PGML




$column2 =$BCENTER."The Pacific banana slugs with and without spots: ".image("P_slug_Stephanie_Marsh.png", width=>373, height=>497, tex_size=>700).$BR."photo by Stephanie Marsh ".$BR.image("P_slug_Kelly_Fretwell.png", width=>396, height=>429, tex_size=>700).$BR."photo by Kelly Fretwell".$BR.$ECENTER;

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


BEGIN_TEXT
\[
\begin{array}{|c|c|c|}
\hline
\text{a.)   } P(Y < 3) & \text{e.)   } P(Y  \ge   3) &  \text{i.)   } P(Y \le 4) \\
\text{b.)   } P(Y > 3) & \text{f.)   } P(Y  <  4) &  \text{j.)   } P(Y \ge 4) \\
\text{c.)   } P(Y = 3) & \text{g.)   } P(Y  >  4) &  \text{k.)   } P(Y = 4) \cap P(Y = 4) \\
\text{d.)   } P(Y \le 3) & \text{h.)   } P(Y  =  4) &  \text{l.)   } P(Y = 4) \cup P(Y = 4) \\
\hline
\end{array}
\]


\( \ge \)
$BR
END_TEXT

BEGIN_PGML

*5.1a)*    Find the expected number of buttercups per quadrant: [``\Large{\mu_x}``] = [_____]{$mean}  


*5.1b)*    Find the expected standard deviation of buttercups per quadrant using fourth decimal accuracy: [``\Large{\sigma_x}``] = [_____]{$sd}  
 
*5.1c)*    Determine the first standard deviation window for a count of buttercups per quadrant using fourth decimal accuracy:  
Lower sd window bound = [_____]{$lb}  
Upper sd window bound = [_____]{$ub}  
 



END_PGML


BEGIN_PGML_SOLUTION
*SOLUTION*

Solution coming in 2017...
 

END_PGML_SOLUTION

ENDDOCUMENT();