## DESCRIPTION ## Precalculus: answer could be a string or another data type ## ENDDESCRIPTION ## KEYWORDS('precalculus', 'answer is a string or other data type') ## DBsubject('WeBWorK') ## DBchapter('WeBWorK Tutorial') ## DBsection('Fort Lewis Tutorial 2011') ## Date('01/30/2011') ## Author('Paul Pearson') ## Institution('Fort Lewis College') ## TitleText1('') ## EditionText1('') ## AuthorText1('') ## Section1('') ## Problem1('') ########################### # Initialization DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); ########################### # Setup Context("Numeric"); \$y = random(0,4,1); if (\$y < 4) { \$answer = String("none"); } else { \$answer = Formula("2*x"); } ########################### # Main text Context()->texStrings; BEGIN_TEXT Is there a line through the points \( (0,0) \), \( (1,2) \), and \( (2,\$y) \)? If there is, the equation for this line. If not, enter \${BITALIC}NONE\${EITALIC}. \$BR \$BR \( y = \) \{ ans_rule(20) \} \{ AnswerFormatHelp("formulas") \} END_TEXT Context()->normalStrings; ############################ # Answer evaluation \$showPartialCorrectAnswers = 1; ANS( \$answer->cmp( typeMatch=>Formula("x") ) ); ############################ # Solution Context()->texStrings; BEGIN_SOLUTION \${PAR}SOLUTION:\${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT();