WeBWorK Problems

Using popups with NAMED_WEIGHTED_ANS

Using popups with NAMED_WEIGHTED_ANS

by tim Payer -
Number of replies: 2

Greetings,

 

I am using the NAMED_WEIGHTED_ANS() tool so that I can combine the features of answerHints() with weighted grading in a homework problem.

 

This is my first use of the tool and I would like to ask for some guidance.

 

1.)  Is the use of NAMED_WEIGHTED_ANS() the only way (or the most likely way) that a weighted grader and answer hints for specific wrong answers can be combined in a homework problem?

 

2.) I have had to change the answer blanks to fit PG coding for the NAMED_WEIGHTED_ANS(). I am assuming that PGML coding is perhaps possible to be used with it, but the syntax for the answer blanks is different? If so could you please show how this syntax for answer blanks are changed?

 

3.) The use of popups with the NAMED_WEIGHTED_ANS() poses a problem in that either specifying a width or ignoring a width input in the \{NAMED_ANS_RULE("popc", 10)\} results in a popup answer blank that does not "pop-up". However, the answer cell will still function, it is just that the selection normally given by the pop-up is not visible.Could you please let me know how the syntax in a popup answer would be changed to permit the the popup blank to function with the NAMED_WEIGHTED_ANS()?

 

Thank you so much for considering the following code block that shows non-functioning pop-up:


# DESCRIPTION  CI on mu for t-intervals and z-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",

"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",

);



## Problem 11.1 ##


$nn = list_random('four', 'five', 'six', 'seven', 'eight', 'nine');

if($nn eq 'four') {

$n = 4;

} elsif($nn eq 'five') {

$n = 5;

}elsif($nn eq 'six') {

$n = 6;

}elsif($nn eq 'seven') {

$n = 7;

}elsif($nn eq 'eight') {

$n = 8;

}else {

$n = 9;

}

@thy =();

foreach my $i (0..$n-1) {

   $thy[$i] = random(21.0, 45.0, 0.1);

}


$mean = stats_mean(@thy);

$sd = stats_sd(@thy);

$mean1 = sprintf("%0.1f",$mean);

$sd1 = sprintf("%0.1f",$sd);


$jj = join("$BR  ", @thy);

$rr =join(", ", @thy);


$sigma =0.8*$sd1;

$sigma1 = sprintf("%0.1f",$sigma);

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

##########################


### Prob 11.1a) ########


$SE = Compute("$sd1/sqrt($n)");


### Prob 11.1b) and 11.1c) ########


if($conf == 80){

$zint = 1.282;

   if($n==4) {

   $tint = 1.63778;

   } elsif($n==5) {

   $tint = 1.53320;

   } elsif($n==6) {

   $tint = 1.47589;

   } elsif($n==7) {

   $tint = 1.43977;

   } elsif($n==8) {

   $tint = 1.41493;

   } else {

   $tint = 1.39685;

   } 

} if($conf == 90){

$zint = 1.645;

   if($n==4) {

   $tint = 2.35341;

   } elsif($n==5) {

   $tint = 2.13184;

   } elsif($n==6) {

   $tint = 2.01505;

   } elsif($n==7) {

   $tint = 1.94317;

   } elsif($n==8) {

   $tint = 1.89456;

   } else {

   $tint = 1.85953;

   } 

} if($conf == 95){

$zint = 1.960;

   if($n==4) {

   $tint = 3.1825;

   } elsif($n==5) {

   $tint = 2.7764;

   } elsif($n==6) {

   $tint = 2.5706;

   } elsif($n==7) {

   $tint = 2.4469;

   } elsif($n==8) {

   $tint = 2.3646;

   } else {

   $tint = 2.3060;

   } 

} if($conf == 98){

$zint = 2.326;

   if($n==4) {

   $tint = 4.5407;

   } elsif($n==5) {

   $tint = 3.7470;

   } elsif($n==6) {

   $tint = 3.3649;

   } elsif($n==7) {

   $tint = 3.1427;

   } elsif($n==8) {

   $tint = 2.9980;

   } else {

   $tint = 2.8965;

   } 

} if($conf == 99){

$zint = 2.576;

   if($n==4) {

   $tint = 5.8410;

   } elsif($n==5) {

   $tint = 4.6041;

   } elsif($n==6) {

   $tint = 4.0321;

   } elsif($n==7) {

   $tint = 3.7075;

   } elsif($n==8) {

   $tint = 3.4995;

   } else {

   $tint = 3.3554;

   } 

} if($conf == 99.9){

$zint = 3.291;

   if($n==4) {

   $tint = 12.924;

   } elsif($n==5) {

   $tint = 8.610;

   } elsif($n==6) {

   $tint = 6.869;

   } elsif($n==7) {

   $tint = 5.959;

   } elsif($n==8) {

   $tint = 5.408;

   } else {

   $tint = 5.041;

   } 

}


$lbt = $mean1 - $tint*$SE;

$ubt = $mean1 + $tint*$SE;

$lbz = Compute("$mean1 - $zint*$sigma1/sqrt($n)");

$ubz = Compute("$mean1 + $zint*$sigma1/sqrt($n)");

$lbs = Compute("$mean1 - $zint*$sd1/sqrt($n)");

$ubs = Compute("$mean1 + $zint*$sd1/sqrt($n)");

$lbtt = Compute("$mean1 - $tint*$sigma1/sqrt($n)");

$ubtt = Compute("$mean1 + $tint*$sigma1/sqrt($n)");


### Prob 11.1d) ########


$popup1 = PopUp(

["Choose:",  'A', 'B', 'C', 'D', 'E' ], 'D');


####  Begin Problem...


 

BEGIN_PGML 

   *Drawn from Lecture Notes: Week 6 Day 1.*  


*11.1)*   As part of a study of the development of the thymus gland, researchers weighed the glands of [$nn] chick embryos after 14 days of incubation. The thymus weights (mg) were as follows:  [$rr]


 

END_PGML 


BEGIN_TEXT


$BR

$BR

$BBOLD 11.1a) $EBOLD  Calculate the standard error of the mean using second decimal accuracy: $BR


SE = \{NAMED_ANS_RULE("stndr",10)\}

$BR

$BR

$BBOLD 11.1b) $EBOLD  Calculate a $conf% confidence interval on the population mean thymus gland weight for chick embryos that have incubated for 14 days using second decimal accuracy:  $BR

$BR

\( = \Large{(\,} \) \{NAMED_ANS_RULE("lwrbt",10)\} \( \Large{, \,}\) \{NAMED_ANS_RULE("upbt",10)\} \( \Large{)} \text{mg}\) 

$BR


$BBOLD 11.1c) $EBOLD Suppose the research on thymus glands in incubating chicks has progressed to such a state that the researchers have determined a reliable standard deviation of \(\sigma\) = 5.4. How does knowing the true standard deviation affect the calculation of the confidence interval? Calculate a $conf% confidence interval on the population mean thymus gland weight for chick embryos that have incubated for 14 days for when: \(\sigma\) is known. Use second decimal accuracy.

$BR

\( = \Large{(\,} \) \{NAMED_ANS_RULE("lwrbz",10)\} \( \Large{, \,}\) \{NAMED_ANS_RULE("upbz",10)\} \( \Large{)} \text{mg}\) 

$BR

$BR

$BBOLD 11.1d) $EBOLD  Interpret the meaning of the confidence interval in the context of this problem. If we have $conf% confidence, then $conf% of what must be true? Choose the one correct interpretation within the following list below:

\{NAMED_ANS_RULE("popc", 10)\} $BR

A.) $conf% confidence means that $conf% of all thymus gland weights (mg) of 14 day old chicks will exist within the $conf% confidence interval that we have calculated.$BR

B.) $conf% confidence means that $conf% of all true mean thymus gland weights (mg) of 14 day old chicks will exist within the $conf% confidence interval that we have calculated.$BR

C.) $conf% confidence means that $conf% of all sample mean thymus gland weights (mg) of 14 day old chicks will exist within the $conf% confidence interval that we have calculated. $BR

D.) $conf% confidence means that $conf% of all samples of thymus gland weights (mg) of 14 day old chicks will form $conf% confidence intervals that contain the population mean. $BR

E.) $conf% confidence means that $conf% of all samples of thymus gland weights (mg) of 14 day old chicks will form $conf% confidence intervals that contain the sample mean. $BR


END_TEXT



$showPartialCorrectAnswers = 1;




NAMED_WEIGHTED_ANS( "stndr" => $SE->cmp()->withPostFilter(AnswerHints(Compute("$sd1**2/sqrt($n)") =>"Use the sample sd, not sd squared!",Compute("$SE") =>"Excellent!",)),8);


NAMED_WEIGHTED_ANS( "lwrbt" => $lbt->cmp()->withPostFilter(AnswerHints(Compute("$lbs") =>"Wrong table! We only use the z-table $BR when the true sd, \(\sigma\) is known.",Compute("$lbt") =>"Yes!",)),17);


NAMED_WEIGHTED_ANS( "upbt" => $ubt->cmp()->withPostFilter(AnswerHints(Compute("$ubs") =>"Wrong table! We only use the z-table $BR when the true sd, \(\sigma\)  is known.",Compute("$ubt") =>"Excellent!",)),17);


NAMED_WEIGHTED_ANS( "lwrbz" => $lbz->cmp()->withPostFilter(AnswerHints(Compute("$lbtt") =>"Wrong table! We use the z-table when the true $BR sd, \(\sigma\), is known, not the t-table.",Compute("$lbz") =>"Yes!",)),20);


NAMED_WEIGHTED_ANS( "upbz" => $ubz->cmp()->withPostFilter(AnswerHints(Compute("$ubtt") =>"Wrong table! We use the z-table when the true $BR sd, \(\sigma\), is known, not the t-table.",Compute("$ubz") =>"Excellent!",)),20);


#WEIGHTED_ANS( ($popup1)->cmp, 18 );


NAMED_WEIGHTED_ANS( "popc" => $popup1->cmp()->withPostFilter(AnswerHints("B" =>"There is only one true mean value.","D" =>"Excellent!",)),18);


BEGIN_PGML_SOLUTION



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




END_PGML_SOLUTION


ENDDOCUMENT();              

In reply to tim Payer

Re: Using popups with NAMED_WEIGHTED_ANS

by Davide Cervone -
1.) Is the use of NAMED_WEIGHTED_ANS() the only way (or the most likely way) that a weighted grader and answer hints for specific wrong answers can be combined in a homework problem?

You could use plain WEIGHTED_ANS, without names, but if you are using PGML, then you would have to use ANS() or WEIGHTED_ANS() for all the answers.

2.) I have had to change the answer blanks to fit PG coding for the NAMED_WEIGHTED_ANS(). I am assuming that PGML coding is perhaps possible to be used with it, but the syntax for the answer blanks is different?

You would need to insert the blanks using variable or command substitutions rather than PGML answer rules. See the example below.

3.) Could you please let me know how the syntax in a popup answer would be changed to permit the the popup blank to function with the NAMED_WEIGHTED_ANS()?

You can use $popup->menu("name") to get a named popup menu. You do not use NAMES_ANS_RULE() directly. See below.


Here is how to use named answer rules in PGML with answer hints and weighted answers.

$pop = PopUp(["A","B","C"],"A");

BEGIN_PGML
Select a letter: [$pop->menu("myPopup")]*
END_PGML

NAMED_ANS(myPopup => $pop->cmp->withPostFilter(
  AnswerHints(
    A => "Awesome!",
    B => "Bummer!",
    C => "Curses!"
  )
));

You can use NAMED_WEIGHTED_ANS() in the same way.

In reply to Davide Cervone

Re: Using popups with NAMED_WEIGHTED_ANS

by tim Payer -
Thank you so much Davide!

I will incorporate all of these corrections soon!

Tim