Fundamental Theorem of Calculus: handling the preview button.
When clicking the preview button, messages that you prepare for the student will be displayed. In the problem below you learn how to prevent this.
# Created by Nikola Kuzmanovski ######################################################################## DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGinfo.pl", ); TEXT(beginproblem()); $showPartialCorrectAnswers = 1; ############################################################## # # Setup # # Context("Numeric"); $f_DownLim = random(-9, 9, 1); $f_UpLim = random($f_DownLim + 5, $f_DownLim + 15, 1); $integral = random(-9, 9, 1) + 1; $F_UpLim = random(-9, 9, 1) + 1; $F_DownLim = $F_UpLim - $integral; ############################################################## # # Text # # Context()->texStrings; BEGIN_TEXT Suppose that you have two functions \(f(x)\) and \(F(x)\) such that \(F'(x)=f(x)\). Also, suppose that \begin{eqnarray*} \int_{$f_DownLim}^{$f_UpLim} f(x) &=& $integral\\ F($f_UpLim) &=& $F_UpLim. \end{eqnarray*} Then \(F($f_DownLim) = \) \{ans_rule\}. END_TEXT Context()->normalStrings; ############################################################## # # Answers # # $checkFTCSolve = sub{ if($inputs_ref->{previewAnswers}){ return 0.0; } my ($correctAns, $studentAns, $ansHash) = @_; $score = 0.0; if($correctAns == $studentAns){ $ansHash->{ans_message} = "Great Job!"; $score = 1.0; }elsif(Real("$F_UpLim + $integral") == $studentAns){ $ansHash->{ans_message} = "You might have made a mistake when moving the integral to the other side of the equation. It could also be that you made a mistake when negating the equation."; $score = 0.9; }elsif(Real("-$F_UpLim - $integral") == $studentAns){ $ansHash->{ans_message} = "You might have made a mistake when moving F(".$f_UpLim.") to the other side of the equation. It could also be that you made a mistake when negating the equation."; $score = 0.9; }elsif(Real("-$F_UpLim + $integral") == $studentAns){ $ansHash->{ans_message} = "You made several algebra mistakes. Go back and check you work. Make sure you are careful when moving things around the = and when negating."; $score = 0.8; }else{ $ansHash->{ans_message} = "Sorry, you didn't get any credit. Try reviewing the material on the Fundamental Theorem of Calculus."; $score = 0.0; } return $score; }; ANS(Real("$F_DownLim")->cmp(checker => $checkFTCSolve)); ENDDOCUMENT();
Exercises:
- Remove the "PGinfo.pl", line. What happens?
- Remove the first if statement in the answer checker. What happens?