I do have a follow up question.
Is there any particular trick to using a pop-up menu in multi-answer.
I've used them before and have set the package to be used and defined
$pop = PopUp(["select","linear","quadratic","exponential","logistic","logarithmic"], "logarithmic");
I then included the pop-up menu in the problem and changed multianswer to call the pop-up.
However, I just get a message saying that the string is not defined. (strangely the pop-up menu is also appearing twice in my question even though I only include it once in the problem.)
I previously had it set up with the strings, which worked as long as they had a feedback message for each answer (so linear and exponential worked as they should using the custom checker included but any other said that it could not convert the word to a number unless I included a message for the first answer also).
I currently have it set-up to compare to floating point numbers because it needed to check against different numbers for each choice. It is also using the inherent 10% tolerance, but I am able to control that through Edfinity where the questions are asigned through to any percent or fixed tolerance I want.
Context()->strings->add("no solution"=>{},
"no solutions"=>{alias=>'no solution'},
"none"=>{alias=>'no solution'});
$pop = PopUp(["select","linear","quadratic","exponential","logistic","logarithmic"], "logarithmic");
$ans_6 = $b0 + $b1*($year-1970);
$ans_7 = ($mpg-$b0)/($b1);
$multians = MultiAnswer($pop, $ans_6, $ans_7)->with(
singleResult => 0, allowBlankAnswers => 1,
checker => sub {
my ( $correct, $student, $self ) = @_;
my ( $a1s, $a2s, $a3s ) = @{$student};
my ( $a1, $a2, $a3 ) = @{$correct};
if ( $a1s == "linear"){
if ($a2s == $b0+$b1*($year-1970) && $a3s == ($mpg-$b0)/$b1) {$self->setMessage(1,"A line is not the best choice.");
return [1,1,1]}
elsif ($a2s == $b0+$b1*($year-1970) && $a3s != ($mpg-$b0)/$b1) {$self->setMessage(1,"A line is not the best choice.");
$self->setMessage(3,"Check your calculation.");
return [1,1,0]}
elsif ($a2s != $b0+$b1*($year-1970) && $a3s == ($mpg-$b0)/$b1) {$self->setMessage(1,"A line is not the best choice.");
$self->setMessage(2,"Check your calculation.");
return [1,0,1]}
else {$self->setMessage(1,"A line is not the best choice.");
$self->setMessage(2,"Check your calculation.");
$self->setMessage(3,"Check your calculation.");
return [1,0,0]}}
elsif ( $a1s == "quadratic"){
if ($a2s == $a*($year-1970)**2 +$b*($year-1970) +$c && $a3s == "no solution") {
return [1,1,1]}
elsif ($a2s == $a*($year-1970)**2 +$b*($year-1970) +$c && $a3s != "no solution") {$self->setMessage(3,"Check your calculation.");
return [1,1,0]}
elsif ($a2s != $a*($year-1970)**2 +$b*($year-1970) +$c && $a3s == "no solution") {$self->setMessage(2,"Check your calculation.");
return [1,0,1]}
else {$self->setMessage(2,"Check your calculation.");
$self->setMessage(3,"Check your calculation.");
return [1,0,0]}}
elsif ( $a1s == "exponential"){
if ($a2s == 15.3285*(1.0107**($year-1970)) && $a3s == ln($mpg/15.3285)/ln(1.0107)) {$self->setMessage(1,"A exponential is not a good choice.");
return [0,1,1]}
elsif ($a2s == 15.3285*(1.0107**($year-1970)) && $a3s != ln($mpg/15.3285)/ln(1.0107)) {$self->setMessage(1,"A exponental is not a good choice.");
$self->setMessage(3,"Check your calculation.");
return [0,1,0]}
elsif ($a2s != 15.3285*(1.0107**($year-1970)) && $a3s == ln($mpg/15.3285)/ln(1.0107)) {$self->setMessage(1,"A exponential is not a good choice.");
$self->setMessage(2,"Check your calculation.");
return [0,0,1]}
else {$self->setMessage(1,"A exponential is not a good choice.");
$self->setMessage(2,"Check your calculation.");
$self->setMessage(3,"Check your calculation.");
return [0,0,0]}}
elsif ( $a1s == "logistic"){
if ($a2s == 24.2704/(1+1.2059*exp(-0.08638*($year-1970))) && $a3s == "no solution") {
return [1,1,1]}
elsif ($a2s == 24.2704/(1+1.2059*exp(-0.08638*($year-1970))) && $a3s != "no solution") {$self->setMessage(3,"Check your calculation.");
return [1,1,0]}
elsif ($a2s != 24.2704/(1+1.2059*exp(-0.08638*($year-1970))) && $a3s == "no solution") {$self->setMessage(2,"Check your calculation.");
return [1,0,1]}
else {$self->setMessage(2,"Check your calculation.");
$self->setMessage(3,"Check your calculation.");
return [1,0,0]}}
elsif ( $a1s == "logarithmic"){
if ($a2s == 4.3528+5.1643*ln(($year-1970)) && $a3s == exp(($mpg-4.3528)/5.1643)) {
return [1,1,1]}
elsif ($a2s == 4.3528+5.1643*ln(($year-1970)) && $a3s != exp(($mpg-4.3528)/5.1643)) {$self->setMessage(3,"Check your calculation.");
return [1,1,0]}
elsif ($a2s != 4.3528+5.1643*ln(($year-1970)) && $a3s == exp(($mpg-4.3528)/5.1643)) {$self->setMessage(2,"Check your calculation.");
return [1,0,1]}
else {$self->setMessage(2,"Check your calculation.");
$self->setMessage(3,"Check your calculation.");
return [1,0,0]}}
else {
return [0,0,0];
}
}
);
b) Which of the better model to use? \{$pop->menu()\}
$PAR
$BR
$BR
c) For the model chosen in the last part, what is the average miles per gallon expected to be in $year? (Round to 1 decimal place.)
$BR
The average miles per gallon in $year is predicted to be \{$multians->ans_rule(15)\} mpg.
$PAR
$BR
$BR
d) For the model chosen, when will the miles per gallon be $mpg? (Depending on your, choice you may
have no solution or very large numbers. Round any decimals to one place.)
$BR
We predict that the mpg will be $mpg \{$multians->ans_rule(15)\} years after 1970.